[Solved] Beginner - Blank screen

Problems building or running the engine, queries about how to use features etc.
Post Reply
Monke
Gnoblar
Posts: 2
Joined: Mon Aug 20, 2007 7:50 pm

[Solved] Beginner - Blank screen

Post by Monke »

I have recently started learning Ogre and I like it alot. But for some reason I get a blank screen when running my compiled code. The goal is to render the Ninja from the example tutorials on the screen without using ExampleApplication, but there's nothing but a black screen. I'm on Ubuntu and using Ogre 1.2.5, it's not a driver issue as the Sample applications work fine. It's probably something very simple.

Below are pastes of the following:
1. Output of the program in the terminal
2. Code of the application header (application.h)
3. Code of the application implementation (application.cpp)

1. program output

Code: Select all

Creating resource group General
Creating resource group Internal
Creating resource group Autodetect
Registering ResourceManager for type Material
Registering ResourceManager for type Mesh
Registering ResourceManager for type Skeleton
MovableObjectFactory for type 'ParticleSystem' registered.
Loading library libOgrePlatform.so
OverlayElementFactory for type Panel registered.
OverlayElementFactory for type BorderPanel registered.
OverlayElementFactory for type TextArea registered.
Registering ResourceManager for type Font
ArchiveFactory for archive type FileSystem registered.
ArchiveFactory for archive type Zip registered.
DevIL version: Developer's Image Library (DevIL) 1.6.7 Jun 21 2006
DevIL image formats: bmp dib cut dcx dds gif hdr ico cur jpg jpe jpeg lif mdl mng jng pcx pic pix png pbm pgm pnm ppm psd pdd psp pxr sgi bw rgb rgba tga vda icb vst tif tiff wal xpm raw 
Registering ResourceManager for type HighLevelGpuProgram
Registering ResourceManager for type Compositor
MovableObjectFactory for type 'Entity' registered.
MovableObjectFactory for type 'Light' registered.
MovableObjectFactory for type 'BillboardSet' registered.
MovableObjectFactory for type 'ManualObject' registered.
MovableObjectFactory for type 'BillboardChain' registered.
MovableObjectFactory for type 'RibbonTrail' registered.
Loading library /usr/lib/OGRE/RenderSystem_GL.so
OpenGL Rendering Subsystem created.
Loading library /usr/lib/OGRE/Plugin_ParticleFX.so
Particle Emitter Type 'Point' registered
Particle Emitter Type 'Box' registered
Particle Emitter Type 'Ellipsoid' registered
Particle Emitter Type 'Cylinder' registered
Particle Emitter Type 'Ring' registered
Particle Emitter Type 'HollowEllipsoid' registered
Particle Affector Type 'LinearForce' registered
Particle Affector Type 'ColourFader' registered
Particle Affector Type 'ColourFader2' registered
Particle Affector Type 'ColourImage' registered
Particle Affector Type 'ColourInterpolator' registered
Particle Affector Type 'Scaler' registered
Particle Affector Type 'Rotator' registered
Particle Affector Type 'DirectionRandomiser' registered
Particle Affector Type 'DeflectorPlane' registered
Loading library /usr/lib/OGRE/Plugin_BSPSceneManager.so
Registering ResourceManager for type BspLevel
Loading library /usr/lib/OGRE/Plugin_OctreeSceneManager.so
Loading library /usr/lib/OGRE/Plugin_EXRCodec.so
EXRCodec initialised
*-*-* OGRE Initialising
*-*-* Version 1.2.5 (Dagon)
******************************
*** Starting GLX Subsystem ***
******************************
ResourceBackgroundQueue - threading disabled
GLXWindow::create
Parsing miscParams
GLXWindow::create -- Best visual is 36
GL_VERSION = 2.1.0 NVIDIA 97.55
GL_VENDOR = NVIDIA Corporation
GL_RENDERER = GeForce 6600/PCI/SSE2/3DNOW!
GL_EXTENSIONS = GL_ARB_color_buffer_float GL_ARB_depth_texture GL_ARB_draw_buffers GL_ARB_fragment_program GL_ARB_fragment_program_shadow GL_ARB_fragment_shader GL_ARB_half_float_pixel GL_ARB_imaging GL_ARB_multisample GL_ARB_multitexture GL_ARB_occlusion_query GL_ARB_pixel_buffer_object GL_ARB_point_parameters GL_ARB_point_sprite GL_ARB_shadow GL_ARB_shader_objects GL_ARB_shading_language_100 GL_ARB_texture_border_clamp GL_ARB_texture_compression GL_ARB_texture_cube_map GL_ARB_texture_env_add GL_ARB_texture_env_combine GL_ARB_texture_env_dot3 GL_ARB_texture_float GL_ARB_texture_mirrored_repeat GL_ARB_texture_non_power_of_two GL_ARB_texture_rectangle GL_ARB_transpose_matrix GL_ARB_vertex_buffer_object GL_ARB_vertex_program GL_ARB_vertex_shader GL_ARB_window_pos GL_ATI_draw_buffers GL_ATI_texture_float GL_ATI_texture_mirror_once GL_S3_s3tc GL_EXT_texture_env_add GL_EXT_abgr GL_EXT_bgra GL_EXT_blend_color GL_EXT_blend_equation_separate GL_EXT_blend_func_separate GL_EXT_blend_minmax GL_EXT_blend_subtract GL_EXT_compiled_vertex_array GL_EXT_Cg_shader GL_EXT_depth_bounds_test GL_EXT_draw_range_elements GL_EXT_fog_coord GL_EXT_framebuffer_blit GL_EXT_framebuffer_multisample GL_EXT_framebuffer_object GL_EXT_gpu_program_parameters GL_EXT_multi_draw_arrays GL_EXT_packed_depth_stencil GL_EXT_packed_pixels GL_EXT_pixel_buffer_object GL_EXT_point_parameters GL_EXT_rescale_normal GL_EXT_secondary_color GL_EXT_separate_specular_color GL_EXT_shadow_funcs GL_EXT_stencil_two_side GL_EXT_stencil_wrap GL_EXT_texture3D GL_EXT_texture_compression_s3tc GL_EXT_texture_cube_map GL_EXT_texture_edge_clamp GL_EXT_texture_env_combine GL_EXT_texture_env_dot3 GL_EXT_texture_filter_anisotropic GL_EXT_texture_lod GL_EXT_texture_lod_bias GL_EXT_texture_mirror_clamp GL_EXT_texture_object GL_EXT_texture_sRGB GL_EXT_timer_query GL_EXT_vertex_array GL_IBM_rasterpos_clip GL_IBM_texture_mirrored_repeat GL_KTX_buffer_region GL_NV_blend_square GL_NV_copy_depth_to_color GL_NV_depth_clamp GL_NV_fence GL_NV_float_buffer GL_NV_fog_distance GL_NV_fragment_program GL_NV_fragment_program_option GL_NV_fragment_program2 GL_NV_framebuffer_multisample_coverage GL_NV_half_float GL_NV_light_max_exponent GL_NV_multisample_filter_hint GL_NV_occlusion_query GL_NV_packed_depth_stencil GL_NV_pixel_data_range GL_NV_point_sprite GL_NV_primitive_restart GL_NV_register_combiners GL_NV_register_combiners2 GL_NV_texgen_reflection GL_NV_texture_compression_vtc GL_NV_texture_env_combine4 GL_NV_texture_expand_normal GL_NV_texture_rectangle GL_NV_texture_shader GL_NV_texture_shader2 GL_NV_texture_shader3 GL_NV_vertex_array_range GL_NV_vertex_array_range2 GL_NV_vertex_program GL_NV_vertex_program1_1 GL_NV_vertex_program2 GL_NV_vertex_program2_option GL_NV_vertex_program3 GL_NVX_conditional_render GL_SGIS_generate_mipmap GL_SGIS_texture_lod GL_SGIX_depth_texture GL_SGIX_shadow GL_SUN_slice_accum 
***************************
*** GL Renderer Started ***
***************************
Registering ResourceManager for type GpuProgram
GLSL support detected
GL: Using GL_EXT_framebuffer_object for rendering to textures (best)
FBO PF_UNKNOWN depth/stencil support: D16S0 D24S0 D32S0 
FBO PF_R5G6B5 depth/stencil support: D0S0 D16S0 
FBO PF_B5G6R5 depth/stencil support: D0S0 D16S0 
FBO PF_R8G8B8 depth/stencil support: D0S0 D24S0 D32S0 
FBO PF_B8G8R8 depth/stencil support: D0S0 D24S0 D32S0 
FBO PF_A8R8G8B8 depth/stencil support: D0S0 D24S0 D32S0 Packed-D24S8 
FBO PF_B8G8R8A8 depth/stencil support: D0S0 D24S0 D32S0 Packed-D24S8 
FBO PF_A2R10G10B10 depth/stencil support: D0S0 D24S0 D32S0 Packed-D24S8 
FBO PF_A2B10G10R10 depth/stencil support: D0S0 D24S0 D32S0 Packed-D24S8 
FBO PF_FLOAT16_RGB depth/stencil support: D0S0 D24S0 D32S0 
FBO PF_FLOAT16_RGBA depth/stencil support: D0S0 D24S0 D32S0 
FBO PF_FLOAT32_RGB depth/stencil support: D0S0 D24S0 D32S0 
FBO PF_FLOAT32_RGBA depth/stencil support: D0S0 D24S0 D32S0 
FBO PF_X8R8G8B8 depth/stencil support: D0S0 D24S0 D32S0 Packed-D24S8 
FBO PF_X8B8G8R8 depth/stencil support: D0S0 D24S0 D32S0 Packed-D24S8 
FBO PF_SHORT_RGBA depth/stencil support: D0S0 D24S0 D32S0 
FBO PF_R3G3B2 depth/stencil support: D0S0 D16S0 
[GL] : Valid FBO targets PF_UNKNOWN PF_R5G6B5 PF_B5G6R5 PF_R8G8B8 PF_B8G8R8 PF_A8R8G8B8 PF_B8G8R8A8 PF_A2R10G10B10 PF_A2B10G10R10 PF_FLOAT16_RGB PF_FLOAT16_RGBA PF_FLOAT32_RGB PF_FLOAT32_RGBA PF_X8R8G8B8 PF_X8B8G8R8 PF_SHORT_RGBA PF_R3G3B2 
RenderSystem capabilities
-------------------------
 * Hardware generation of mipmaps: yes
 * Texture blending: yes
 * Anisotropic texture filtering: yes
 * Dot product texture operation: yes
 * Cube mapping: yes
 * Hardware stencil buffer: yes
   - Stencil depth: 8
   - Two sided stencil support: yes
   - Wrap stencil values: yes
 * Hardware vertex / index buffers: yes
 * Vertex programs: yes
   - Max vertex program version: vp40
 * Fragment programs: yes
   - Max fragment program version: fp40
 * Texture Compression: yes
   - DXT: yes
   - VTC: yes
 * Scissor Rectangle: yes
 * Hardware Occlusion Query: yes
 * User clip planes: yes
 * VET_UBYTE4 vertex element type: yes
 * Infinite far plane projection: yes
 * Hardware render-to-texture: yes
 * Floating point textures: yes
 * Non-power-of-two textures: yes
 * Volume textures: yes
 * Multiple Render Targets: 4
 * Point Sprites: yes
 * Extended point parameters: yes
 * Max Point Size: 63.375
Registering ResourceManager for type Texture
Particle Renderer Type 'billboard' registered
Added resource location '/home/guido-xubuntu/projects/ogre/dat' of type 'FileSystem' to resource group 'General'
Parsing scripts for resource group Autodetect
Finished parsing scripts for resource group Autodetect
Parsing scripts for resource group General
Parsing script Example.material
Error at line 183 of Example.material: Error in program Examples/MorningSkyBoxHDRfp parameter entry_point is not valid.
Error at line 183 of Example.material: Error in program Examples/MorningSkyBoxHDRfp parameter profiles is not valid.
Error in material Examples/MorningSkyBox at line 211 of Example.material: Invalid vertex_program_ref entry - vertex program Ogre/BasicVertexPrograms/AmbientOneTexture has not been defined.
Error at line 234 of Example.material: Error in program Examples/MorningCubeMapHDRfp parameter entry_point is not valid.
Error at line 234 of Example.material: Error in program Examples/MorningCubeMapHDRfp parameter profiles is not valid.
Error in material Examples/Robot at line 697 of Example.material: Invalid vertex_program_ref entry - vertex program Ogre/HardwareSkinningOneWeight has not been defined.
Error in material Examples/Robot at line 709 of Example.material: Invalid shadow_caster_vertex_program_ref entry - vertex program Ogre/HardwareSkinningOneWeightShadowCaster has not been defined.
Error at line 757 of Example.material: Error in program Examples/GrassWaverVp parameter entry_point is not valid.
Error at line 757 of Example.material: Error in program Examples/GrassWaverVp parameter profiles is not valid.
Error in material Examples/HardwareMorphAnimation at line 844 of Example.material: Invalid vertex_program_ref entry - vertex program Ogre/HardwareMorphAnimation has not been defined.
Error in material Examples/HardwarePoseAnimation at line 879 of Example.material: Invalid vertex_program_ref entry - vertex program Ogre/HardwarePoseAnimation has not been defined.
Error in material jaiqua at line 987 of Example.material: Invalid vertex_program_ref entry - vertex program Ogre/HardwareSkinningTwoWeights has not been defined.
Error in material jaiqua at line 999 of Example.material: Invalid shadow_caster_vertex_program_ref entry - vertex program Ogre/HardwareSkinningTwoWeightsShadowCaster has not been defined.
Finished parsing scripts for resource group General
Parsing scripts for resource group Internal
Finished parsing scripts for resource group Internal
Mesh: Loading ninja.mesh.
Skeleton: Loading ninja.skeleton
Texture: nskingr.jpg: Loading 1 faces(PF_B8G8R8,512x512x1) with 9 hardware generated mipmaps from Image. Internal format is PF_X8R8G8B8,512x512x1.
Creating viewport on target 'main', rendering from camera 'camera', relative dimensions L: 0.00 T: 0.00 W: 1.00 H: 1.00 ZOrder: 0
Viewport for camera 'camera', actual dimensions L: 0 T: 0 W: 640 H: 480
2. application.h

Code: Select all

#ifndef OGRE_APPLICATION_H
#define OGRE_APPLICATION_H

#include <libguido.h>
#include <Ogre.h>

class Application : public libguido::Application {
private:
	bool _good;
	Ogre::Root _root;
	Ogre::SceneManager* _sceneMgr;
	Ogre::RenderWindow* _renderWindow;
	Ogre::Camera* _camera;
	Ogre::Viewport* _viewport;
	
	int _selectRenderSystem(void);
	
	int _setupResources(void);
	int _createEntities(void);
	int _createLights(void);
	int _createCameras(void);
	int _createViewports(void);
	
	int _init(void);
	
public:
	Application(void);
	
	int main(int argc, const char* argv[]);
	
};

#endif
3. application.cpp

Code: Select all

#include <iostream>
#include <string>
using namespace std;

#include <libguido.h>
#include <application.h>
#include <Ogre.h>
using namespace Ogre;

int Application::_selectRenderSystem(void) {
	RenderSystemList* list = Root::getSingleton().getAvailableRenderers();
	if(list->size() == 0) {
		LIBGUIDO_SETERROR("no rendersystem available");
		LIBGUIDO_TRACEERROR(_selectRenderSystem);
		return LG_ERROR;
	}
	
	RenderSystemList::const_iterator i;
	
	/* Select rendersystems in the following order:
	 * OpenGL
	 * Direct3D
	 * First in list
	 */
	
	RenderSystem* rs = NULL;
	
	for(i = list->begin(); i != list->end(); i++) {
		string name = (*i)->getName();
		if(name.find("OpenGL") != string::npos) {
			rs = *i;
			break;
		}
	}
	
	if(!rs) {
		for(i = list->begin(); i != list->end(); i++) {
			string name = (*i)->getName();
			if(name.find("Direct3D") != string::npos) {
				rs = *i;
				break;
			}
		}
	}
	
	if(!rs) rs = *(list->begin());
	
	Root::getSingleton().setRenderSystem(rs);
	return LG_SUCCESS;
}

int Application::_setupResources(void) {
	Root::getSingleton().addResourceLocation(
		"/home/guido-xubuntu/projects/ogre/dat", "FileSystem");
	
	ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
	
	return LG_SUCCESS;
}

int Application::_createEntities(void) {
	Entity* ent = _sceneMgr->createEntity("ninja", "ninja.mesh");
		
	SceneNode* node = _sceneMgr->createSceneNode();
	node->attachObject(ent);
	node->setPosition(Vector3(0.0, 0.0, 0.0));
	
	_sceneMgr->getRootSceneNode()->addChild(node);
	
	return LG_SUCCESS;
}

int Application::_createLights(void) {
	Light* light = _sceneMgr->createLight("light");
	
	light->setPosition(Vector3(0.0, 500.0, 0.0));
	light->setType(Light::LT_POINT);
	
	_sceneMgr->setAmbientLight(ColourValue(1, 1, 1));
	
	return LG_SUCCESS;
}

int Application::_createCameras(void) {
	_camera = _sceneMgr->createCamera("camera");
	
	_camera->setPosition(Vector3(0.0, 10.0, -10.0));
	_camera->lookAt(Vector3(0.0, -0.1, 0.0));
	
	return LG_SUCCESS;
}

int Application::_createViewports(void) {
	_viewport = _renderWindow->addViewport(_camera);
	_camera->setAspectRatio(_viewport->getActualWidth() /
		_viewport->getActualHeight());
	
	return LG_SUCCESS;
}

int Application::_init(void) {
	if(_selectRenderSystem() == LG_ERROR) {
		LIBGUIDO_TRACEERROR(_init);
		return LG_ERROR;
	}
	
	Root::getSingleton().initialise(false);
	if(!Root::getSingleton().isInitialised()) {
		LIBGUIDO_SETERROR("could not initialise Root");
		LIBGUIDO_TRACEERROR(_init);
		return LG_ERROR;
	}
	
	_renderWindow = Root::getSingleton().createRenderWindow("main",
		640, 480, false);
	
	_sceneMgr = Root::getSingleton().createSceneManager(ST_GENERIC);
	
	if(_setupResources() == LG_ERROR) {
		LIBGUIDO_TRACEERROR(_init);
		return LG_ERROR;
	}
	
	if(_createEntities() == LG_ERROR) {
		LIBGUIDO_TRACEERROR(_init);
		return LG_ERROR;
	}
	
	if(_createLights() == LG_ERROR) {
		LIBGUIDO_TRACEERROR(_init);
		return LG_ERROR;
	}
	
	if(_createCameras() == LG_ERROR) {
		LIBGUIDO_TRACEERROR(_init);
		return LG_ERROR;
	}
	
	if(_createViewports() == LG_ERROR) {
		LIBGUIDO_TRACEERROR(_init);
		return LG_ERROR;
	}
	
	return LG_SUCCESS;
}

Application::Application(void) : _good(false),
	_root("/etc/OGRE/plugins.cfg"), _sceneMgr(NULL),
	_renderWindow(NULL), _camera(NULL), _viewport(NULL) {
	
	if(_init() != LG_ERROR) _good = true;
	else LIBGUIDO_TRACEERROR(Application);
}

int Application::main(int argc, const char* argv[]) {
	if(!_good) {
		LIBGUIDO_TRACEERROR(main);
		cout << endl << LIBGUIDO_ERROR << endl << endl;
		return -1;
	}
	
	Root::getSingleton().startRendering();
	
	return 0;
}

//macro defines main entry point
LIBGUIDO_APPLICATION_MAIN(Application)
Inside the /home/guido-xubuntu/projects/ogre/dat directory are the following files copied from the Samples/Media subdirectories:
Example.material
ninja.mesg
ninja.skeleton
nskingr.jpg
Last edited by Monke on Mon Aug 20, 2007 10:45 pm, edited 1 time in total.
User avatar
walaber
OGRE Expert User
OGRE Expert User
Posts: 829
Joined: Sat Oct 02, 2004 2:20 pm
Location: California, USA
Contact:

Post by walaber »

how big is the ninja.mesh? are you sure the camera isn't "inside" the model, so you aren't seeing anything?
Go Go Gadget OGRE!!
Image
Monke
Gnoblar
Posts: 2
Joined: Mon Aug 20, 2007 7:50 pm

Post by Monke »

Thanks for taking the time to reply.

I edited the source and this time took the values from the Basic Tutorial 2 but the distance from the ninja to the camera was not the problem. I have solved it now: it was a missing call to _renderWindow->setActive(true);

Thanks again. :)
Post Reply