Porting windows game engine. crashes on loading.

Discussion of issues specific to mobile platforms such as iOS, Android, Symbian and Meego.
xxpokerxx
Gnoblar
Posts: 7
Joined: Sun Jul 24, 2011 8:18 pm

Porting windows game engine. crashes on loading.

Post by xxpokerxx »

Hi All,

so what i am trying to do is port my game engine i have developed for windows to run on my iphone. I have converted the starting class that most of my engine uses. The conversion seemed to go fine, pretty much all the code in the template provided "OgreFramework.h/.cpp" is inside my class so i figured i could replace the OgreFramework with my "Game.h/.cpp", there are some left over things that arent/wont be used (Window resizing and keyboard methods for example). i also have a world class that has setting up entities, camera's etc. i have ported the bare minimum for that class to work so as not to overcomplicate something while still starting the port. i have modified the appdelegate to run my Game's go() method which does all the initialization and creates a world. however the app opens the status bar rotates and i get this output in the log and then i get a SIGABRT exception in main.mm. this output looks the same as when an app successfully loads (at least to me, i didnt go line by line)

Code: Select all

GNU gdb 6.3.50-20050815 (Apple version gdb-1518) (Sat Feb 12 02:52:12 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin".sharedlibrary apply-load-rules all
Attaching to process 1644.
Creating resource group General
Creating resource group Internal
Creating resource group Autodetect
SceneManagerFactory for type 'DefaultSceneManager' registered.
Registering ResourceManager for type Material
Registering ResourceManager for type Mesh
Registering ResourceManager for type Skeleton
MovableObjectFactory for type 'ParticleSystem' registered.
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.
DDS codec registering
FreeImage version: 3.15.0
This program uses FreeImage, a free, open source image library supporting all common bitmap formats. See http://freeimage.sourceforge.net for details
Supported formats: jpg,jif,jpeg,jpe,png,tga,targa,tif,tiff
PVRTC codec registering
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.
*-*-* OGRE Initialising
*-*-* Version 1.7.3 (Cthugha)
Installing plugin: OpenGL ES 1.x RenderSystem
OpenGL ES 1.x Rendering Subsystem created.
Plugin successfully installed
CPU Identifier & Features
-------------------------
 *   CPU ID: GenuineIntel: Intel(R) Core(TM)2 CPU         T7200  @ 2.00GHz
 *      SSE: yes
 *     SSE2: yes
 *     SSE3: yes
 *      MMX: yes
 *   MMXEXT: yes
 *    3DNOW: no
 * 3DNOWEXT: no
 *     CMOV: yes
 *      TSC: yes
 *      FPU: yes
 *      PRO: yes
 *       HT: no
-------------------------
GLESRenderSystem::_createRenderWindow "Capstone v1.0", 320x480 fullscreen  miscParams: FSAA=0 contentScalingFactor=2 displayFrequency=0 Hz orientation=Landscape Right 
iOS: Window created 320 x 480 with backing store size 640 x 960 using content scaling factor 2.0
GL_VERSION = OpenGL ES-CM 1.1 APPLE
GL_VENDOR = Apple Computer, Inc.
GL_RENDERER = Apple Software Renderer
GL_EXTENSIONS = GL_OES_blend_equation_separate GL_OES_blend_func_separate GL_OES_blend_subtract GL_OES_compressed_paletted_texture GL_OES_depth24 GL_OES_draw_texture GL_OES_fbo_render_mipmap GL_OES_framebuffer_object GL_OES_mapbuffer GL_OES_matrix_palette GL_OES_packed_depth_stencil GL_OES_point_size_array GL_OES_point_sprite GL_OES_read_format GL_OES_rgb8_rgba8 GL_OES_stencil_wrap GL_OES_stencil8 GL_OES_texture_mirrored_repeat GL_OES_vertex_array_object GL_EXT_blend_minmax GL_EXT_discard_framebuffer GL_EXT_read_format_bgra GL_EXT_texture_filter_anisotropic GL_EXT_texture_lod_bias GL_APPLE_framebuffer_multisample GL_APPLE_texture_2D_limited_npot GL_APPLE_texture_format_BGRA8888 GL_APPLE_texture_max_level GL_IMG_read_format GL_IMG_texture_compression_pvrtc 
EXT:GL_OES_blend_equation_separate
EXT:GL_OES_blend_func_separate
EXT:GL_OES_blend_subtract
EXT:GL_OES_compressed_paletted_texture
EXT:GL_OES_depth24
EXT:GL_OES_draw_texture
EXT:GL_OES_fbo_render_mipmap
EXT:GL_OES_framebuffer_object
EXT:GL_OES_mapbuffer
EXT:GL_OES_matrix_palette
EXT:GL_OES_packed_depth_stencil
EXT:GL_OES_point_size_array
EXT:GL_OES_point_sprite
EXT:GL_OES_read_format
EXT:GL_OES_rgb8_rgba8
EXT:GL_OES_stencil_wrap
EXT:GL_OES_stencil8
EXT:GL_OES_texture_mirrored_repeat
EXT:GL_OES_vertex_array_object
EXT:GL_EXT_blend_minmax
EXT:GL_EXT_discard_framebuffer
EXT:GL_EXT_read_format_bgra
EXT:GL_EXT_texture_filter_anisotropic
EXT:GL_EXT_texture_lod_bias
EXT:GL_APPLE_framebuffer_multisample
EXT:GL_APPLE_texture_2D_limited_npot
EXT:GL_APPLE_texture_format_BGRA8888
EXT:GL_APPLE_texture_max_level
EXT:GL_IMG_read_format
EXT:GL_IMG_texture_compression_pvrtc
**************************************
*** OpenGL ES 1.x Renderer Started ***
**************************************
Registering ResourceManager for type GpuProgram
GL ES: Using GL_OES_framebuffer_object for rendering to textures (best)
FBO PF_UNKNOWN depth/stencil support: D16S0 D24S0 Packed-D24S8 
FBO PF_R5G6B5 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8 
FBO PF_B5G6R5 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8 
FBO PF_A4R4G4B4 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8 
FBO PF_A1R5G5B5 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8 
FBO PF_R8G8B8 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8 
FBO PF_B8G8R8 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8 
FBO PF_A8R8G8B8 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8 
FBO PF_X8R8G8B8 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8 
FBO PF_X8B8G8R8 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8 
[GLES] : Valid FBO targets PF_UNKNOWN PF_R5G6B5 PF_B5G6R5 PF_A4R4G4B4 PF_A1R5G5B5 PF_R8G8B8 PF_B8G8R8 PF_A8R8G8B8 PF_X8R8G8B8 PF_X8B8G8R8 
RenderSystem capabilities
-------------------------
RenderSystem Name: OpenGL ES 1.x Rendering Subsystem
GPU Vendor: apple
Device Name: Apple Software Renderer
Driver Version: 0.0.0.0
 * Fixed function pipeline: yes
 * Hardware generation of mipmaps: yes[Switching to process 1644 thread 0x610b]

 * Texture blending: yes
 * Anisotropic texture filtering: yes
 * Dot product texture operation: yes
 * Cube mapping: no
 * Hardware stencil buffer: no
 * Hardware vertex / index buffers: yes
 * Vertex programs: no
 * Number of floating-point constants for vertex programs: 0
 * Number of integer constants for vertex programs: 0
 * Number of boolean constants for vertex programs: 0
 * Fragment programs: no
 * Number of floating-point constants for fragment programs: 0
 * Number of integer constants for fragment programs: 0
 * Number of boolean constants for fragment programs: 0
 * Geometry programs: no
 * Number of floating-point constants for geometry programs: 0
 * Number of integer constants for geometry programs: 0
 * Number of boolean constants for geometry programs: 0
 * Supported Shader Profiles:
 * Texture Compression: yes
   - DXT: no
   - VTC: no
   - PVRTC: yes
 * Scissor Rectangle: yes
 * Hardware Occlusion Query: no
 * User clip planes: yes
 * VET_UBYTE4 vertex element type: yes
 * Infinite far plane projection: yes
 * Hardware render-to-texture: yes
 * Floating point textures: no
 * Non-power-of-two textures: no
 * Volume textures: no
 * Multiple Render Targets: 1
   - With different bit depths: no
 * Point Sprites: yes
 * Extended point parameters: yes
 * Max Point Size: 511
 * Vertex texture fetch: no
 * Number of world matrices: 0
 * Number of texture units: 8
 * Stencil buffer depth: 0
 * Number of vertex blend matrices: 0
 * Render to Vertex Buffer : no
 * GL 1.5 without VBO workaround: no
 * Frame Buffer objects: yes
 * Frame Buffer objects (ARB extension): no
 * Frame Buffer objects (ATI extension): no
 * PBuffer support: no
 * GL 1.5 without HW-occlusion workaround: no
Registering ResourceManager for type Texture
DefaultWorkQueue('Root') initialising on thread 0x553ade0.
Particle Renderer Type 'billboard' registered
DefaultWorkQueue('Root')::WorkerFunc - thread 0x92bd280 starting.
DefaultWorkQueue('Root')::WorkerFunc - thread 0x92bd440 starting.
I have uploaded my classes to megaupload, if someone could please take a look and let me know what im doing wrong, need to add/change, etc. I would greatly appreciate it. Thank you very much.

Classes Archive :

Code: Select all

http://www.megaupload.com/?d=9JXKKKX5
xxpokerxx
Gnoblar
Posts: 7
Joined: Sun Jul 24, 2011 8:18 pm

Re: Porting windows game engine. crashes on loading.

Post by xxpokerxx »

OK, so I got rid of the crash, turns out referenceing OIS::OISKeyboard was causing the crash, however now it doesnt crash but it just shows a black screen.

It also seems that people do not want to download the source as only 1 person has downloaded it. so ill just go ahead and post the source here. Please help me out, I really need to get this working soon. Thanks.

current Console Output

Code: Select all

GNU gdb 6.3.50-20050815 (Apple version gdb-1518) (Sat Feb 12 02:52:12 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin".sharedlibrary apply-load-rules all
Attaching to process 2203.
Creating resource group General
Creating resource group Internal
Creating resource group Autodetect
SceneManagerFactory for type 'DefaultSceneManager' registered.
Registering ResourceManager for type Material
Registering ResourceManager for type Mesh
Registering ResourceManager for type Skeleton
MovableObjectFactory for type 'ParticleSystem' registered.
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.
DDS codec registering
FreeImage version: 3.15.0
This program uses FreeImage, a free, open source image library supporting all common bitmap formats. See http://freeimage.sourceforge.net for details
Supported formats: jpg,jif,jpeg,jpe,png,tga,targa,tif,tiff
PVRTC codec registering
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.
*-*-* OGRE Initialising
*-*-* Version 1.7.3 (Cthugha)
Installing plugin: OpenGL ES 1.x RenderSystem
OpenGL ES 1.x Rendering Subsystem created.
Plugin successfully installed
CPU Identifier & Features
-------------------------
 *   CPU ID: GenuineIntel: Intel(R) Core(TM)2 CPU         T7200  @ 2.00GHz
 *      SSE: yes
 *     SSE2: yes
 *     SSE3: yes
 *      MMX: yes
 *   MMXEXT: yes
 *    3DNOW: no
 * 3DNOWEXT: no
 *     CMOV: yes
 *      TSC: yes
 *      FPU: yes
 *      PRO: yes
 *       HT: no
-------------------------
GLESRenderSystem::_createRenderWindow "Capstone v1.0", 320x480 fullscreen  miscParams: FSAA=0 contentScalingFactor=2 displayFrequency=0 Hz orientation=Landscape Right 
iOS: Window created 320 x 480 with backing store size 640 x 960 using content scaling factor 2.0
GL_VERSION = OpenGL ES-CM 1.1 APPLE
GL_VENDOR = Apple Computer, Inc.
GL_RENDERER = Apple Software Renderer
GL_EXTENSIONS = GL_OES_blend_equation_separate GL_OES_blend_func_separate GL_OES_blend_subtract GL_OES_compressed_paletted_texture GL_OES_depth24 GL_OES_draw_texture GL_OES_fbo_render_mipmap GL_OES_framebuffer_object GL_OES_mapbuffer GL_OES_matrix_palette GL_OES_packed_depth_stencil GL_OES_point_size_array GL_OES_point_sprite GL_OES_read_format GL_OES_rgb8_rgba8 GL_OES_stencil_wrap GL_OES_stencil8 GL_OES_texture_mirrored_repeat GL_OES_vertex_array_object GL_EXT_blend_minmax GL_EXT_discard_framebuffer GL_EXT_read_format_bgra GL_EXT_texture_filter_anisotropic GL_EXT_texture_lod_bias GL_APPLE_framebuffer_multisample GL_APPLE_texture_2D_limited_npot GL_APPLE_texture_format_BGRA8888 GL_APPLE_texture_max_level GL_IMG_read_format GL_IMG_texture_compression_pvrtc 
EXT:GL_OES_blend_equation_separate
EXT:GL_OES_blend_func_separate
EXT:GL_OES_blend_subtract
EXT:GL_OES_compressed_paletted_texture
EXT:GL_OES_depth24
EXT:GL_OES_draw_texture
EXT:GL_OES_fbo_render_mipmap
EXT:GL_OES_framebuffer_object
EXT:GL_OES_mapbuffer
EXT:GL_OES_matrix_palette
EXT:GL_OES_packed_depth_stencil
EXT:GL_OES_point_size_array
EXT:GL_OES_point_sprite
EXT:GL_OES_read_format
EXT:GL_OES_rgb8_rgba8
EXT:GL_OES_stencil_wrap
EXT:GL_OES_stencil8
EXT:GL_OES_texture_mirrored_repeat
EXT:GL_OES_vertex_array_object
EXT:GL_EXT_blend_minmax
EXT:GL_EXT_discard_framebuffer
EXT:GL_EXT_read_format_bgra
EXT:GL_EXT_texture_filter_anisotropic
EXT:GL_EXT_texture_lod_bias
EXT:GL_APPLE_framebuffer_multisample
EXT:GL_APPLE_texture_2D_limited_npot
EXT:GL_APPLE_texture_format_BGRA8888
EXT:GL_APPLE_texture_max_level
EXT:GL_IMG_read_format
EXT:GL_IMG_texture_compression_pvrtc
**************************************
*** OpenGL ES 1.x Renderer Started ***
**************************************
Registering ResourceManager for type GpuProgram
GL ES: Using GL_OES_framebuffer_object for rendering to textures (best)
FBO PF_UNKNOWN depth/stencil support: D16S0 D24S0 Packed-D24S8 
FBO PF_R5G6B5 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8 
FBO PF_B5G6R5 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8 
FBO PF_A4R4G4B4 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8 
FBO PF_A1R5G5B5 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8 
FBO PF_R8G8B8 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8 
FBO PF_B8G8R8 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8 
FBO PF_A8R8G8B8 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8 
FBO PF_X8R8G8B8 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8 
FBO PF_X8B8G8R8 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8 
[GLES] : Valid FBO targets PF_UNKNOWN PF_R5G6B5 PF_B5G6R5 PF_A4R4G4B4 PF_A1R5G5B5 PF_R8G8B8 PF_B8G8R8 PF_A8R8G8B8 PF_X8R8G8B8 PF_X8B8G8R8 
RenderSystem capabilities
-------------------------
RenderSystem Name: OpenGL ES 1.x Rendering Subsystem
GPU Vendor: apple
Device Name: Apple Software Renderer
Driver Version: 0.0.0.0
 * Fixed function pipeline: yes
 * Hardware generation of mipmaps: yes
 * Texture blending: yes
 * Anisotropic texture filtering: yes
 * Dot product texture operation: yes
 * Cube mapping: no
 * Hardware stencil buffer: no
 * Hardware vertex / index buffers: yes
 * Vertex programs: no
 * Number of floating-point constants for vertex programs: 0
 * Number of integer constants for vertex programs: 0
 * Number of boolean constants for vertex programs: 0
 * Fragment programs: no
 * Number of floating-point constants for fragment programs: 0
 * Number of integer constants for fragment programs: 0
 * Number of boolean constants for fragment programs: 0
 * Geometry programs: no
 * Number of floating-point constants for geometry programs: 0
 * Number of integer constants for geometry programs: 0
 * Number of boolean constants for geometry programs: 0
 * Supported Shader Profiles:
 * Texture Compression: yes
   - DXT: no
   - VTC: no
   - PVRTC: yes
 * Scissor Rectangle: yes
 * Hardware Occlusion Query: no
 * User clip planes: yes
 * VET_UBYTE4 vertex element type: yes
 * Infinite far plane projection: yes
 * Hardware render-to-texture: yes
 * Floating point textures: no
 * Non-power-of-two textures: no
 * Volume textures: no
 * Multiple Render Targets: 1
   - With different bit depths: no
 * Point Sprites: yes
 * Extended point parameters: yes
 * Max Point Size: 511
 * Vertex texture fetch: no
 * Number of world matrices: 0
 * Number of texture units: 8
 * Stencil buffer depth: 0
 * Number of vertex blend matrices: 0
 * Render to Vertex Buffer : no
 * GL 1.5 without VBO workaround: no
 * Frame Buffer objects: yes
 * Frame Buffer objects (ARB extension): no
 * Frame Buffer objects (ATI extension): no
 * PBuffer support: no
 * GL 1.5 without HW-occlusion workaround: no
Registering ResourceManager for type Texture
DefaultWorkQueue('Root') initialising on thread 0x5586aa0.
Particle Renderer Type 'billboard' registered
Creating resource group Bootstrap
Added resource location '/Users/richardroylance/Library/Application Support/iPhone Simulator/4.3.2/Applications/D2D7E3F5-C459-41AC-8F02-6E6B89348D0A/Capstone.app/media/packs/SdkTrays.zip' of type 'Zip' to resource group 'Bootstrap'
Added resource location '/Users/richardroylance/Library/Application Support/iPhone Simulator/4.3.2/Applications/D2D7E3F5-C459-41AC-8F02-6E6B89348D0A/Capstone.app/media/models' of type 'FileSystem' to resource group 'General'
Added resource location '/Users/richardroylance/Library/Application Support/iPhone Simulator/4.3.2/Applications/D2D7E3F5-C459-41AC-8F02-6E6B89348D0A/Capstone.app/media/materials/scripts' of type 'FileSystem' to resource group 'General'
Added resource location '/Users/richardroylance/Library/Application Support/iPhone Simulator/4.3.2/Applications/D2D7E3F5-C459-41AC-8F02-6E6B89348D0A/Capstone.app/media/materials/textures' of type 'FileSystem' to resource group 'General'
Added resource location '/Users/richardroylance/Library/Application Support/iPhone Simulator/4.3.2/Applications/D2D7E3F5-C459-41AC-8F02-6E6B89348D0A/Capstone.app/media/RTShaderLib' of type 'FileSystem' to resource group 'General'
Added resource location '/Users/richardroylance/Library/Application Support/iPhone Simulator/4.3.2/Applications/D2D7E3F5-C459-41AC-8F02-6E6B89348D0A/Capstone.app/media/RTShaderLib/materials' of type 'FileSystem' to resource group 'General'
Added resource location '/Users/richardroylance/Library/Application Support/iPhone Simulator/4.3.2/Applications/D2D7E3F5-C459-41AC-8F02-6E6B89348D0A/Capstone.app/media/packs/cubemap.zip' of type 'Zip' to resource group 'General'
Added resource location '/Users/richardroylance/Library/Application Support/iPhone Simulator/4.3.2/Applications/D2D7E3F5-C459-41AC-8F02-6E6B89348D0A/Capstone.app/media/packs/cubemapsJS.zip' of type 'Zip' to resource group 'General'
Added resource location '/Users/richardroylance/Library/Application Support/iPhone Simulator/4.3.2/Applications/D2D7E3F5-C459-41AC-8F02-6E6B89348D0A/Capstone.app/media/packs/skybox.zip' of type 'Zip' to resource group 'General'
Parsing scripts for resource group Autodetect
Finished parsing scripts for resource group Autodetect
Parsing scripts for resource group Bootstrap
Parsing script SdkTrays.material
DefaultWorkQueue('Root')::WorkerFunc - thread 0x6817860 starting.
DefaultWorkQueue('Root')::WorkerFunc - thread 0x68200e0 starting.
Parsing script SdkTrays.fontdef
Parsing script SdkTrays.overlay
Bad element attribute line: '# you can offset the image to change the cursor "hotspot"' for element SdkTrays/Cursor in overlay 
Texture: sdk_cursor.png: Loading 1 faces(PF_A8B8G8R8,32x32x1) with 5 hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,32x32x1.
Texture: sdk_tray.png: Loading 1 faces(PF_A8B8G8R8,64x64x1) with 5 hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,64x64x1.
Texture: sdk_button_up.png: Loading 1 faces(PF_A8B8G8R8,128x32x1) with 5 hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,128x32x1.
Texture: sdk_text_box.png: Loading 1 faces(PF_A8B8G8R8,32x32x1) with 5 hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,32x32x1.
Texture: sdk_mini_tray.png: Loading 1 faces(PF_A8B8G8R8,32x32x1) with 5 hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,32x32x1.
Texture: sdk_track.png: Loading 1 faces(PF_A8B8G8R8,16x32x1) with 5 hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,16x32x1.
Texture: sdk_handle.png: Loading 1 faces(PF_A8B8G8R8,16x16x1) with 4 hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,16x16x1.
Texture: sdk_mini_text_box.png: Loading 1 faces(PF_A8B8G8R8,32x32x1) with 5 hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,32x32x1.
Texture: sdk_label.png: Loading 1 faces(PF_A8B8G8R8,32x32x1) with 5 hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,32x32x1.
[Switching to process 2203 thread 0x610b]
Texture: sdk_separator.png: Loading 1 faces(PF_A8B8G8R8,64x16x1) with 5 hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,64x16x1.
Texture: sdk_logo.png: Loading 1 faces(PF_A8B8G8R8,128x64x1) with 5 hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,128x64x1.
Texture: sdk_shade.png: Loading 1 faces(PF_A8B8G8R8,64x48x1) with 5 hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,64x64x1.
Texture: sdk_frame.png: Loading 1 faces(PF_A8B8G8R8,32x32x1) with 5 hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,32x32x1.
Texture: sdk_mini_text_box_over.png: Loading 1 faces(PF_A8B8G8R8,32x32x1) with 5 hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,32x32x1.
Texture: sdk_pulse.png: Loading 1 faces(PF_B8G8R8,8x1x1) with 3 hardware generated mipmaps from Image. Internal format is PF_R8G8B8,8x1x1.
Finished parsing scripts for resource group Bootstrap
Parsing scripts for resource group General
Parsing script barrel.material
Parsing script Examples.material
Compiler error: reference to a non existing object in Examples.material(253)
Compiler error: reference to a non existing object in Examples.material(772)
Compiler error: reference to a non existing object in Examples.material(784)
Compiler error: reference to a non existing object in Examples.material(1281)
Compiler error: reference to a non existing object in Examples.material(1473)
Compiler error: reference to a non existing object in Examples.material(1508)
Compiler error: reference to a non existing object in Examples.material(1617)
Compiler error: reference to a non existing object in Examples.material(1622)
Compiler error: reference to a non existing object in Examples.material(1716)
Parsing script FireballExplosion.material
Parsing script flare.material
Parsing script GreenBasterd.material
Parsing script ground.material
Parsing script missile.material
Parsing script Ogre.material
Parsing script spaceship.material
Parsing script HardwareSkinningShadow.material
Parsing script RTShaderSystem.material
Compiler error: unknown error in RTShaderSystem.material(23): token "rtshader_system" is not recognized
Compiler error: unknown error in RTShaderSystem.material(52): token "rtshader_system" is not recognized
Compiler error: unknown error in RTShaderSystem.material(81): token "rtshader_system" is not recognized
Compiler error: unknown error in RTShaderSystem.material(110): token "rtshader_system" is not recognized
Compiler error: unknown error in RTShaderSystem.material(146): token "rtshader_system" is not recognized
Compiler error: unknown error in RTShaderSystem.material(81): token "rtshader_system" is not recognized
Compiler error: unknown error in RTShaderSystem.material(162): token "rtshader_system" is not recognized
Compiler error: unknown error in RTShaderSystem.material(81): token "rtshader_system" is not recognized
Compiler error: unknown error in RTShaderSystem.material(110): token "rtshader_system" is not recognized
Compiler error: unknown error in RTShaderSystem.material(211): token "rtshader_system" is not recognized
Finished parsing scripts for resource group General
Parsing scripts for resource group Internal
Finished parsing scripts for resource group Internal
Mesh: Loading ogrehead.mesh.
Texture: GreenSkin.jpg: Loading 1 faces(PF_B8G8R8,256x256x1) with 5 hardware generated mipmaps from Image. Internal format is PF_R8G8B8,256x256x1.
Texture: spheremap.png: Loading 1 faces(PF_B8G8R8,256x256x1) with 5 hardware generated mipmaps from Image. Internal format is PF_R8G8B8,256x256x1.
Texture: tusk.jpg: Loading 1 faces(PF_B8G8R8,96x96x1) with 5 hardware generated mipmaps from Image. Internal format is PF_R8G8B8,128x128x1.
Font SdkTrays/Captionusing texture size 512x256
Info: Freetype returned null for character 160 in font SdkTrays/Caption
Texture: SdkTrays/CaptionTexture: Loading 1 faces(PF_BYTE_LA,512x256x1) with  hardware generated mipmaps from Image. Internal format is PF_BYTE_LA,512x256x1.
main.mm

Code: Select all

#include "OgreDemoApp.h"
#include "AppDelegate.h"

int main(int argc, char **argv)
{
	NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
	int retVal = UIApplicationMain(argc, argv, @"UIApplication", @"AppDelegate");
	[pool release];
	return retVal;
}
AppDelegate.h

Code: Select all

#ifndef __AppDelegate_H__
#define __AppDelegate_H__

#include "OgrePlatform.h"

#if !defined(OGRE_IS_IOS)
#  error This header is for use with iOS only
#endif

#ifdef __OBJC__

#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>

// To use CADisplayLink for smoother animation on iPhone comment out
// the following line or define it to 1.  Use with caution, it can
// sometimes cause input lag.
#define USE_CADISPLAYLINK 1


@interface AppDelegate : NSObject <UIApplicationDelegate>
{
    Game game;
}

- (void)go;

@end

@implementation AppDelegate

- (void)go {
    
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
        
    try {
        game.go();
        
        //Ogre::Root::getSingleton().getRenderSystem()->_initRenderTargets();
        
		//Ogre::Root::getSingleton().clearEventTimes();
    } catch( Ogre::Exception& e ) {
        std::cerr << "An exception has occurred: " <<
        e.getFullDescription().c_str() << std::endl;
    }
    
    [pool release];
}

- (void)applicationDidFinishLaunching:(UIApplication *)application
{
    // Hide the status bar
    [[UIApplication sharedApplication] setStatusBarHidden:YES];

    [self go];
}

- (void)applicationWillTerminate:(UIApplication *)application
{
    Ogre::Root::getSingleton().queueEndRendering();
    
    [[UIApplication sharedApplication] performSelector:@selector(terminate:) withObject:nil afterDelay:0.0];
}

- (void)applicationWillResignActive:(UIApplication *)application
{
    Ogre::Root::getSingleton().saveConfig();
    
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
}

@end

#endif

#endif
Game.h

Code: Select all

#ifndef OGRE_FRAMEWORK_H
#define OGRE_FRAMEWORK_H

#include <OgreCamera.h>
#include <OgreEntity.h>
#include <OgreLogManager.h>
#include <OgreOverlay.h>
#include <OgreOverlayElement.h>
#include <OgreOverlayManager.h>
#include <OgreRoot.h>
#include <OgreViewport.h>
#include <OgreSceneManager.h>
#include <OgreRenderWindow.h>
#include <OgreConfigFile.h>

#include <OISEvents.h>
#include <OISInputManager.h>
#include <OISMouse.h>

#ifdef OGRE_STATIC_LIB
#  define OGRE_STATIC_GL
#  if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#    define OGRE_STATIC_Direct3D9
#    if OGRE_USE_D3D10
#      define OGRE_STATIC_Direct3D10
#    endif
#  endif
#  define OGRE_STATIC_CgProgramManager
#  ifdef OGRE_USE_PCZ
#    define OGRE_STATIC_PCZSceneManager
#    define OGRE_STATIC_OctreeZone
#  endif
#  if OGRE_VERSION >= 0x10800
#    if OGRE_PLATFORM == OGRE_PLATFORM_APPLE_IOS
#      define OGRE_IS_IOS 1
#    endif
#  else
#    if OGRE_PLATFORM == OGRE_PLATFORM_IPHONE
#      define OGRE_IS_IOS 1
#    endif
#  endif
#  ifdef OGRE_IS_IOS
#    undef OGRE_STATIC_CgProgramManager
#    undef OGRE_STATIC_GL
#    define OGRE_STATIC_GLES 1
#    ifdef OGRE_USE_GLES2
#      define OGRE_STATIC_GLES2 1
#      define USE_RTSHADER_SYSTEM
#      undef OGRE_STATIC_GLES
#    endif
#    ifdef __OBJC__
#      import <UIKit/UIKit.h>
#    endif
#  endif
#  include "OgreStaticPluginLoader.h"
#endif

#include <OISMultiTouch.h>
#include <SdkTrays.h>

class World;

class Game : public Ogre::Singleton<Game>, Ogre::FrameListener,  OIS::MultiTouchListener, OgreBites::SdkTrayListener
{
public:
	Game();
	~Game();
    
    // the entry point
    void go();
    
    OIS::MultiTouch* getMouse()
    { return mMouse; }
    
    // noncopyable
    Game(const Game&);
    Game& operator= (const Game&);
    
    // core ogre objects
    Ogre::Root* mRoot;
    Ogre::RenderWindow* mWindow;
    Ogre::Viewport* mViewport;
    
    // gui stuff
    OgreBites::SdkTrayManager* mTrayMgr;
    
    Ogre::Overlay* mCrosshairOverlay;
    
    // input handling stuff
    OIS::InputManager* mInputMgr;
    OIS::MultiTouch* mMouse;
    
    // flag to set if program should exit
    bool mShouldQuit;
    
    // the world
    World* mWorld;
    
    Ogre::Log* mLog;

    // private initialization methods
    bool initializeRenderer();
    void initializeInput();
    void initializeGui();
    void initializeResources();
    
    // methods that create and destroy the world
    void createWorld();
    void destroyWorld(); 
    
    // private cleanup methods
    void shutdownRenderer();
    void shutdownInput();
    void shutdownGui();
    
    //
    // Event handler interfaces
    //
    
    // Ogre::FrameListener callbacks
    bool frameRenderingQueued(const Ogre::FrameEvent& evt);
    
    // Ogre::WindowEventListener callbacks
    void windowResized(Ogre::RenderWindow* rw);
    void windowClosed(Ogre::RenderWindow* rw);
  
    // OIS::MultiTouchListener callbacks
	bool touchMoved(const OIS::MultiTouchEvent &evt);
	bool touchPressed(const OIS::MultiTouchEvent &evt); 
	bool touchReleased(const OIS::MultiTouchEvent &evt);
	bool touchCancelled(const OIS::MultiTouchEvent &evt);

protected:
   // Added for Mac compatibility
   Ogre::String                 m_ResourcePath;

#ifdef OGRE_STATIC_LIB
    Ogre::StaticPluginLoader    m_StaticPluginLoader;
#endif
};
#endif 
Game.cpp

Code: Select all

#include "Game.h"
#include "macUtils.h"
#include "World.h"

using namespace Ogre; 

namespace Ogre
{
    template<> Game* Ogre::Singleton<Game>::ms_Singleton = 0;
};

Game::Game()
{
	mRoot = NULL;
    mWindow = NULL;
    mViewport = NULL;
    mTrayMgr = NULL;
    mInputMgr = NULL;
    mMouse = NULL;
    mShouldQuit = false;
    mLog = NULL;
    
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
    m_ResourcePath = macBundlePath() + "/Contents/Resources/";
#elif defined(OGRE_IS_IOS)
    m_ResourcePath = macBundlePath() + "/";
#else
    m_ResourcePath = "";
#endif
}

Game::~Game()
{
    destroyWorld();
    shutdownGui();
    shutdownInput();
    shutdownRenderer();
#ifdef OGRE_STATIC_LIB
    m_StaticPluginLoader.unload();
#endif
}

void Game::go()
{
    if (!initializeRenderer())
        return;
    
    initializeInput();
    initializeResources();
    initializeGui();
    
    createWorld();
    
    mRoot->startRendering();
    
    // Custom game loop
    // - Uses a fixed time step for physics updates.
    // - Prevents some instabilities with physics simulation
    //   that may occur using variable time steps.
    // - Particularly useful for the spring-based ChaseCameraController.
    //
    
    Ogre::Real ticksPerSecond = 100;           // number of physics updates per second
    Ogre::Real dt = 1.f / ticksPerSecond;      // fixed physics time step
    
    mRoot->getTimer()->reset();                // reset timer
    int nTicks = 0;                            // no updates yet
    
    // this is the game loop
    //
    while (!mWindow->isClosed() && !mShouldQuit) {
        
        // update window messages
        Ogre::WindowEventUtilities::messagePump();
        
        // update input device states
        mMouse->capture();
        
        // draw the scene
        mRoot->renderOneFrame();
        
        // get time elapsed since we started the game
        Ogre::Real gameTime = 0.001f * mRoot->getTimer()->getMilliseconds();
        
        // compute elapsed "game time" (time used by physics simulation)
        Ogre::Real simTime = nTicks * dt;
        
        // run enough physics updates to catch up with elapsed time
        //
        
        // don't let the "catchup" physics updates grind us down to a halt
        // - this will happen if each update takes longer than dt.
        //
        const int maxCatchupFrames = 10;
        int numCatchupFrames = 0;
        
        while (gameTime - simTime > 0.5f * dt) {
            mWorld->update(dt);
            simTime += dt;
            nTicks++;
            
            if (numCatchupFrames++ > maxCatchupFrames)
                break;
        }
    }
    
    destroyWorld();
    
    shutdownGui();
    shutdownInput();
    shutdownRenderer();
}

bool Game::initializeRenderer()
{
    new Ogre::LogManager();

	mLog = Ogre::LogManager::getSingleton().createLog("OgreLogfile.log", true, true, false);
	mLog->setDebugOutputEnabled(true);
    
    String pluginsPath;
    // only use plugins.cfg if not static
#ifndef OGRE_STATIC_LIB
    pluginsPath = m_ResourcePath + "plugins.cfg";
#endif
    
    mRoot = new Ogre::Root(pluginsPath, Ogre::macBundlePath() + "/ogre.cfg");
    
#ifdef OGRE_STATIC_LIB
    m_StaticPluginLoader.load();
#endif
    
	if (mRoot->showConfigDialog()) {
        // Let the system create a default rendering window by passing 'true'.
        mWindow = mRoot->initialise(true, "Capstone v1.0");
    } else {
        return false;
    }
    
    // register self as frame listener
    mRoot->addFrameListener(this);
   
	return true;
}

void Game::initializeInput()
{
    // create input manager for our window
    size_t windowHnd = 0;
    mWindow->getCustomAttribute("WINDOW", &windowHnd);
    mInputMgr = OIS::InputManager::createInputSystem(windowHnd);
    
    // create input objects
    mMouse = static_cast<OIS::MultiTouch*>(mInputMgr->createInputObject(OIS::OISMultiTouch, true));
    
    // register self as callback handler for mouse events
    mMouse->setEventCallback(this);
}

void Game::initializeGui()
{
    mTrayMgr = new OgreBites::SdkTrayManager("InterfaceName", mWindow, mMouse, this);
    mTrayMgr->showFrameStats(OgreBites::TL_BOTTOMLEFT);
    mTrayMgr->toggleAdvancedFrameStats();
    //mTrayMgr->showLogo(OgreBites::TL_BOTTOMRIGHT);
    mTrayMgr->hideCursor();
}

void Game::shutdownRenderer()
{
    if (mRoot) {
        // Shutdown Ogre.
        // Deleting mRoot will cascade-delete all object created/managed by Ogre.
        delete mRoot;
        mRoot = NULL;
    }
}

void Game::shutdownInput()
{
    // destroy OIS handlers
    if (mInputMgr) {
        if (mMouse) {
            mInputMgr->destroyInputObject(mMouse);
            mMouse = NULL;
        }
        mInputMgr->destroyInputSystem(mInputMgr);
        mInputMgr = NULL;
    }
}

void Game::shutdownGui()
{
    delete mTrayMgr;
    mTrayMgr = NULL;
}

void Game::initializeResources()
{
    Ogre::String secName, typeName, archName;
	Ogre::ConfigFile cf;
    cf.load(m_ResourcePath + "resources.cfg");
    
	Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
    while (seci.hasMoreElements())
    {
        secName = seci.peekNextKey();
		Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
        Ogre::ConfigFile::SettingsMultiMap::iterator i;
        for (i = settings->begin(); i != settings->end(); ++i)
        {
            typeName = i->first;
            archName = i->second;
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE || defined(OGRE_IS_IOS)
            // OS X does not set the working directory relative to the app,
            // In order to make things portable on OS X we need to provide
            // the loading with it's own bundle path location
            if (!Ogre::StringUtil::startsWith(archName, "/", false)) // only adjust relative dirs
                archName = Ogre::String(m_ResourcePath + archName);
#endif
            Ogre::ResourceGroupManager::getSingleton().addResourceLocation(archName, typeName, secName);
        }
    }
	Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
	Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
}

void Game::createWorld()
{
    // create the world
    mWorld = new World();
    
    // load stuff into the world
    mWorld->load();
    
    // get world camera
    Ogre::Camera* camera = mWorld->getCamera();
    
    // create viewport (entire screen)
    mViewport = mWindow->addViewport(camera);
    mViewport->setBackgroundColour(Ogre::ColourValue(0.4f, 0.6f, 0.9f));  // cornflower blue-ish
    
    // adjust camera aspect ratio to viewport
    camera->setAspectRatio(
                           Ogre::Real(mViewport->getActualWidth()) / Ogre::Real(mViewport->getActualHeight()));
}

void Game::destroyWorld()
{
    delete mWorld;
    mWorld = NULL;
}

bool Game::frameRenderingQueued(const Ogre::FrameEvent& evt)
{
    // Check if we should quit.
    // Returning false will terminate the rendering loop.
    if (mShouldQuit)
        return false;
    
    // update input device states
    mMouse->capture();
    
    // update the world
    mWorld->update(evt.timeSinceLastFrame);

    // update gui
    mTrayMgr->frameRenderingQueued(evt);
    
    return true;
}

void Game::windowResized(Ogre::RenderWindow* rw)
{
    // only react for the main window we created
    if (rw == mWindow) {
        
        // get all cameras
        mWorld->getCamera()->setAspectRatio(
                                       Ogre::Real(mViewport->getActualWidth()) /
                                       Ogre::Real(mViewport->getActualHeight()));
    }
}

void Game::windowClosed(Ogre::RenderWindow* rw)
{
    // only react for the main window we created
    if (rw == mWindow)
        // detach OIS before window shutdown (very important under Linux)
        shutdownInput();
    
    mShouldQuit = true;
}

bool Game::touchMoved(const OIS::MultiTouchEvent &evt)
{
    return true;
}

bool Game::touchPressed(const OIS:: MultiTouchEvent &evt)
{
	return true;
}

bool Game::touchReleased(const OIS:: MultiTouchEvent &evt)
{
	return true;
}

bool Game::touchCancelled(const OIS:: MultiTouchEvent &evt)
{
	return true;
}
World.h

Code: Select all

#ifndef GB_WORLD_H__
#define GB_WORLD_H__
    
#include <OgreCamera.h>
#include <OgreEntity.h>
#include <OgreRoot.h>
#include <OgreSceneManager.h>
    
//
// The World class represents a game level, including terrain
// geometry, objects, lights, cameras, etc.
//
class World {
    Ogre::SceneManager* mSceneMgr;
    Ogre::Camera* mCamera;
    Ogre::Light* mLight;

public:
    World();
    ~World();

    // method that initializes the world
    // - later, we could add functionality for loading worlds from files, etc.
    void load();

    // clear the world
    void unload();

    // call this every frame to update the world and all the objects it contains
    void update(Ogre::Real deltaT);

    //
    // getters and such

    Ogre::Camera* getCamera()
    { return mCamera; }

private:
    // noncopyable
    World(const World&);
    World& operator= (const World&);

    // create simple ground plane
    void createGround();
};
#endif
World.cpp

Code: Select all

#include "World.h"

    World::World()
    {
        mSceneMgr = NULL;
        mCamera = NULL;
        mLight = NULL;
    }

    World::~World()
    {
        unload();
    }

    void World::load()
    {
        // pretend like all this stuff is getting loaded from a file...
        //

        Ogre::Root& ogreRoot = Ogre::Root::getSingleton();

        // create scene manager
        mSceneMgr = ogreRoot.createSceneManager(Ogre::ST_GENERIC);

        // load player ship and attach it to a scene node
        Ogre::Entity* shipEnt = mSceneMgr->createEntity("ogrehead.mesh");
        Ogre::SceneNode* shipNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
        shipNode->attachObject(shipEnt);
        shipNode->setPosition(0, 50, 0);

        // create the ground plane
        createGround();

        // set ambient light
        mSceneMgr->setAmbientLight(Ogre::ColourValue(0.25, 0.25, 0.25));

        // create a light
        mLight = mSceneMgr->createLight();
        mLight->setType(Ogre::Light::LT_DIRECTIONAL);
        mLight->setDirection(Ogre::Vector3(-1, -2, -1).normalisedCopy());
        mLight->setDiffuseColour(1, 1, 1);
        mLight->setSpecularColour(1, 1, 1);

        // create main camera
        mCamera = mSceneMgr->createCamera("PlayerCam");
        mCamera->setNearClipDistance(1);
        mCamera->setPosition(0, 50, 40);
        mCamera->lookAt(shipNode->getPosition());
    }

    void World::unload()
    {
        if (mSceneMgr) {
            // Destroying the scene manager automatically destroys everything
            // created by the scene manager.
            Ogre::Root::getSingleton().destroySceneManager(mSceneMgr);
            mSceneMgr = NULL;
        }
    }

    void World::createGround()
    {
//        // geometric plane definition
//        Ogre::Plane groundPlane(Ogre::Vector3::UNIT_Y, 0);
//
//        // define ground plane parameters
//        Ogre::String meshName = "GroundPlaneMesh";
//        Ogre::Real width = 1000;
//        Ogre::Real height = 1000;
//        int xSegments = 100;
//        int ySegments = 100;
//        Ogre::Real uTile = 10;
//        Ogre::Real vTile = 10;
//
//        // create a ground plane mesh
//        Ogre::MeshManager& meshMgr = Ogre::MeshManager::getSingleton();
//        Ogre::MeshPtr meshPtr = meshMgr.createPlane(
//            meshName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, groundPlane,
//            width, height, xSegments, ySegments, true, 1, uTile, vTile, Ogre::Vector3::UNIT_Z);
//        meshPtr->getSubMesh(0)->setMaterialName("DirtGrass");
//
//        // create an entity from the mesh
//        Ogre::Entity* groundEntity = mSceneMgr->createEntity(meshName);
//
//        // create a scene node and attach the ground entity
//        Ogre::SceneNode* groundNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
//        groundNode->attachObject(groundEntity);
    }

    void World::update(float deltaT)
    {
        // update the world and all the objects in it
        //
    }