├── dejavu.png ├── .gitignore ├── shaderBasedMaterials ├── gorilla2DFP.glsl ├── gorilla3DFP.glsl ├── gorilla2DVP.glsl ├── gorilla2DFP.glsles ├── gorilla3DFP.glsles ├── gorilla3DVP.glsl ├── gorilla2DVP.glsles ├── gorilla3DVP.glsles ├── gorilla2D.hlsl ├── gorilla3D.hlsl ├── Gorilla2D.material └── Gorilla3D.material ├── examples ├── makefile ├── vs2008 │ ├── gorilla.sln │ ├── gorilla_rtt.vcproj │ ├── gorilla_tests.vcproj │ ├── gorilla_playpen.vcproj │ └── gorilla_ogreconsole.vcproj ├── vs2010 │ ├── gorilla.sln │ ├── gorilla_tests.vcxproj │ ├── gorilla_rtt.vcxproj │ ├── gorilla_playpen.vcxproj │ └── gorilla_ogreconsole.vcxproj ├── gorilla_playpen.cpp ├── gorilla_tests.cpp ├── gorilla_ogreconsole.cpp └── gorilla_3d.cpp ├── extensions ├── OgreConsoleForGorilla.h └── OgreConsoleForGorilla.cpp ├── bindings └── luabind │ ├── ward_ptr.h │ └── gorillabind.cpp ├── README.md ├── converters └── bmfontgen_to_gorilla.rb ├── GORILLA_SCHEMA.md ├── dejavu.licence └── dejavu.gorilla /dejavu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/betajaen/gorilla/HEAD/dejavu.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *~ 3 | Ogre.log 4 | console 5 | gorilla3d 6 | playpen 7 | tests 8 | -------------------------------------------------------------------------------- /shaderBasedMaterials/gorilla2DFP.glsl: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec4 oUv; 4 | varying vec4 oColor; 5 | 6 | uniform sampler2D atlas; 7 | 8 | void main() 9 | { 10 | gl_FragColor = texture2D(atlas, oUv.xy) * oColor; 11 | } -------------------------------------------------------------------------------- /shaderBasedMaterials/gorilla3DFP.glsl: -------------------------------------------------------------------------------- 1 | #version 120 2 | 3 | varying vec4 oUv; 4 | varying vec4 oColor; 5 | 6 | uniform sampler2D atlas; 7 | 8 | void main() 9 | { 10 | gl_FragColor = texture2D(atlas, oUv.xy) * oColor; 11 | } -------------------------------------------------------------------------------- /shaderBasedMaterials/gorilla2DVP.glsl: -------------------------------------------------------------------------------- 1 | #version 120 2 | attribute vec4 vertex; 3 | attribute vec4 colour; 4 | attribute vec4 uv0; 5 | 6 | varying vec4 oUv; 7 | varying vec4 oColor; 8 | void main() 9 | { 10 | oUv = uv0; 11 | oColor = colour; 12 | gl_Position = vertex; 13 | } -------------------------------------------------------------------------------- /shaderBasedMaterials/gorilla2DFP.glsles: -------------------------------------------------------------------------------- 1 | #version 100 2 | precision highp float; 3 | precision highp int; 4 | precision lowp sampler2D; 5 | 6 | varying vec4 oUv; 7 | varying vec4 oColor; 8 | 9 | uniform sampler2D atlas; 10 | 11 | void main() 12 | { 13 | gl_FragColor = texture2D(atlas, oUv.xy) * oColor; 14 | } -------------------------------------------------------------------------------- /shaderBasedMaterials/gorilla3DFP.glsles: -------------------------------------------------------------------------------- 1 | #version 100 2 | precision highp float; 3 | precision highp int; 4 | precision lowp sampler2D; 5 | 6 | varying vec4 oUv; 7 | varying vec4 oColor; 8 | 9 | uniform sampler2D atlas; 10 | 11 | void main() 12 | { 13 | gl_FragColor = texture2D(atlas, oUv.xy) * oColor; 14 | } -------------------------------------------------------------------------------- /shaderBasedMaterials/gorilla3DVP.glsl: -------------------------------------------------------------------------------- 1 | #version 120 2 | attribute vec4 vertex; 3 | attribute vec4 colour; 4 | attribute vec4 uv0; 5 | 6 | uniform mat4 worldViewProj; 7 | 8 | varying vec4 oUv; 9 | varying vec4 oColor; 10 | 11 | void main() 12 | { 13 | oUv = uv0; 14 | oColor = colour; 15 | gl_Position = worldViewProj * vertex; 16 | } -------------------------------------------------------------------------------- /shaderBasedMaterials/gorilla2DVP.glsles: -------------------------------------------------------------------------------- 1 | #version 100 2 | precision highp float; 3 | precision highp int; 4 | precision lowp sampler2D; 5 | 6 | attribute vec4 vertex; 7 | attribute vec4 colour; 8 | attribute vec4 uv0; 9 | 10 | varying vec4 oUv; 11 | varying vec4 oColor; 12 | void main() 13 | { 14 | oUv = uv0; 15 | oColor = colour; 16 | gl_Position = vertex; 17 | } -------------------------------------------------------------------------------- /shaderBasedMaterials/gorilla3DVP.glsles: -------------------------------------------------------------------------------- 1 | #version 100 2 | precision highp float; 3 | precision highp int; 4 | precision lowp sampler2D; 5 | 6 | attribute vec4 vertex; 7 | attribute vec4 colour; 8 | attribute vec4 uv0; 9 | 10 | uniform mat4 worldViewProj; 11 | 12 | varying vec4 oUv; 13 | varying vec4 oColor; 14 | 15 | void main() 16 | { 17 | oUv = uv0; 18 | oColor = colour; 19 | gl_Position = worldViewProj * vertex; 20 | } -------------------------------------------------------------------------------- /shaderBasedMaterials/gorilla2D.hlsl: -------------------------------------------------------------------------------- 1 | void main_vp( in float4 position : POSITION, 2 | in float2 uv : TEXCOORD0, 3 | in float4 color : COLOR0, 4 | 5 | out float4 oPosition : POSITION, 6 | out float2 oUv : TEXCOORD0, 7 | out float4 oColor : TEXCOORD1) 8 | { 9 | oPosition = position; 10 | oUv = uv; 11 | oColor = color; 12 | } 13 | 14 | 15 | float4 main_fp(float2 texCoord : TEXCOORD0, 16 | float4 color : TEXCOORD1, 17 | sampler2D atlas : register(s0)) : COLOR 18 | { 19 | return tex2D(atlas, texCoord) * color; 20 | } -------------------------------------------------------------------------------- /shaderBasedMaterials/gorilla3D.hlsl: -------------------------------------------------------------------------------- 1 | void main_vp( in float4 position : POSITION, 2 | in float2 uv : TEXCOORD0, 3 | in float4 color : COLOR0, 4 | uniform float4x4 worldViewProj, 5 | 6 | out float4 oPosition : POSITION, 7 | out float2 oUv : TEXCOORD0, 8 | out float4 oColor : TEXCOORD1) 9 | { 10 | oPosition = mul(worldViewProj, position); 11 | oUv = uv; 12 | oColor = color; 13 | } 14 | 15 | 16 | float4 main_fp(float2 texCoord : TEXCOORD0, 17 | float4 color : TEXCOORD1, 18 | sampler2D atlas : register(s0)) : COLOR 19 | { 20 | return tex2D(atlas, texCoord) * color; 21 | } -------------------------------------------------------------------------------- /examples/makefile: -------------------------------------------------------------------------------- 1 | # Simple GNU make makefile 2 | # 3 | # Run from examples directory. 4 | # 5 | # Comment out / in the settings applicable to your system. 6 | 7 | # Ogre 3d installed from source 8 | OGRE_INCDIR=-I/usr/local/include 9 | OGRE_RENDERER=/usr/local/lib/OGRE/RenderSystem_GL.so 10 | 11 | # Ogre 3d installed from distro package 12 | #OGRE_RENDERER=/usr/lib/OGRE/RenderSystem_GL.so 13 | 14 | # Ogre 3d installed from 64bit distro package 15 | #OGRE_RENDERER=/usr/lib64/OGRE/RenderSystem_GL.so 16 | 17 | LIBS=-lOgreMain -lOIS -lboost_system 18 | CXXFLAGS=-Wall -Wno-unknown-pragmas -g -I.. -I../extensions ${OGRE_INCDIR} -DOGRE_RENDERER="\"${OGRE_RENDERER}\"" 19 | 20 | vpath %.cpp .. 21 | vpath %.cpp ../extensions 22 | 23 | .PHONY: all 24 | all: ../console ../playpen ../gorilla3d ../tests 25 | 26 | ../console: gorilla_ogreconsole.o OgreConsoleForGorilla.o Gorilla.o 27 | ${CXX} $^ ${LIBS} -o $@ 28 | 29 | ../playpen: gorilla_playpen.o Gorilla.o 30 | ${CXX} $^ ${LIBS} -o $@ 31 | 32 | ../gorilla3d: gorilla_3d.o Gorilla.o 33 | ${CXX} $^ ${LIBS} -o $@ 34 | 35 | ../tests: gorilla_tests.o Gorilla.o 36 | ${CXX} $^ ${LIBS} -o $@ 37 | 38 | .PHONY: clean 39 | clean: 40 | -rm *.o 41 | -------------------------------------------------------------------------------- /shaderBasedMaterials/Gorilla2D.material: -------------------------------------------------------------------------------- 1 | vertex_program gorilla2DVPHLSL hlsl 2 | { 3 | source gorilla2D.hlsl 4 | entry_point main_vp 5 | target vs_2_0 6 | } 7 | 8 | fragment_program gorilla2DFPHLSL hlsl 9 | { 10 | source gorilla2D.hlsl 11 | entry_point main_fp 12 | target ps_2_0 13 | } 14 | 15 | vertex_program gorilla2DVPGLSL glsl 16 | { 17 | source gorilla2DVP.glsl 18 | } 19 | 20 | fragment_program gorilla2DFPGLSL glsl 21 | { 22 | source gorilla2DFP.glsl 23 | } 24 | 25 | vertex_program gorilla2DVPGLSLES glsles 26 | { 27 | source gorilla2DVP.glsles 28 | } 29 | 30 | fragment_program gorilla2DFPGLSLES glsles 31 | { 32 | source gorilla2DFP.glsles 33 | } 34 | 35 | // Unified definition 36 | vertex_program gorilla2DVP unified 37 | { 38 | delegate gorilla2DVPGLSLES 39 | delegate gorilla2DVPHLSL 40 | delegate gorilla2DVPGLSL 41 | } 42 | fragment_program gorilla2DFP unified 43 | { 44 | delegate gorilla2DFPGLSLES 45 | delegate gorilla2DFPHLSL 46 | delegate gorilla2DFPGLSL 47 | } 48 | 49 | material Gorilla2D 50 | { 51 | technique 52 | { 53 | pass 54 | { 55 | lighting off 56 | depth_check off 57 | depth_write off 58 | diffuse vertexcolour 59 | ambient vertexcolour 60 | scene_blend alpha_blend 61 | 62 | vertex_program_ref gorilla2DVP 63 | { 64 | } 65 | 66 | fragment_program_ref gorilla2DFP 67 | { 68 | } 69 | 70 | texture_unit 71 | { 72 | texture atlas 73 | filtering none none none 74 | tex_address_mode clamp 75 | } 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /shaderBasedMaterials/Gorilla3D.material: -------------------------------------------------------------------------------- 1 | vertex_program gorilla3DVPHLSL hlsl 2 | { 3 | source gorilla3D.hlsl 4 | entry_point main_vp 5 | target vs_2_0 6 | 7 | default_params 8 | { 9 | param_named_auto worldViewProj WORLDVIEWPROJ_MATRIX 10 | } 11 | } 12 | 13 | fragment_program gorilla3DFPHLSL hlsl 14 | { 15 | source gorilla3D.hlsl 16 | entry_point main_fp 17 | target ps_2_0 18 | } 19 | 20 | vertex_program gorilla3DVPGLSL glsl 21 | { 22 | source gorilla3DVP.glsl 23 | 24 | default_params 25 | { 26 | param_named_auto worldViewProj WORLDVIEWPROJ_MATRIX 27 | } 28 | } 29 | 30 | fragment_program gorilla3DFPGLSL glsl 31 | { 32 | source gorilla3DFP.glsl 33 | } 34 | 35 | vertex_program gorilla3DVPGLSLES glsles 36 | { 37 | source gorilla3DVP.glsles 38 | 39 | default_params 40 | { 41 | param_named_auto worldViewProj WORLDVIEWPROJ_MATRIX 42 | } 43 | } 44 | 45 | fragment_program gorilla3DFPGLSLES glsles 46 | { 47 | source gorilla3DFP.glsles 48 | } 49 | 50 | // Unified definition 51 | vertex_program gorilla3DVP unified 52 | { 53 | delegate gorilla3DVPGLSLES 54 | delegate gorilla3DVPHLSL 55 | delegate gorilla3DVPGLSL 56 | } 57 | fragment_program gorilla3DFP unified 58 | { 59 | delegate gorilla3DFPGLSLES 60 | delegate gorilla3DFPHLSL 61 | delegate gorilla3DFPGLSL 62 | } 63 | 64 | material Gorilla3D 65 | { 66 | technique 67 | { 68 | pass 69 | { 70 | lighting off 71 | depth_check off 72 | depth_write off 73 | diffuse vertexcolour 74 | ambient vertexcolour 75 | scene_blend alpha_blend 76 | 77 | vertex_program_ref gorilla3DVP 78 | { 79 | } 80 | 81 | fragment_program_ref gorilla3DFP 82 | { 83 | } 84 | 85 | texture_unit 86 | { 87 | texture atlas 88 | filtering anisotropic 89 | max_anisotropy 8 90 | tex_address_mode clamp 91 | } 92 | } 93 | } 94 | } -------------------------------------------------------------------------------- /examples/vs2008/gorilla.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 10.00 3 | # Visual Studio 2008 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gorilla_playpen", "gorilla_playpen.vcproj", "{4722520A-274E-4071-9E3F-880C9E4F7928}" 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gorilla_console", "gorilla_ogreconsole.vcproj", "{6DC84147-F5EB-400D-9361-473A4C2CDDCA}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gorilla_3D", "gorilla_rtt.vcproj", "{2B37A960-A0F1-461D-9E9E-387BF151CBBC}" 9 | EndProject 10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gorilla_tests", "gorilla_tests.vcproj", "{389714B7-D63D-4F7C-900B-4C8625980B46}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Win32 = Debug|Win32 15 | Release|Win32 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {4722520A-274E-4071-9E3F-880C9E4F7928}.Debug|Win32.ActiveCfg = Debug|Win32 19 | {4722520A-274E-4071-9E3F-880C9E4F7928}.Debug|Win32.Build.0 = Debug|Win32 20 | {4722520A-274E-4071-9E3F-880C9E4F7928}.Release|Win32.ActiveCfg = Release|Win32 21 | {4722520A-274E-4071-9E3F-880C9E4F7928}.Release|Win32.Build.0 = Release|Win32 22 | {6DC84147-F5EB-400D-9361-473A4C2CDDCA}.Debug|Win32.ActiveCfg = Debug|Win32 23 | {6DC84147-F5EB-400D-9361-473A4C2CDDCA}.Debug|Win32.Build.0 = Debug|Win32 24 | {6DC84147-F5EB-400D-9361-473A4C2CDDCA}.Release|Win32.ActiveCfg = Release|Win32 25 | {6DC84147-F5EB-400D-9361-473A4C2CDDCA}.Release|Win32.Build.0 = Release|Win32 26 | {2B37A960-A0F1-461D-9E9E-387BF151CBBC}.Debug|Win32.ActiveCfg = Debug|Win32 27 | {2B37A960-A0F1-461D-9E9E-387BF151CBBC}.Debug|Win32.Build.0 = Debug|Win32 28 | {2B37A960-A0F1-461D-9E9E-387BF151CBBC}.Release|Win32.ActiveCfg = Release|Win32 29 | {2B37A960-A0F1-461D-9E9E-387BF151CBBC}.Release|Win32.Build.0 = Release|Win32 30 | {389714B7-D63D-4F7C-900B-4C8625980B46}.Debug|Win32.ActiveCfg = Debug|Win32 31 | {389714B7-D63D-4F7C-900B-4C8625980B46}.Debug|Win32.Build.0 = Debug|Win32 32 | {389714B7-D63D-4F7C-900B-4C8625980B46}.Release|Win32.ActiveCfg = Release|Win32 33 | {389714B7-D63D-4F7C-900B-4C8625980B46}.Release|Win32.Build.0 = Release|Win32 34 | EndGlobalSection 35 | GlobalSection(SolutionProperties) = preSolution 36 | HideSolutionNode = FALSE 37 | EndGlobalSection 38 | EndGlobal 39 | -------------------------------------------------------------------------------- /examples/vs2010/gorilla.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gorilla_playpen", "gorilla_playpen.vcxproj", "{4722520A-274E-4071-9E3F-880C9E4F7928}" 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gorilla_console", "gorilla_ogreconsole.vcxproj", "{6DC84147-F5EB-400D-9361-473A4C2CDDCA}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gorilla_3D", "gorilla_rtt.vcxproj", "{2B37A960-A0F1-461D-9E9E-387BF151CBBC}" 9 | EndProject 10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gorilla_tests", "gorilla_tests.vcxproj", "{389714B7-D63D-4F7C-900B-4C8625980B46}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Win32 = Debug|Win32 15 | Release|Win32 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {4722520A-274E-4071-9E3F-880C9E4F7928}.Debug|Win32.ActiveCfg = Debug|Win32 19 | {4722520A-274E-4071-9E3F-880C9E4F7928}.Debug|Win32.Build.0 = Debug|Win32 20 | {4722520A-274E-4071-9E3F-880C9E4F7928}.Release|Win32.ActiveCfg = Release|Win32 21 | {4722520A-274E-4071-9E3F-880C9E4F7928}.Release|Win32.Build.0 = Release|Win32 22 | {6DC84147-F5EB-400D-9361-473A4C2CDDCA}.Debug|Win32.ActiveCfg = Debug|Win32 23 | {6DC84147-F5EB-400D-9361-473A4C2CDDCA}.Debug|Win32.Build.0 = Debug|Win32 24 | {6DC84147-F5EB-400D-9361-473A4C2CDDCA}.Release|Win32.ActiveCfg = Release|Win32 25 | {6DC84147-F5EB-400D-9361-473A4C2CDDCA}.Release|Win32.Build.0 = Release|Win32 26 | {2B37A960-A0F1-461D-9E9E-387BF151CBBC}.Debug|Win32.ActiveCfg = Debug|Win32 27 | {2B37A960-A0F1-461D-9E9E-387BF151CBBC}.Debug|Win32.Build.0 = Debug|Win32 28 | {2B37A960-A0F1-461D-9E9E-387BF151CBBC}.Release|Win32.ActiveCfg = Release|Win32 29 | {2B37A960-A0F1-461D-9E9E-387BF151CBBC}.Release|Win32.Build.0 = Release|Win32 30 | {389714B7-D63D-4F7C-900B-4C8625980B46}.Debug|Win32.ActiveCfg = Debug|Win32 31 | {389714B7-D63D-4F7C-900B-4C8625980B46}.Debug|Win32.Build.0 = Debug|Win32 32 | {389714B7-D63D-4F7C-900B-4C8625980B46}.Release|Win32.ActiveCfg = Release|Win32 33 | {389714B7-D63D-4F7C-900B-4C8625980B46}.Release|Win32.Build.0 = Release|Win32 34 | EndGlobalSection 35 | GlobalSection(SolutionProperties) = preSolution 36 | HideSolutionNode = FALSE 37 | EndGlobalSection 38 | EndGlobal 39 | -------------------------------------------------------------------------------- /extensions/OgreConsoleForGorilla.h: -------------------------------------------------------------------------------- 1 | /* 2 | Description: 3 | 4 | This is a port of the OgreConsole code presented by PixL in the Ogre Forums then later added 5 | to the Ogre Wiki[1]. 6 | 7 | This is a straight port replacing all the Overlay code with Gorilla code, some changes have 8 | been added but they are minor and do not add to the actual functionality of the class. 9 | 10 | Port Author: 11 | 12 | Betajaen. 13 | 14 | Usage: 15 | 16 | 17 | 18 | References: 19 | 20 | [1] http://www.ogre3d.org/tikiwiki/OgreConsole&structure=Cookbook 21 | 22 | */ 23 | 24 | #include "OGRE/Ogre.h" 25 | #include "OIS/OIS.h" 26 | #include "Gorilla.h" 27 | 28 | typedef void (*OgreConsoleFunctionPtr)(Ogre::StringVector&); 29 | 30 | class OgreConsole : public Ogre::Singleton, Ogre::FrameListener, Ogre::LogListener 31 | { 32 | 33 | public: 34 | 35 | OgreConsole(); 36 | 37 | ~OgreConsole(); 38 | 39 | void init(Gorilla::Screen* screen_to_use); 40 | void shutdown(); 41 | 42 | void setVisible(bool mIsVisible); 43 | bool isVisible(){return mIsVisible;} 44 | 45 | void print(const Ogre::String &text); 46 | 47 | virtual bool frameStarted(const Ogre::FrameEvent &evt); 48 | virtual bool frameEnded(const Ogre::FrameEvent &evt); 49 | 50 | void onKeyPressed(const OIS::KeyEvent &arg); 51 | 52 | void addCommand(const Ogre::String &command, OgreConsoleFunctionPtr); 53 | void removeCommand(const Ogre::String &command); 54 | 55 | //log 56 | #if OGRE_VERSION_MINOR < 8 && OGRE_VERSION_MAJOR < 2 57 | void messageLogged( const Ogre::String& message, Ogre::LogMessageLevel lml, bool maskDebug, const Ogre::String &logName ); 58 | #else 59 | // "bool& skip" added in Ogre 1.8 60 | void messageLogged( const Ogre::String& message, Ogre::LogMessageLevel lml, bool maskDebug, const Ogre::String &logName, bool &skip ); 61 | #endif 62 | private: 63 | 64 | void updateConsole(); 65 | void updatePrompt(); 66 | 67 | bool mIsVisible; 68 | bool mIsInitialised; 69 | Gorilla::Screen* mScreen; 70 | Gorilla::Layer* mLayer; 71 | Gorilla::Caption* mPromptText; 72 | Gorilla::MarkupText* mConsoleText; 73 | Gorilla::Rectangle* mDecoration; 74 | Gorilla::GlyphData* mGlyphData; 75 | 76 | bool mUpdateConsole; 77 | bool mUpdatePrompt; 78 | 79 | unsigned int mStartline; 80 | std::list lines; 81 | Ogre::String prompt; 82 | std::map commands; 83 | 84 | 85 | }; 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /bindings/luabind/ward_ptr.h: -------------------------------------------------------------------------------- 1 | /* 2 | ----------------------------------------------------------------------------- 3 | 4 | Copyright (c) 2010 Nigel Atkinson 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | ----------------------------------------------------------------------------- 24 | */ 25 | #include 26 | 27 | /* 28 | * ward_ptr 29 | * 30 | * Similar to a weak reference, holds a pointer to a object. Does not control 31 | * the life time of the object, but can be marked 'invalid', afterwhich any 32 | * attempt to dereference results in an exception. 33 | * 34 | */ 35 | 36 | template 37 | class ward_ptr 38 | { 39 | private: 40 | T** ptr; 41 | int *ref_count; 42 | 43 | public: 44 | ward_ptr() : ptr(NULL) 45 | { 46 | } 47 | ward_ptr( const ward_ptr& p ) 48 | { 49 | ptr = p.ptr; 50 | ref_count = p.ref_count; 51 | (*ref_count)++; 52 | } 53 | ward_ptr( T* p ) 54 | { 55 | ptr = new T*; 56 | ref_count = new int; 57 | *ptr = p; 58 | *ref_count = 1; 59 | } 60 | T* get() const 61 | { 62 | if( ! ptr || ! *ptr ) 63 | throw std::logic_error( "ward_ptr: exception - instance pointer not set." ); 64 | return *ptr; 65 | } 66 | T* operator->() const 67 | { 68 | if( ! ptr || ! *ptr ) 69 | throw std::logic_error( "ward_ptr: exception - instance pointer not set." ); 70 | return *ptr; 71 | } 72 | operator T*() const 73 | { 74 | if( ! ptr || ! *ptr ) 75 | throw std::logic_error( "ward_ptr: exception - instance pointer not set." ); 76 | return *ptr; 77 | } 78 | void invalidate() 79 | { 80 | *ptr = NULL; 81 | } 82 | virtual ~ward_ptr() 83 | { 84 | (*ref_count)--; 85 | if( *ref_count == 0 ) 86 | { 87 | delete ref_count; 88 | delete ptr; 89 | } 90 | } 91 | }; 92 | 93 | template 94 | T* get_pointer( ward_ptr p ) 95 | { 96 | return p.get(); 97 | } 98 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 88 88 88 3 | "" 88 88 4 | 88 88 5 | ,adPPYb,d8 ,adPPYba, 8b,dPPYba, 88 88 88 ,adPPYYba, 6 | a8" `Y88 a8" "8a 88P' "Y8 88 88 88 "" `Y8 7 | 8b 88 8b d8 88 88 88 88 ,adPPPPP88 8 | "8a, ,d88 "8a, ,a8" 88 88 88 88 88, ,88 9 | `"YbbdP"Y8 `"YbbdP"' 88 88 88 88 `"8bbdP"Y8 10 | aa, ,88 11 | "Y8bbdP" 12 | 13 | Software Licence 14 | ---------------- 15 | 16 | Copyright (c) 2010 Robin Southern 17 | 18 | Permission is hereby granted, free of charge, to any person obtaining a copy 19 | of this software and associated documentation files (the "Software"), to deal 20 | in the Software without restriction, including without limitation the rights 21 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 22 | copies of the Software, and to permit persons to whom the Software is 23 | furnished to do so, subject to the following conditions: 24 | 25 | The above copyright notice and this permission notice shall be included in 26 | all copies or substantial portions of the Software. 27 | 28 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 29 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 30 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 31 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 32 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 33 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 34 | THE SOFTWARE. 35 | 36 | What is Gorilla? 37 | ================ 38 | 39 | Gorilla is a C++ based HUD and simple 2D overlay system for the [Ogre3D] graphics 40 | engine, it comes in two files Gorilla.cpp and Gorilla.h 41 | 42 | [Ogre3D]: http://www.ogre3d.org 43 | 44 | Gorilla is intended to substitute the Ogre overlay system, and to provide 45 | a good framework and basis for any Ogre programmer to build their HUD or GUI 46 | system upon. 47 | 48 | Gorilla is designed for speed; It uses Texture Atlases and tries to render 49 | everything in one batch. 50 | 51 | Gorilla can support 52 | 53 | * Filled (Solid, Gradient or Sprite-based) Rectangles (Canvas Rectangles) 54 | * Outlined Rectangles (Canvas Boxes) 55 | * Lines with n-thickness (Canvas Lines) 56 | * Sprites (SpriteLayer Sprites) 57 | * Plain and formatted text (Canvas Captions and Text) 58 | 59 | Gorilla only uses Ogre as a dependency, and is developed with Ogre 1.7 in mind; 60 | but should work with any 1.x version. 61 | 62 | 63 | Using Gorilla 64 | ============= 65 | 66 | All of Gorilla's classes are contained in the `Gorilla` namespace. All classes and member functions use the `camelCase` notation, with the exception that class names the first letter is always captialised. 67 | 68 | To include Gorilla in your project, simply copy the two Gorilla files `Gorilla.cpp` and `Gorilla.h` into your project. Making sure you correctly include and link to Ogre. To increase compliation speed you may want to `#include` Gorilla in your static headers file. 69 | -------------------------------------------------------------------------------- /converters/bmfontgen_to_gorilla.rb: -------------------------------------------------------------------------------- 1 | # 2 | # BMFontGen to Gorilla file generator 3 | # 4 | # Description 5 | # Converts BMFontGen files (xml) into Gorilla files. 6 | # 7 | # Usage 8 | # > bmfontgen_to_gorilla font.xml 9 | 10 | 11 | def make_gorilla(xm, name = nil) 12 | 13 | glyphs = [] 14 | kernings = [] 15 | baseline = 0 16 | spacelength = 0 17 | lineheight = 0 18 | kerning = 0 19 | monowidth = 0 20 | alt_name = "" 21 | texture_name = "texture.png" 22 | range_begin = 65535 23 | range_end = 0 24 | 25 | xm.each_line do |l| 26 | 27 | if l.include? " 30 | 31 | glyph = {} 32 | 33 | c = l.match /code="(\w+)"/ 34 | if (c != nil) 35 | glyph[:id] = c[1].to_i(16) 36 | else 37 | next 38 | end 39 | 40 | origin = l.match /origin="(\d+,\d+)"/ 41 | if (origin != nil) 42 | x, y = origin[1].split(',') 43 | glyph[:x] = x.to_i 44 | glyph[:y] = y.to_i 45 | end 46 | 47 | size = l.match /size="(\d+x\d+)"/ 48 | if (size != nil) 49 | w, h = size[1].split('x') 50 | glyph[:w] = w.to_i 51 | glyph[:h] = h.to_i 52 | monowidth = glyph[:w] if (monowidth < glyph[:w]) 53 | end 54 | 55 | advance = l.match /aw="(\d+)"/ 56 | if (size != nil) 57 | glyph[:advance] = advance[1].to_i 58 | 59 | if (glyph[:id] == 32) 60 | spacelength = advance[1].to_i 61 | next 62 | end 63 | 64 | end 65 | 66 | if (glyph[:id] < range_begin) 67 | range_begin = glyph[:id] 68 | end 69 | 70 | if (glyph[:id] > range_end) 71 | range_end = glyph[:id] 72 | end 73 | 74 | glyphs.push glyph 75 | 76 | next 77 | elsif l.include? " 82 | 83 | lft = l.match /left="(.)"/ 84 | if (lft != nil) 85 | k[:left] = lft[1].to_s.ord 86 | end 87 | 88 | rgt = l.match /right="(.)"/ 89 | if (rgt != nil) 90 | k[:right] = rgt[1].to_s.ord 91 | end 92 | 93 | kn = l.match /adjust="(-?\d+)"/ 94 | if (kn != nil) 95 | k[:adjust] = kn[1].to_i 96 | end 97 | 98 | kernings.push k 99 | 100 | next 101 | end 102 | 103 | # base="18" 104 | bl = l.match /base="(\d+)"/ 105 | if (bl != nil) 106 | baseline = bl[1].to_i 107 | end 108 | 109 | # height="18" 110 | lh = l.match /height="(\d+)"/ 111 | if (lh != nil) 112 | lineheight = lh[1].to_i 113 | end 114 | 115 | # size="14" 116 | sz = l.match /size="(\d+)"/ 117 | if (sz != nil) 118 | alt_name = sz[1] 119 | end 120 | 121 | 122 | # name="d-0.png" 123 | nm = l.match / REQUIRED 28 | 29 | Image file to use. 30 | 31 | ### whitepixel REQUIRED 32 | 33 | Where a white (RGB 255 255 255) pixel is in the image, for best results the surrounding pixels should be white too. 34 | 35 | Section: Font.x 36 | --------------- 37 | 38 | Where "x" is the font index; i.e. `[Font.14]` 39 | 40 | ### lineheight REQUIRED 41 | `lineheight 22` 42 | 43 | Amount of vertical position to move downwards on a new line. 44 | 45 | Height in pixels 46 | 47 | ### spacelength REQUIRED 48 | `spacelength 5` 49 | 50 | Amount of space to move across when a space is needed. 51 | 52 | Width in pixels 53 | 54 | ### baseline REQUIRED 55 | `baseline 18` 56 | Distance from the top where the character "sit's" upon. See http://en.wikipedia.org/wiki/Baseline_%28typography%29 57 | 58 | Height in pixels 59 | 60 | ### letterspacing REQUIRED 61 | `letterspacing -1` 62 | 63 | Amount of horizontal space to move forwards/backwards when a letter is drawn. 64 | 65 | This value is used when no kerning information is found for a character 66 | 67 | Kerning value (in pixels) 68 | 69 | ### monowidth REQUIRED 70 | `monowidth 15` 71 | 72 | Amount of horiziontal space to move fowards when a letter is drawn in monospace mode. 73 | 74 | Value (in pixels) 75 | 76 | ### range 77 | `range 33 126` 78 | 79 | Available glyphs to use, lower is the ascii code for the lowest character available and upper is the highest character available. Typically for a English character set this would be 33 126 80 | 81 | Lowest character 82 | Highest character 83 | 84 | 85 | ### glyph_ (advance) REQUIRED (advance is optional) 86 | `glyph_65 388 0 14 23 13` 87 | 88 | Glyph image in the texture atlas. All glyph images need to have the same height, but width is variable. 89 | 90 | Left position of where the glyph starts 91 | Top position of where the glyph starts 92 | Width of the glyph 93 | Height of the glyph 94 | (advance) Move across this distance when draw (OPTIONAL) 95 | 96 | 97 | ### kerning_ 98 | `kerning_74 45 1` 99 | 100 | Kerning value for when a right character is drawn after a left character. 101 | 102 | ASCII code for the right character 103 | ASCII code for the left character 104 | Kerning value 105 | 106 | ### verticaloffset_ 107 | `verticaloffset_74 10` 108 | 109 | ASCII code for the character 110 | Offset value 111 | 112 | An offset value in pixels to move the character downwards when drawing. This allows you to pack a font 113 | more tightly into the atlas. Characters with space above and a 'decender' can be moved up fit alongside 114 | other characters that do not. For example consider 'g' and 'G' are a similar height - 'g' is just drawn 115 | lower. 116 | 117 | Section: Sprite 118 | --------------- 119 | 120 | ### 121 | `ogrehead 0 464 48 48` 122 | 123 | A single sprite. 124 | 125 | Name of the sprite 126 | Left of the top/left position of the sprite 127 | Top of the top/left position of the sprite 128 | Width of the sprite 129 | height of the sprite 130 | 131 | 132 | -------------------------------------------------------------------------------- /examples/vs2008/gorilla_rtt.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 25 | 28 | 31 | 34 | 37 | 40 | 50 | 53 | 56 | 59 | 66 | 69 | 72 | 75 | 78 | 81 | 84 | 88 | 89 | 97 | 100 | 103 | 106 | 109 | 112 | 122 | 125 | 128 | 131 | 140 | 143 | 146 | 149 | 152 | 155 | 158 | 162 | 163 | 164 | 165 | 166 | 167 | 170 | 171 | 174 | 175 | 178 | 179 | 180 | 181 | 182 | 183 | -------------------------------------------------------------------------------- /examples/vs2008/gorilla_tests.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 25 | 28 | 31 | 34 | 37 | 40 | 50 | 53 | 56 | 59 | 66 | 69 | 72 | 75 | 78 | 81 | 84 | 88 | 89 | 97 | 100 | 103 | 106 | 109 | 112 | 122 | 125 | 128 | 131 | 140 | 143 | 146 | 149 | 152 | 155 | 158 | 162 | 163 | 164 | 165 | 166 | 167 | 170 | 171 | 174 | 175 | 178 | 179 | 180 | 181 | 182 | 183 | -------------------------------------------------------------------------------- /examples/vs2008/gorilla_playpen.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 25 | 28 | 31 | 34 | 37 | 40 | 50 | 53 | 56 | 59 | 67 | 70 | 73 | 76 | 79 | 82 | 85 | 89 | 90 | 98 | 101 | 104 | 107 | 110 | 113 | 123 | 126 | 129 | 132 | 141 | 144 | 147 | 150 | 153 | 156 | 159 | 163 | 164 | 165 | 166 | 167 | 168 | 171 | 172 | 175 | 176 | 179 | 180 | 181 | 182 | 183 | 184 | -------------------------------------------------------------------------------- /dejavu.licence: -------------------------------------------------------------------------------- 1 | Fonts are (c) Bitstream (see below). DejaVu changes are in public domain. 2 | Glyphs imported from Arev fonts are (c) Tavmjong Bah (see below) 3 | 4 | Bitstream Vera Fonts Copyright 5 | ------------------------------ 6 | 7 | Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is 8 | a trademark of Bitstream, Inc. 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of the fonts accompanying this license ("Fonts") and associated 12 | documentation files (the "Font Software"), to reproduce and distribute the 13 | Font Software, including without limitation the rights to use, copy, merge, 14 | publish, distribute, and/or sell copies of the Font Software, and to permit 15 | persons to whom the Font Software is furnished to do so, subject to the 16 | following conditions: 17 | 18 | The above copyright and trademark notices and this permission notice shall 19 | be included in all copies of one or more of the Font Software typefaces. 20 | 21 | The Font Software may be modified, altered, or added to, and in particular 22 | the designs of glyphs or characters in the Fonts may be modified and 23 | additional glyphs or characters may be added to the Fonts, only if the fonts 24 | are renamed to names not containing either the words "Bitstream" or the word 25 | "Vera". 26 | 27 | This License becomes null and void to the extent applicable to Fonts or Font 28 | Software that has been modified and is distributed under the "Bitstream 29 | Vera" names. 30 | 31 | The Font Software may be sold as part of a larger software package but no 32 | copy of one or more of the Font Software typefaces may be sold by itself. 33 | 34 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 35 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, 36 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, 37 | TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME 38 | FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING 39 | ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, 40 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 41 | THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE 42 | FONT SOFTWARE. 43 | 44 | Except as contained in this notice, the names of Gnome, the Gnome 45 | Foundation, and Bitstream Inc., shall not be used in advertising or 46 | otherwise to promote the sale, use or other dealings in this Font Software 47 | without prior written authorization from the Gnome Foundation or Bitstream 48 | Inc., respectively. For further information, contact: fonts at gnome dot 49 | org. 50 | 51 | Arev Fonts Copyright 52 | ------------------------------ 53 | 54 | Copyright (c) 2006 by Tavmjong Bah. All Rights Reserved. 55 | 56 | Permission is hereby granted, free of charge, to any person obtaining 57 | a copy of the fonts accompanying this license ("Fonts") and 58 | associated documentation files (the "Font Software"), to reproduce 59 | and distribute the modifications to the Bitstream Vera Font Software, 60 | including without limitation the rights to use, copy, merge, publish, 61 | distribute, and/or sell copies of the Font Software, and to permit 62 | persons to whom the Font Software is furnished to do so, subject to 63 | the following conditions: 64 | 65 | The above copyright and trademark notices and this permission notice 66 | shall be included in all copies of one or more of the Font Software 67 | typefaces. 68 | 69 | The Font Software may be modified, altered, or added to, and in 70 | particular the designs of glyphs or characters in the Fonts may be 71 | modified and additional glyphs or characters may be added to the 72 | Fonts, only if the fonts are renamed to names not containing either 73 | the words "Tavmjong Bah" or the word "Arev". 74 | 75 | This License becomes null and void to the extent applicable to Fonts 76 | or Font Software that has been modified and is distributed under the 77 | "Tavmjong Bah Arev" names. 78 | 79 | The Font Software may be sold as part of a larger software package but 80 | no copy of one or more of the Font Software typefaces may be sold by 81 | itself. 82 | 83 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 84 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF 85 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 86 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL 87 | TAVMJONG BAH BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 88 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 89 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 90 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM 91 | OTHER DEALINGS IN THE FONT SOFTWARE. 92 | 93 | Except as contained in this notice, the name of Tavmjong Bah shall not 94 | be used in advertising or otherwise to promote the sale, use or other 95 | dealings in this Font Software without prior written authorization 96 | from Tavmjong Bah. For further information, contact: tavmjong @ free 97 | . fr. 98 | 99 | $Id: LICENSE 2133 2007-11-28 02:46:28Z lechimp $ 100 | -------------------------------------------------------------------------------- /examples/vs2008/gorilla_ogreconsole.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 25 | 28 | 31 | 34 | 37 | 40 | 50 | 53 | 56 | 59 | 66 | 69 | 72 | 75 | 78 | 81 | 84 | 88 | 89 | 97 | 100 | 103 | 106 | 109 | 112 | 122 | 125 | 128 | 131 | 140 | 143 | 146 | 149 | 152 | 155 | 158 | 162 | 163 | 164 | 165 | 166 | 167 | 170 | 171 | 174 | 175 | 178 | 179 | 182 | 183 | 186 | 187 | 188 | 189 | 190 | 191 | -------------------------------------------------------------------------------- /examples/vs2010/gorilla_tests.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {389714B7-D63D-4F7C-900B-4C8625980B46} 15 | gorilla_tests 16 | 17 | 18 | 19 | Application 20 | MultiByte 21 | true 22 | 23 | 24 | Application 25 | MultiByte 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | <_ProjectFileVersion>10.0.30319.1 39 | $(SolutionDir)$(Configuration)\ 40 | $(Configuration)\ 41 | $(SolutionDir)$(Configuration)\ 42 | $(Configuration)\ 43 | 44 | 45 | 46 | Disabled 47 | $(OGRE_HOME)/include;$(OGRE_HOME)/boost_1_42;$(SolutionDir)\..\;$(SolutionDir)\..\..\;%(AdditionalIncludeDirectories) 48 | true 49 | EnableFastChecks 50 | MultiThreadedDebugDLL 51 | Level3 52 | EditAndContinue 53 | 54 | 55 | OgreMain_d.lib;OIS_d.lib;%(AdditionalDependencies) 56 | $(OGRE_HOME)/lib/Debug/;$(OGRE_HOME)/boost_1_42/lib/;%(AdditionalLibraryDirectories) 57 | true 58 | MachineX86 59 | 60 | 61 | copy "$(TargetPath)" "$(SolutionDir)\..\.." 62 | 63 | 64 | 65 | 66 | MaxSpeed 67 | true 68 | $(OGRE_HOME)/include;$(OGRE_HOME)/boost_1_42;$(SolutionDir)\..\;$(SolutionDir)\..\..\;%(AdditionalIncludeDirectories) 69 | MultiThreadedDLL 70 | true 71 | Level3 72 | ProgramDatabase 73 | 74 | 75 | OgreMain.lib;OIS.lib;%(AdditionalDependencies) 76 | $(OGRE_HOME)/lib/release/;$(OGRE_HOME)/boost_1_42/lib/;%(AdditionalLibraryDirectories) 77 | true 78 | true 79 | true 80 | MachineX86 81 | 82 | 83 | copy "$(TargetPath)" "$(SolutionDir)\..\.." 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /examples/vs2010/gorilla_rtt.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | gorilla_3D 15 | {2B37A960-A0F1-461D-9E9E-387BF151CBBC} 16 | gorilla_rtt 17 | 18 | 19 | 20 | Application 21 | MultiByte 22 | true 23 | 24 | 25 | Application 26 | MultiByte 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | <_ProjectFileVersion>10.0.30319.1 40 | $(SolutionDir)$(Configuration)\ 41 | $(Configuration)\ 42 | $(SolutionDir)$(Configuration)\ 43 | $(Configuration)\ 44 | 45 | 46 | 47 | Disabled 48 | $(OGRE_HOME)/include;$(OGRE_HOME)/boost_1_42;$(SolutionDir)\..\;$(SolutionDir)\..\..\;%(AdditionalIncludeDirectories) 49 | true 50 | EnableFastChecks 51 | MultiThreadedDebugDLL 52 | Level3 53 | EditAndContinue 54 | 55 | 56 | OgreMain_d.lib;OIS_d.lib;%(AdditionalDependencies) 57 | $(OGRE_HOME)/lib/Debug/;$(OGRE_HOME)/boost_1_42/lib/;%(AdditionalLibraryDirectories) 58 | true 59 | MachineX86 60 | 61 | 62 | copy "$(TargetPath)" "$(SolutionDir)\..\.." 63 | 64 | 65 | 66 | 67 | MaxSpeed 68 | true 69 | $(OGRE_HOME)/include;$(OGRE_HOME)/boost_1_42;$(SolutionDir)\..\;$(SolutionDir)\..\..\;%(AdditionalIncludeDirectories) 70 | MultiThreadedDLL 71 | true 72 | Level3 73 | ProgramDatabase 74 | 75 | 76 | OgreMain.lib;OIS.lib;%(AdditionalDependencies) 77 | $(OGRE_HOME)/lib/release/;$(OGRE_HOME)/boost_1_42/lib/;%(AdditionalLibraryDirectories) 78 | true 79 | true 80 | true 81 | MachineX86 82 | 83 | 84 | copy "$(TargetPath)" "$(SolutionDir)\..\.." 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /examples/vs2010/gorilla_playpen.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {4722520A-274E-4071-9E3F-880C9E4F7928} 15 | gorilla 16 | 17 | 18 | 19 | Application 20 | MultiByte 21 | true 22 | 23 | 24 | Application 25 | MultiByte 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | <_ProjectFileVersion>10.0.30319.1 39 | $(SolutionDir)$(Configuration)\ 40 | $(Configuration)\ 41 | $(SolutionDir)$(Configuration)\ 42 | $(Configuration)\ 43 | 44 | 45 | 46 | Disabled 47 | $(OGRE_HOME)/include;$(OGRE_HOME)/boost_1_42;$(SolutionDir)\..\;$(SolutionDir)\..\..\;%(AdditionalIncludeDirectories) 48 | true 49 | EnableFastChecks 50 | MultiThreadedDebugDLL 51 | Level3 52 | EditAndContinue 53 | 54 | 55 | false 56 | OgreMain_d.lib;OIS_d.lib;%(AdditionalDependencies) 57 | $(OGRE_HOME)/lib/Debug/;$(OGRE_HOME)/boost_1_42/lib/;%(AdditionalLibraryDirectories) 58 | true 59 | MachineX86 60 | 61 | 62 | copy "$(TargetPath)" "$(SolutionDir)\..\.." 63 | 64 | 65 | 66 | 67 | MaxSpeed 68 | true 69 | $(OGRE_HOME)/include;$(OGRE_HOME)/boost_1_42;$(SolutionDir)\..\;$(SolutionDir)\..\..\;%(AdditionalIncludeDirectories) 70 | MultiThreadedDLL 71 | true 72 | Level3 73 | ProgramDatabase 74 | 75 | 76 | OgreMain.lib;OIS.lib;%(AdditionalDependencies) 77 | $(OGRE_HOME)/lib/release/;$(OGRE_HOME)/boost_1_42/lib/;%(AdditionalLibraryDirectories) 78 | true 79 | true 80 | true 81 | MachineX86 82 | 83 | 84 | copy "$(TargetPath)" "$(SolutionDir)\..\.." 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /examples/gorilla_playpen.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "Gorilla.h" 5 | 6 | #include 7 | 8 | #pragma warning ( disable : 4244 ) 9 | 10 | class App : public Ogre::FrameListener, public OIS::KeyListener, public OIS::MouseListener 11 | { 12 | 13 | public: 14 | 15 | Ogre::Real mTimer, mTimer2; 16 | Gorilla::Silverback* mSilverback; 17 | Gorilla::Screen* mScreen; 18 | Gorilla::Layer* mLayer; 19 | 20 | Gorilla::Polygon* poly; 21 | Gorilla::LineList* list; 22 | Gorilla::Caption* caption; 23 | Gorilla::Rectangle* rect; 24 | Gorilla::QuadList* quads; 25 | Gorilla::MarkupText* markup; 26 | 27 | App() : mTimer(0), mTimer2(0), mNextUpdate(0) 28 | { 29 | 30 | _makeOgre(); 31 | _makeOIS(); 32 | 33 | // Create Silverback and load in dejavu 34 | mSilverback = new Gorilla::Silverback(); 35 | mSilverback->loadAtlas("dejavu"); 36 | mScreen = mSilverback->createScreen(mViewport, "dejavu"); 37 | mScreen->setOrientation(Ogre::OR_DEGREE_270); 38 | Ogre::Real vpW = mScreen->getWidth(), vpH = mScreen->getHeight(); 39 | 40 | // Create our drawing layer 41 | mLayer = mScreen->createLayer(0); 42 | rect = mLayer->createRectangle(0,0, vpW, vpH); 43 | rect->background_gradient(Gorilla::Gradient_Diagonal, Gorilla::rgb(98,0,63), Gorilla::rgb(255,180,174)); 44 | 45 | markup = mLayer->createMarkupText(9,5,5, "%@24%A Haiku\n%@14%Written by Betajaen%@9%\nSo many to choose from\nPretty typefaces on Ogre screen\nTime to update Git"); 46 | 47 | caption = mLayer->createCaption(9, vpW - 55, 5, "9"); 48 | caption->width(50); 49 | caption->align(Gorilla::TextAlign_Right); 50 | 51 | caption = mLayer->createCaption(14, vpW - 55, 18, "14"); 52 | caption->width(50); 53 | caption->align(Gorilla::TextAlign_Right); 54 | 55 | caption = mLayer->createCaption(24, vpW - 55, 33, "24"); 56 | caption->width(50); 57 | caption->align(Gorilla::TextAlign_Right); 58 | } 59 | 60 | ~App() 61 | { 62 | std::cout << "\n** Average FPS is " << mWindow->getAverageFPS() << "\n\n"; 63 | delete mSilverback; 64 | delete mRoot; 65 | } 66 | 67 | bool frameStarted(const Ogre::FrameEvent& evt) 68 | { 69 | 70 | if (mWindow->isClosed()) 71 | return false; 72 | 73 | mKeyboard->capture(); 74 | if (mKeyboard->isKeyDown(OIS::KC_ESCAPE)) 75 | return false; 76 | mMouse->capture(); 77 | 78 | return true; 79 | } 80 | 81 | bool keyPressed( const OIS::KeyEvent &e ) 82 | { 83 | return true; 84 | } 85 | 86 | bool keyReleased( const OIS::KeyEvent &e ) 87 | { 88 | return true; 89 | } 90 | 91 | bool mouseMoved( const OIS::MouseEvent &arg ) 92 | { 93 | return true; 94 | } 95 | 96 | bool mousePressed( const OIS::MouseEvent &arg, OIS::MouseButtonID id ) 97 | { 98 | return true; 99 | } 100 | 101 | bool mouseReleased( const OIS::MouseEvent &arg, OIS::MouseButtonID id ) 102 | { 103 | return true; 104 | } 105 | 106 | void _makeOgre() 107 | { 108 | srand(time(0)); 109 | 110 | mRoot = new Ogre::Root("",""); 111 | mRoot->addFrameListener(this); 112 | 113 | #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX 114 | mRoot->loadPlugin(OGRE_RENDERER); 115 | #else 116 | #if 1 117 | #ifdef _DEBUG 118 | mRoot->loadPlugin("RenderSystem_Direct3D9_d"); 119 | #else 120 | mRoot->loadPlugin("RenderSystem_Direct3D9"); 121 | #endif 122 | #else 123 | #ifdef _DEBUG 124 | mRoot->loadPlugin("RenderSystem_GL_d.dll"); 125 | #else 126 | mRoot->loadPlugin("RenderSystem_GL.dll"); 127 | #endif 128 | #endif 129 | #endif 130 | 131 | mRoot->setRenderSystem(mRoot->getAvailableRenderers()[0]); 132 | 133 | Ogre::ResourceGroupManager* rgm = Ogre::ResourceGroupManager::getSingletonPtr(); 134 | rgm->addResourceLocation(".", "FileSystem"); 135 | 136 | mRoot->initialise(false); 137 | 138 | mWindow = mRoot->createRenderWindow("Gorilla", 1024, 768, false); 139 | mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC); 140 | mCamera = mSceneMgr->createCamera("Camera"); 141 | mViewport = mWindow->addViewport(mCamera); 142 | mViewport->setBackgroundColour(Gorilla::webcolour(Gorilla::Colours::FireBrick)); 143 | 144 | rgm->initialiseAllResourceGroups(); 145 | } 146 | 147 | void _makeOIS() 148 | { 149 | // Initialise OIS 150 | OIS::ParamList pl; 151 | size_t windowHnd = 0; 152 | std::ostringstream windowHndStr; 153 | mWindow->getCustomAttribute("WINDOW", &windowHnd); 154 | windowHndStr << windowHnd; 155 | pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str())); 156 | mInputManager = OIS::InputManager::createInputSystem( pl ); 157 | mKeyboard = static_cast(mInputManager->createInputObject(OIS::OISKeyboard, true)); 158 | mKeyboard->setEventCallback(this); 159 | mMouse = static_cast(mInputManager->createInputObject(OIS::OISMouse, true)); 160 | mMouse->setEventCallback(this); 161 | mMouse->getMouseState().width = mViewport->getActualWidth(); 162 | mMouse->getMouseState().height = mViewport->getActualHeight(); 163 | } 164 | 165 | Ogre::Root* mRoot; 166 | Ogre::RenderWindow* mWindow; 167 | Ogre::Viewport* mViewport; 168 | Ogre::SceneManager* mSceneMgr; 169 | Ogre::Camera* mCamera; 170 | Ogre::Real mNextUpdate; 171 | OIS::InputManager* mInputManager; 172 | OIS::Keyboard* mKeyboard; 173 | OIS::Mouse* mMouse; 174 | 175 | }; 176 | 177 | int main() 178 | { 179 | App* app = new App(); 180 | app->mRoot->startRendering(); 181 | delete app; 182 | return 0; 183 | } 184 | 185 | 186 | -------------------------------------------------------------------------------- /examples/vs2010/gorilla_ogreconsole.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | gorilla_console 15 | {6DC84147-F5EB-400D-9361-473A4C2CDDCA} 16 | gorilla_console 17 | 18 | 19 | 20 | Application 21 | MultiByte 22 | true 23 | 24 | 25 | Application 26 | MultiByte 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | <_ProjectFileVersion>10.0.30319.1 40 | $(SolutionDir)$(Configuration)\ 41 | $(Configuration)\ 42 | $(SolutionDir)$(Configuration)\ 43 | $(Configuration)\ 44 | 45 | 46 | 47 | Disabled 48 | $(OGRE_HOME)/include;$(OGRE_HOME)/boost_1_42;$(SolutionDir)\..\;$(SolutionDir)\..\..\;$(SolutionDir)\..\..\extensions\;%(AdditionalIncludeDirectories) 49 | true 50 | EnableFastChecks 51 | MultiThreadedDebugDLL 52 | Level3 53 | EditAndContinue 54 | 55 | 56 | OgreMain_d.lib;OIS_d.lib;%(AdditionalDependencies) 57 | $(OGRE_HOME)/lib/Debug/;$(OGRE_HOME)/boost_1_42/lib/;%(AdditionalLibraryDirectories) 58 | true 59 | MachineX86 60 | 61 | 62 | copy "$(TargetPath)" "$(SolutionDir)\..\.." 63 | 64 | 65 | 66 | 67 | MaxSpeed 68 | true 69 | $(OGRE_HOME)/include;$(OGRE_HOME)/boost_1_42;$(SolutionDir)\..\;$(SolutionDir)\..\..\;$(SolutionDir)\..\..\extensions\;%(AdditionalIncludeDirectories) 70 | MultiThreadedDLL 71 | true 72 | Level3 73 | ProgramDatabase 74 | 75 | 76 | OgreMain.lib;OIS.lib;%(AdditionalDependencies) 77 | $(OGRE_HOME)/lib/release/;$(OGRE_HOME)/boost_1_42/lib/;%(AdditionalLibraryDirectories) 78 | true 79 | true 80 | true 81 | MachineX86 82 | 83 | 84 | copy "$(TargetPath)" "$(SolutionDir)\..\.." 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /examples/gorilla_tests.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "Gorilla.h" 5 | 6 | #include 7 | 8 | #pragma warning ( disable : 4244 ) 9 | 10 | /// UNIT TEST SETUP CODE 11 | class UnitTest{public:UnitTest(Gorilla::Silverback* sb, Ogre::Viewport* vp, Ogre::SceneManager* sm):mSilverback(sb),mViewport(vp), 12 | mSceneMgr(sm){}virtual ~UnitTest(){}virtual bool periodic(Ogre::Real){return true;}Gorilla::Silverback* mSilverback;Ogre::Viewport* mViewport; 13 | Ogre::SceneManager* mSceneMgr;}; 14 | #define BEGIN_TEST(NAME) class NAME :public UnitTest{public:NAME(Gorilla::Silverback* sb, Ogre::Viewport* vp, Ogre::SceneManager* sm):\ 15 | UnitTest(sb,vp,sm){start();}~NAME(){stop();} 16 | #define END_TEST(NAME) }; 17 | #define TEST_START bool start() 18 | #define TEST_STOP bool stop() 19 | #define TEST_PERIODIC bool periodic(Ogre::Real timeElapsed) 20 | #define TEST_CONTINUE return true; 21 | #define TEST_FAIL(DESCRIPTION) std::cout << "\n\n\n---\n"DESCRIPTION << "\n---\n\n\n";return false; 22 | ///////////////////////////////// 23 | 24 | ///////////////////////////////////////////////////////////////////////////////////////// 25 | // Rectangle Tests 26 | ///////////////////////////////////////////////////////////////////////////////////////// 27 | 28 | BEGIN_TEST(RectangleTest) 29 | 30 | Gorilla::Screen* mScreen; 31 | Gorilla::Layer* mLayer; 32 | Gorilla::Rectangle* mRectangle; 33 | 34 | TEST_START 35 | { 36 | mScreen = mSilverback->createScreen(mViewport, "dejavu"); 37 | TEST_CONTINUE 38 | } 39 | 40 | TEST_STOP 41 | { 42 | TEST_CONTINUE 43 | } 44 | 45 | TEST_PERIODIC 46 | { 47 | TEST_CONTINUE 48 | } 49 | 50 | END_TEST(RectangleTest) 51 | 52 | ///////////////////////////////////////////////////////////////////////////////////////// 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | void registerTests(std::map& tests, Gorilla::Silverback* sb, Ogre::Viewport* vp, Ogre::SceneManager* sm) 76 | { 77 | tests[0] = new RectangleTest(sb, vp, sm); 78 | } 79 | 80 | 81 | 82 | 83 | 84 | class App : public Ogre::FrameListener, public OIS::KeyListener, public OIS::MouseListener 85 | { 86 | 87 | public: 88 | 89 | std::map mTests; 90 | UnitTest* mCurrentTest; 91 | Gorilla::Silverback* mSilverback; 92 | 93 | App() : mCurrentTest(0) 94 | { 95 | 96 | _makeOgre(); 97 | _makeOIS(); 98 | 99 | // Create Silverback and load in dejavu 100 | mSilverback = new Gorilla::Silverback(); 101 | mSilverback->loadAtlas("dejavu"); 102 | 103 | registerTests(mTests, mSilverback, mViewport, mSceneMgr); 104 | 105 | } 106 | 107 | ~App() 108 | { 109 | delete mSilverback; 110 | delete mRoot; 111 | } 112 | 113 | void startTest(Ogre::uint index) 114 | { 115 | } 116 | 117 | void stopTest() 118 | { 119 | } 120 | 121 | void updateTest(Ogre::Real) 122 | { 123 | } 124 | 125 | bool frameStarted(const Ogre::FrameEvent& evt) 126 | { 127 | 128 | if (mWindow->isClosed()) 129 | return false; 130 | 131 | mKeyboard->capture(); 132 | if (mKeyboard->isKeyDown(OIS::KC_ESCAPE)) 133 | return false; 134 | mMouse->capture(); 135 | 136 | 137 | return true; 138 | } 139 | 140 | bool keyPressed( const OIS::KeyEvent &e ) 141 | { 142 | return true; 143 | } 144 | 145 | bool keyReleased( const OIS::KeyEvent &e ) 146 | { 147 | return true; 148 | } 149 | 150 | bool mouseMoved( const OIS::MouseEvent &arg ) 151 | { 152 | return true; 153 | } 154 | 155 | bool mousePressed( const OIS::MouseEvent &arg, OIS::MouseButtonID id ) 156 | { 157 | return true; 158 | } 159 | 160 | bool mouseReleased( const OIS::MouseEvent &arg, OIS::MouseButtonID id ) 161 | { 162 | return true; 163 | } 164 | 165 | void _makeOgre() 166 | { 167 | srand(time(0)); 168 | 169 | mRoot = new Ogre::Root("",""); 170 | mRoot->addFrameListener(this); 171 | 172 | #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX 173 | mRoot->loadPlugin(OGRE_RENDERER); 174 | #else 175 | #if 1 176 | #ifdef _DEBUG 177 | mRoot->loadPlugin("RenderSystem_Direct3D9_d"); 178 | #else 179 | mRoot->loadPlugin("RenderSystem_Direct3D9"); 180 | #endif 181 | #else 182 | #ifdef _DEBUG 183 | mRoot->loadPlugin("RenderSystem_GL_d.dll"); 184 | #else 185 | mRoot->loadPlugin("RenderSystem_GL.dll"); 186 | #endif 187 | #endif 188 | #endif 189 | 190 | mRoot->setRenderSystem(mRoot->getAvailableRenderers()[0]); 191 | 192 | Ogre::ResourceGroupManager* rgm = Ogre::ResourceGroupManager::getSingletonPtr(); 193 | rgm->addResourceLocation(".", "FileSystem"); 194 | 195 | mRoot->initialise(false); 196 | 197 | mWindow = mRoot->createRenderWindow("Gorilla - Press 0 to 9 for unit tests. C to Clear.", 1024, 768, false); 198 | mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC); 199 | mCamera = mSceneMgr->createCamera("Camera"); 200 | mViewport = mWindow->addViewport(mCamera); 201 | mViewport->setBackgroundColour(Ogre::ColourValue::Black); 202 | 203 | rgm->initialiseAllResourceGroups(); 204 | } 205 | 206 | void _makeOIS() 207 | { 208 | // Initialise OIS 209 | OIS::ParamList pl; 210 | size_t windowHnd = 0; 211 | std::ostringstream windowHndStr; 212 | mWindow->getCustomAttribute("WINDOW", &windowHnd); 213 | windowHndStr << windowHnd; 214 | pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str())); 215 | mInputManager = OIS::InputManager::createInputSystem( pl ); 216 | mKeyboard = static_cast(mInputManager->createInputObject(OIS::OISKeyboard, true)); 217 | mKeyboard->setEventCallback(this); 218 | mMouse = static_cast(mInputManager->createInputObject(OIS::OISMouse, true)); 219 | mMouse->setEventCallback(this); 220 | mMouse->getMouseState().width = mViewport->getActualWidth(); 221 | mMouse->getMouseState().height = mViewport->getActualHeight(); 222 | } 223 | 224 | Ogre::Root* mRoot; 225 | Ogre::RenderWindow* mWindow; 226 | Ogre::Viewport* mViewport; 227 | Ogre::SceneManager* mSceneMgr; 228 | Ogre::Camera* mCamera; 229 | OIS::InputManager* mInputManager; 230 | OIS::Keyboard* mKeyboard; 231 | OIS::Mouse* mMouse; 232 | 233 | }; 234 | 235 | int main() 236 | { 237 | App* app = new App(); 238 | app->mRoot->startRendering(); 239 | delete app; 240 | 241 | return 0; 242 | } 243 | 244 | 245 | -------------------------------------------------------------------------------- /extensions/OgreConsoleForGorilla.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Description: 3 | 4 | This is a port of the OgreConsole code presented by PixL in the Ogre Forums then later added 5 | to the Ogre Wiki. 6 | 7 | This is a straight port replacing all the Overlay code with Gorilla code, some changes have 8 | been added but they are minor and do not add to the actual functionality of the class. 9 | 10 | 11 | */ 12 | 13 | #include "OgreConsoleForGorilla.h" 14 | 15 | #if OGRE_VERSION < 67584 // 1.8.0 16 | template<> OgreConsole* Ogre::Singleton::ms_Singleton=0; 17 | #else 18 | template<> OgreConsole* Ogre::Singleton::msSingleton=0; 19 | #endif 20 | 21 | #define CONSOLE_FONT_INDEX 14 22 | 23 | #define CONSOLE_LINE_LENGTH 85 24 | #define CONSOLE_LINE_COUNT 15 25 | static const unsigned char legalchars[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890+!\"'#%&/()=?[]\\*-_.:,; "; 26 | 27 | OgreConsole::OgreConsole() 28 | : mIsVisible(true), mIsInitialised(false), mScreen(0), mUpdateConsole(false), mUpdatePrompt(false), mStartline(0) 29 | { 30 | } 31 | 32 | OgreConsole::~OgreConsole() 33 | { 34 | if (mIsInitialised) 35 | shutdown(); 36 | } 37 | 38 | void OgreConsole::init(Gorilla::Screen* screen) 39 | { 40 | 41 | if(mIsInitialised) 42 | shutdown(); 43 | 44 | Ogre::Root::getSingletonPtr()->addFrameListener(this); 45 | Ogre::LogManager::getSingleton().getDefaultLog()->addListener(this); 46 | 47 | // Create gorilla things here. 48 | mScreen = screen; 49 | mLayer = mScreen->createLayer(15); 50 | mGlyphData = mLayer->_getGlyphData(CONSOLE_FONT_INDEX); // Font.CONSOLE_FONT_INDEX 51 | 52 | mConsoleText = mLayer->createMarkupText(CONSOLE_FONT_INDEX, 10,10, Ogre::StringUtil::BLANK); 53 | mConsoleText->width(mScreen->getWidth() - 10); 54 | mPromptText = mLayer->createCaption(CONSOLE_FONT_INDEX, 10,10, "> _"); 55 | mDecoration = mLayer->createRectangle(8,8, mScreen->getWidth() - 16, mGlyphData->mLineHeight ); 56 | mDecoration->background_gradient(Gorilla::Gradient_NorthSouth, Gorilla::rgb(128,128,128,128), Gorilla::rgb(64,64,64,128)); 57 | mDecoration->border(2, Gorilla::rgb(128,128,128,128)); 58 | 59 | mIsInitialised = true; 60 | 61 | print("%5Ogre%R%6Console%0 Activated. Press F1 to show/hide.%R"); 62 | } 63 | 64 | void OgreConsole::shutdown() 65 | { 66 | if(!mIsInitialised) 67 | return; 68 | 69 | mIsInitialised = false; 70 | 71 | Ogre::Root::getSingletonPtr()->removeFrameListener(this); 72 | Ogre::LogManager::getSingleton().getDefaultLog()->removeListener(this); 73 | 74 | mScreen->destroy(mLayer); 75 | 76 | } 77 | 78 | 79 | void OgreConsole::onKeyPressed(const OIS::KeyEvent &arg) 80 | { 81 | 82 | if(!mIsVisible) 83 | return; 84 | 85 | if (arg.key == OIS::KC_RETURN || arg.key == OIS::KC_NUMPADENTER) 86 | { 87 | 88 | print("%3> " + prompt + "%R"); 89 | 90 | //split the parameter list 91 | Ogre::StringVector params = Ogre::StringUtil::split(prompt, " "); 92 | 93 | if (params.size()) 94 | { 95 | std::map::iterator i; 96 | for(i=commands.begin();i!=commands.end();i++){ 97 | if((*i).first==params[0]){ 98 | if((*i).second) 99 | (*i).second(params); 100 | break; 101 | } 102 | } 103 | prompt.clear(); 104 | mUpdateConsole = true; 105 | mUpdatePrompt = true; 106 | } 107 | } 108 | 109 | else if (arg.key == OIS::KC_BACK) 110 | { 111 | if (prompt.size()) 112 | { 113 | prompt.erase(prompt.end() - 1); //=prompt.substr(0,prompt.length()-1); 114 | mUpdatePrompt = true; 115 | } 116 | } 117 | else if (arg.key == OIS::KC_PGUP) 118 | { 119 | if(mStartline>0) 120 | mStartline--; 121 | mUpdateConsole = true; 122 | } 123 | 124 | else if (arg.key == OIS::KC_PGDOWN) 125 | { 126 | if(mStartline::iterator i,start,end; 162 | 163 | //make sure is in range 164 | if(mStartline>lines.size()) 165 | mStartline=lines.size(); 166 | 167 | int lcount=0; 168 | start=lines.begin(); 169 | for(unsigned int c=0;ctext(text.str()); 184 | 185 | // Move prompt downwards. 186 | mPromptText->top(10 + (lcount * mGlyphData->mLineHeight)); 187 | 188 | // Change background height so it covers the text and prompt 189 | mDecoration->height(((lcount+1) * mGlyphData->mLineHeight) + 4); 190 | 191 | mConsoleText->width(mScreen->getWidth() - 20); 192 | mDecoration->width(mScreen->getWidth() - 16); 193 | mPromptText->width(mScreen->getWidth() - 20); 194 | 195 | } 196 | 197 | void OgreConsole::updatePrompt() 198 | { 199 | mUpdatePrompt = false; 200 | std::stringstream text; 201 | text << "> " << prompt << "_"; 202 | mPromptText->text(text.str()); 203 | } 204 | 205 | void OgreConsole::print(const Ogre::String &text) 206 | { 207 | //subdivide it into lines 208 | const char *str=text.c_str(); 209 | int len=text.length(); 210 | Ogre::String line; 211 | for(int c=0;c=CONSOLE_LINE_LENGTH){ 213 | lines.push_back(line); 214 | line=""; 215 | } 216 | if(str[c]!='\n') 217 | line+=str[c]; 218 | } 219 | if(line.length()) 220 | lines.push_back(line); 221 | if(lines.size()>CONSOLE_LINE_COUNT) 222 | mStartline=lines.size()-CONSOLE_LINE_COUNT; 223 | else 224 | mStartline=0; 225 | mUpdateConsole=true; 226 | } 227 | 228 | bool OgreConsole::frameEnded(const Ogre::FrameEvent &evt) 229 | { 230 | return true; 231 | } 232 | 233 | void OgreConsole::setVisible(bool isVisible) 234 | { 235 | mIsVisible = isVisible; 236 | mLayer->setVisible(mIsVisible); 237 | } 238 | 239 | void OgreConsole::addCommand(const Ogre::String &command, OgreConsoleFunctionPtr func) 240 | { 241 | commands[command]=func; 242 | } 243 | 244 | void OgreConsole::removeCommand(const Ogre::String &command) 245 | { 246 | commands.erase(commands.find(command)); 247 | } 248 | 249 | #if OGRE_VERSION_MINOR < 8 && OGRE_VERSION_MAJOR < 2 250 | void OgreConsole::messageLogged( const Ogre::String& message, Ogre::LogMessageLevel lml, bool maskDebug, const Ogre::String &logName ) 251 | #else 252 | // "bool& skip" added in Ogre 1.8 253 | void OgreConsole::messageLogged( const Ogre::String& message, Ogre::LogMessageLevel lml, bool maskDebug, const Ogre::String &logName, bool &skip ) 254 | #endif 255 | { 256 | print(message); 257 | } 258 | -------------------------------------------------------------------------------- /examples/gorilla_ogreconsole.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "Gorilla.h" 5 | #include "OgreConsoleForGorilla.h" 6 | 7 | #include 8 | 9 | #pragma warning ( disable : 4244 ) 10 | 11 | bool quitApp = false; 12 | 13 | void whoami(Ogre::StringVector&) 14 | { 15 | OgreConsole::getSingleton().print("You're you!"); 16 | } 17 | 18 | void version(Ogre::StringVector&) 19 | { 20 | std::stringstream s; 21 | s << "Ogre " << OGRE_VERSION_MAJOR << "." << OGRE_VERSION_MINOR << "." << OGRE_VERSION_PATCH << " '" << OGRE_VERSION_NAME << "'"; 22 | OgreConsole::getSingleton().print(s.str()); 23 | } 24 | 25 | void make(Ogre::StringVector& vec) 26 | { 27 | if (vec.size() == 1) 28 | OgreConsole::getSingleton().print("Make you what?"); 29 | else 30 | { 31 | Ogre::String item_to_make = vec[1]; 32 | Ogre::StringUtil::toLowerCase(item_to_make); 33 | if (item_to_make == "sandwich") 34 | OgreConsole::getSingleton().print("Make it yourself!"); 35 | else if (item_to_make == "universe") 36 | OgreConsole::getSingleton().print("Boom!"); 37 | else if (item_to_make == "ogre") 38 | OgreConsole::getSingleton().print("I need a Daddy and Mommy Ogre"); 39 | else if (item_to_make == "gorilla") 40 | OgreConsole::getSingleton().print("He wouldn't like that"); 41 | else 42 | OgreConsole::getSingleton().print("Go check your fridge."); 43 | } 44 | } 45 | 46 | void sudo(Ogre::StringVector& vec) 47 | { 48 | // See http://xkcd.com/149/ for the design specs of this function. 49 | if( vec.size() == 3 ) 50 | { 51 | Ogre::String make = vec[1]; 52 | Ogre::String item_to_make = vec[2]; 53 | Ogre::StringUtil::toLowerCase(make); 54 | Ogre::StringUtil::toLowerCase(item_to_make); 55 | if( make == "make" && item_to_make == "sandwich") 56 | { 57 | OgreConsole::getSingleton().print("Oh, ok then . . . . . . argh! The Ogre ate it! Honest!"); 58 | return; 59 | } 60 | } 61 | OgreConsole::getSingleton().print("Go check everyones fridge."); 62 | } 63 | 64 | void quit(Ogre::StringVector&) 65 | { 66 | quitApp = true; 67 | } 68 | 69 | class App : public Ogre::FrameListener, public OIS::KeyListener, public OIS::MouseListener 70 | { 71 | 72 | public: 73 | 74 | Gorilla::Silverback* mGorilla; 75 | Gorilla::Screen* mScreen; 76 | OgreConsole* mConsole; 77 | 78 | Gorilla::Layer* mFPSLayer; 79 | Gorilla::Caption* mFPS; 80 | Ogre::Real mTimer; 81 | 82 | App() : mTimer(0), mNextUpdate(0) 83 | { 84 | 85 | _makeOgre(); 86 | _makeOIS(); 87 | _makeScene(); 88 | 89 | // Initialise Gorilla 90 | mGorilla = new Gorilla::Silverback(); 91 | mGorilla->loadAtlas("dejavu"); 92 | mScreen = mGorilla->createScreen(mViewport, "dejavu"); 93 | 94 | mFPSLayer = mScreen->createLayer(14); 95 | mFPS = mFPSLayer->createCaption(14, 10,10, Ogre::StringUtil::BLANK); 96 | 97 | mConsole = new OgreConsole(); 98 | mConsole->init(mScreen); 99 | mConsole->addCommand("whoami", whoami); 100 | mConsole->addCommand("version", version); 101 | mConsole->addCommand("sudo", sudo); 102 | mConsole->addCommand("make", make); 103 | mConsole->addCommand("quit", quit); 104 | } 105 | 106 | ~App() 107 | { 108 | delete mGorilla; 109 | delete mRoot; 110 | } 111 | 112 | bool frameStarted(const Ogre::FrameEvent& evt) 113 | { 114 | 115 | if (mWindow->isClosed() || quitApp) 116 | return false; 117 | 118 | mKeyboard->capture(); 119 | if (mKeyboard->isKeyDown(OIS::KC_ESCAPE)) 120 | return false; 121 | mMouse->capture(); 122 | 123 | mTimer += evt.timeSinceLastFrame; 124 | if (mTimer > 1.0f / 60.0f) 125 | { 126 | mTimer = 0; 127 | std::stringstream s; 128 | s << "FPS: " << mWindow->getLastFPS() << ", Batches: " << mRoot->getRenderSystem()->_getBatchCount() << "\n"; 129 | mFPS->top(mViewport->getActualHeight() - 25); 130 | mFPS->text(s.str()); 131 | 132 | } 133 | return true; 134 | } 135 | 136 | bool keyPressed( const OIS::KeyEvent &e ) 137 | { 138 | mConsole->onKeyPressed(e); 139 | return true; 140 | } 141 | 142 | bool keyReleased( const OIS::KeyEvent &e ) 143 | { 144 | if (e.key == OIS::KC_F1) 145 | { 146 | mConsole->setVisible(!mConsole->isVisible()); 147 | return true; 148 | } 149 | return true; 150 | } 151 | 152 | bool mouseMoved( const OIS::MouseEvent &arg ) 153 | { 154 | return true; 155 | } 156 | 157 | bool mousePressed( const OIS::MouseEvent &arg, OIS::MouseButtonID id ) 158 | { 159 | return true; 160 | } 161 | 162 | bool mouseReleased( const OIS::MouseEvent &arg, OIS::MouseButtonID id ) 163 | { 164 | return true; 165 | } 166 | 167 | void _makeOgre() 168 | { 169 | srand(time(0)); 170 | 171 | mRoot = new Ogre::Root("",""); 172 | mRoot->addFrameListener(this); 173 | #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX 174 | mRoot->loadPlugin(OGRE_RENDERER); 175 | #else 176 | #ifdef _DEBUG 177 | mRoot->loadPlugin("RenderSystem_Direct3D9_d"); 178 | #else 179 | mRoot->loadPlugin("RenderSystem_Direct3D9"); 180 | #endif 181 | #endif 182 | 183 | mRoot->setRenderSystem(mRoot->getAvailableRenderers()[0]); 184 | 185 | Ogre::ResourceGroupManager* rgm = Ogre::ResourceGroupManager::getSingletonPtr(); 186 | rgm->addResourceLocation(".", "FileSystem"); 187 | 188 | mRoot->initialise(false); 189 | 190 | mWindow = mRoot->createRenderWindow("Gorilla", 1024, 768, false); 191 | mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC); 192 | mCamera = mSceneMgr->createCamera("Camera"); 193 | mSceneMgr->setAmbientLight(Ogre::ColourValue(1.0f, 1.0f, 1.0f)); 194 | mViewport = mWindow->addViewport(mCamera); 195 | mViewport->setBackgroundColour(Gorilla::rgb(13, 13, 13)); 196 | 197 | rgm->initialiseAllResourceGroups(); 198 | } 199 | 200 | void _makeOIS() 201 | { 202 | // Initialise OIS 203 | OIS::ParamList pl; 204 | size_t windowHnd = 0; 205 | std::ostringstream windowHndStr; 206 | mWindow->getCustomAttribute("WINDOW", &windowHnd); 207 | windowHndStr << windowHnd; 208 | pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str())); 209 | mInputManager = OIS::InputManager::createInputSystem( pl ); 210 | mKeyboard = static_cast(mInputManager->createInputObject(OIS::OISKeyboard, true)); 211 | mKeyboard->setEventCallback(this); 212 | mMouse = static_cast(mInputManager->createInputObject(OIS::OISMouse, true)); 213 | mMouse->setEventCallback(this); 214 | mMouse->getMouseState().width = mViewport->getActualWidth(); 215 | mMouse->getMouseState().height = mViewport->getActualHeight(); 216 | } 217 | 218 | void _makeScene() 219 | { 220 | mCamera->setNearClipDistance(1); 221 | mCamera->setFarClipDistance(1000); 222 | // Create the texture 223 | Ogre::TexturePtr texture = Ogre::TextureManager::getSingleton().createManual( 224 | "DynamicTexture", // name 225 | Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, 226 | Ogre::TEX_TYPE_2D, // type 227 | 128, 128, // width & height 228 | 0, // number of mipmaps 229 | Ogre::PF_BYTE_BGRA, // pixel format 230 | Ogre::TU_DEFAULT); // usage; should be TU_DYNAMIC_WRITE_ONLY_DISCARDABLE for 231 | // textures updated very often (e.g. each frame) 232 | 233 | // Get the pixel buffer 234 | Ogre::HardwarePixelBufferSharedPtr pixelBuffer = texture->getBuffer(); 235 | 236 | // Lock the pixel buffer and get a pixel box 237 | pixelBuffer->lock(Ogre::HardwareBuffer::HBL_NORMAL); // for best performance use HBL_DISCARD! 238 | const Ogre::PixelBox& pixelBox = pixelBuffer->getCurrentLock(); 239 | 240 | Ogre::uint8* pDest = static_cast(pixelBox.data); 241 | 242 | // Fill in some pixel data. This will give a semi-transparent blue, 243 | // but this is of course dependent on the chosen pixel format. 244 | for (size_t j = 0; j < 128; j++) 245 | for(size_t i = 0; i < 128; i++) 246 | { 247 | *pDest++ = 82 + (Ogre::Math::Sin(i) + Ogre::Math::Cos(j) * 10.5); 248 | *pDest++ = 45 + (Ogre::Math::Cos(i) + Ogre::Math::Sin(j) * 10.5); 249 | *pDest++ = 128 + (Ogre::Math::Tan(i) + Ogre::Math::Cos(j) * 10.5); 250 | *pDest++ = 255; // A 251 | } 252 | 253 | // Unlock the pixel buffer 254 | pixelBuffer->unlock(); 255 | 256 | // Create a material using the texture 257 | Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create( 258 | "DynamicTextureMaterial", // name 259 | Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); 260 | 261 | Ogre::TextureUnitState* tus = material->getTechnique(0)->getPass(0)->createTextureUnitState("DynamicTexture"); 262 | tus->setScrollAnimation(0.005f, 0.0025f); 263 | tus->setRotateAnimation(0.009f); 264 | material->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA); 265 | 266 | Ogre::Plane plane(Ogre::Vector3::UNIT_Y, 0); 267 | 268 | Ogre::MeshManager::getSingleton().createPlane("ground", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, 269 | plane, 1500, 1500, 1, 1, true, 1, 1, 1, Ogre::Vector3::UNIT_Z); 270 | 271 | Ogre::Entity* entGround = mSceneMgr->createEntity("GroundEntity", "ground"); 272 | mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(entGround); 273 | 274 | entGround->setMaterialName("DynamicTextureMaterial"); 275 | entGround->setCastShadows(false); 276 | 277 | mCamera->setPosition(25,100,30); 278 | mCamera->lookAt(0,0,0); 279 | } 280 | 281 | Ogre::Root* mRoot; 282 | Ogre::RenderWindow* mWindow; 283 | Ogre::Viewport* mViewport; 284 | Ogre::SceneManager* mSceneMgr; 285 | Ogre::Camera* mCamera; 286 | Ogre::Real mNextUpdate; 287 | OIS::InputManager* mInputManager; 288 | OIS::Keyboard* mKeyboard; 289 | OIS::Mouse* mMouse; 290 | 291 | 292 | }; 293 | 294 | int main() 295 | { 296 | App* app = new App(); 297 | app->mRoot->startRendering(); 298 | delete app; 299 | 300 | return 0; 301 | } 302 | 303 | 304 | -------------------------------------------------------------------------------- /bindings/luabind/gorillabind.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ----------------------------------------------------------------------------- 3 | Copyright (c) 2010 Nigel Atkinson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | ----------------------------------------------------------------------------- 23 | */ 24 | 25 | // Known to compile under MSVC10 and GCC4 26 | 27 | #include "Gorilla.h" 28 | #include 29 | #include "ward_ptr.h" 30 | 31 | using namespace luabind; 32 | using namespace Gorilla; 33 | using Ogre::Real; 34 | using Ogre::Vector2; 35 | using Ogre::ColourValue; 36 | using Ogre::String; 37 | using Ogre::MovableObject; 38 | 39 | // Dummy class to hold enums. 40 | class dummy {}; 41 | 42 | // Why the ward pointers? They stop program crashes should you accidently 43 | // access a object after you have destroyed it. With them you get an exception 44 | // that gets translated by Luabind into a Lua error. Handy when you have an 45 | // in game Lua console. 46 | // Glue create and destroy functions, to allow the use of ward pointers. 47 | 48 | ward_ptr createRectangle( Layer *layer, Real x, Real y, Real width, Real height ) 49 | { 50 | return ward_ptr( layer->createRectangle( x, y, width, height ) ); 51 | } 52 | 53 | ward_ptr createRectangle( Layer *layer, const Vector2& a, const Vector2& b ) 54 | { 55 | return layer->createRectangle( a, b ); 56 | } 57 | 58 | void destroyRectangle( Layer *layer, ward_ptr ptr ) 59 | { 60 | layer->destroyRectangle( ptr.get() ); 61 | ptr.invalidate(); 62 | } 63 | 64 | ward_ptr createCaption( Layer* layer, Ogre::uint index, Real x, Real y, const Ogre::String& text ) 65 | { 66 | return layer->createCaption( index, x, y, text ); 67 | } 68 | 69 | void destroyCaption( Layer *layer, ward_ptr ptr ) 70 | { 71 | layer->destroyCaption( ptr.get() ); 72 | ptr.invalidate(); 73 | } 74 | 75 | ward_ptr createMarkupText( Layer *layer, Ogre::uint index, Real x, Real y, const Ogre::String& text ) 76 | { 77 | return layer->createMarkupText( index, x, y, text ); 78 | } 79 | 80 | void destroyMarkupText( Layer *layer, ward_ptr ptr ) 81 | { 82 | layer->destroyMarkupText( ptr.get() ); 83 | ptr.invalidate(); 84 | } 85 | 86 | // The big binding! 87 | 88 | void bindGorilla( lua_State *L ) 89 | { 90 | module(L) 91 | [ 92 | // Bind everything within the "Gorilla" scope. 93 | namespace_( "Gorilla" ) 94 | [ 95 | class_( "Gradient" ) 96 | .enum_( "" ) 97 | [ 98 | value( "NorthSouth", Gradient_NorthSouth ), 99 | value( "WestEast", Gradient_WestEast ), 100 | value( "Diagonal", Gradient_Diagonal ) 101 | ], 102 | class_( "Border" ) 103 | .enum_( "" ) 104 | [ 105 | value( "North", Border_North ), 106 | value( "South", Border_South ), 107 | value( "East", Border_East ), 108 | value( "West", Border_West ) 109 | ], 110 | class_( "QuadCorner" ) 111 | .enum_( "" ) 112 | [ 113 | value( "TopLeft", TopLeft ), 114 | value( "TopRight", TopRight ), 115 | value( "BottomRight", BottomRight ), 116 | value( "BottomLeft", BottomLeft ) 117 | ], 118 | class_( "TextAlignment" ) 119 | .enum_( "" ) 120 | [ 121 | value( "Left", TextAlign_Left ), 122 | value( "Right", TextAlign_Right ), 123 | value( "Centre", TextAlign_Centre ) 124 | ], 125 | class_( "VerticalAlignment" ) 126 | .enum_( "" ) 127 | [ 128 | value( "Top", VerticalAlign_Top ), 129 | value( "Middle", VerticalAlign_Middle ), 130 | value( "Bottom", VerticalAlign_Bottom ) 131 | ], 132 | class_( "Silverback" ) 133 | // Singleton so no constructor, but a (static) getSingletonPtr instead. 134 | .scope 135 | [ 136 | def( "getSingleton", &Silverback::getSingletonPtr ) 137 | ] 138 | .def( "loadAtlas", &Silverback::loadAtlas ) 139 | .def( "createScreen", &Silverback::createScreen ) 140 | .def( "destroyScreen", &Silverback::destroyScreen ) 141 | .def( "createScreenRenderable", &Silverback::createScreenRenderable ) 142 | .def( "destroyScreenRenderable", &Silverback::destroyScreenRenderable ), 143 | class_( "Screen" ) 144 | .def( "createLayer", &Screen::createLayer ) 145 | .def( "destroy", &Screen::destroy ) 146 | .def_readonly( "width", (float (Screen::*)())&Screen::getWidth ) 147 | .def_readonly( "height", (float (Screen::*)())&Screen::getHeight ), 148 | class_( "ScreenRenderable" ) 149 | .def( "createLayer", &ScreenRenderable::createLayer ) 150 | .def( "destroy", &ScreenRenderable::destroy ) 151 | .def( "getBoundingRadius", &ScreenRenderable::getBoundingRadius ) 152 | .def( "getSquaredViewDepth", &ScreenRenderable::getSquaredViewDepth ), 153 | class_( "Layer" ) 154 | .property( "visible", &Layer::isVisible, &Layer::setVisible ) 155 | .def( "show", &Layer::show ) 156 | .def( "hide", &Layer::hide ) 157 | .property( "alphaModifier", &Layer::getAlphaModifier, &Layer::setAlphaModifier ) 158 | .def( "createRectangle", 159 | (ward_ptr(*)(Layer*, Real, Real, Real, Real))&createRectangle ) 160 | .def( "createRectangle", 161 | (ward_ptr(*)(Layer*, const Vector2&, const Vector2&))&createRectangle ) 162 | .def( "destroyRectangle", &destroyRectangle ) 163 | // getRectangels - will need some sort of converter 164 | .def( "createCaption", createCaption ) 165 | .def( "destroyCaption", destroyCaption ) 166 | // getCaptions 167 | .def( "createMarkupText", createMarkupText ) 168 | .def( "destroyMarkupText", destroyMarkupText ) 169 | // getMarkupTexts 170 | , 171 | class_( "Rectangle" ) 172 | .def( "intersects", &Rectangle::intersects ) 173 | .def( "position", (Vector2 (Rectangle::*)() const )&Rectangle::position ) 174 | .def( "position", (void (Rectangle::*)( const Real&, const Real& ))&Rectangle::position ) 175 | .def( "position", (void (Rectangle::*)( const Vector2& ))&Rectangle::position ) 176 | .property( "left", 177 | (Real (Rectangle::*)() const )&Rectangle::left, 178 | (void (Rectangle::*)( const Real& ))&Rectangle::left ) 179 | .property( "top", 180 | (Real (Rectangle::*)() const )&Rectangle::top, 181 | (void (Rectangle::*)( const Real& ))&Rectangle::top ) 182 | .property( "width", 183 | (Real (Rectangle::*)() const )&Rectangle::width, 184 | (void (Rectangle::*)( const Real& ))&Rectangle::width ) 185 | .property( "height", 186 | (Real (Rectangle::*)() const )&Rectangle::height, 187 | (void (Rectangle::*)( const Real& ))&Rectangle::height ) 188 | .def( "noBackground", &Rectangle::no_background ) 189 | .def( "noBorder", &Rectangle::no_border ) 190 | .def( "backgroundColour", 191 | (ColourValue (Rectangle::*)( QuadCorner ) const )&Gorilla::Rectangle::background_colour ) 192 | .def( "backgroundColour", 193 | (void (Rectangle::*)( const ColourValue& ))&Rectangle::background_colour ) 194 | .def( "backgroundColour", 195 | (void (Rectangle::*)( QuadCorner, const ColourValue& ))&Rectangle::background_colour ) 196 | .def( "backgroundGradient", &Rectangle::background_gradient ) 197 | .def( "backgroundImage", 198 | (void (Rectangle::*)( const String& ))&Rectangle::background_image ) 199 | .def( "borderColour", 200 | (ColourValue (Rectangle::*)( Border ) const )&Rectangle::border_colour ) 201 | .def( "borderColour", 202 | (void (Rectangle::*)( const ColourValue& ))&Rectangle::border_colour ) 203 | .def( "borderColour", 204 | (void (Rectangle::*)( Border, const ColourValue& ))&Rectangle::border_colour ) 205 | .property( "borderWidth", 206 | (Real (Rectangle::*)() const )&Rectangle::border_width, 207 | (void (Rectangle::*)( Real ))&Rectangle::border_width ) 208 | .def( "border", 209 | (void (Rectangle::*)( Real, const ColourValue& ))&Rectangle::border ) 210 | .def( "border", 211 | (void (Rectangle::*)( Real, const ColourValue&, const ColourValue&, 212 | const ColourValue&, const ColourValue& )) 213 | &Rectangle::border ) 214 | , 215 | class_( "Caption" ) 216 | .def( "intersects", &Caption::intersects ) 217 | .property( "left", 218 | (Real (Caption::*)() const)&Caption::left, 219 | (void (Caption::*)( const Real& ))&Caption::left ) 220 | .property( "top", 221 | (Real (Caption::*)() const)&Caption::top, 222 | (void (Caption::*)( const Real& ))&Caption::top ) 223 | .property( "width", 224 | (Real (Caption::*)() const)&Caption::width, 225 | (void (Caption::*)( const Real& ))&Caption::width ) 226 | .property( "height", 227 | (Real (Caption::*)() const)&Caption::height, 228 | (void (Caption::*)( const Real& ))&Caption::height ) 229 | .def( "size", &Caption::size ) 230 | .property( "text", 231 | (String (Caption::*)() const)&Caption::text, 232 | (void (Caption::*)( const String& ))&Caption::text ) 233 | .property( "align", 234 | (TextAlignment (Caption::*)() const )&Caption::align, 235 | (void (Caption::*)( const TextAlignment& ))&Caption::align ) 236 | .property( "verticalAlign", 237 | (VerticalAlignment (Caption::*)() const )&Caption::vertical_align, 238 | (void (Caption::*)( const VerticalAlignment& ))&Caption::vertical_align ) 239 | .property( "colour", 240 | (ColourValue (Caption::*)() const )&Caption::colour, 241 | (void (Caption::*)( const ColourValue& ))&Caption::colour ) 242 | .property( "background", 243 | (ColourValue (Caption::*)() const )&Caption::background, 244 | (void (Caption::*)( const ColourValue& ))&Caption::background ) 245 | .def( "noBackground", &Caption::no_background ) 246 | , 247 | class_( "MarkupText" ) 248 | .property( "maxTextWidth", &MarkupText::maxTextWidth ) 249 | .property( "left", 250 | (Real (MarkupText::*)() const)&MarkupText::left, 251 | (void (MarkupText::*)( const Real& ))&MarkupText::left ) 252 | .property( "top", 253 | (Real (MarkupText::*)() const)&MarkupText::top, 254 | (void (MarkupText::*)( const Real& ))&MarkupText::top ) 255 | .property( "text", 256 | (String (MarkupText::*)() const)&MarkupText::text, 257 | (void (MarkupText::*)( const String& ))&MarkupText::text ) 258 | ] 259 | ]; 260 | 261 | return; 262 | } 263 | 264 | -------------------------------------------------------------------------------- /examples/gorilla_3d.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "Gorilla.h" 5 | 6 | #include 7 | 8 | #pragma warning ( disable : 4244 ) 9 | 10 | struct Button 11 | { 12 | 13 | Button(Ogre::Real x, Ogre::Real y, const Ogre::String& text, Gorilla::Layer* layer) 14 | : hovered(false) 15 | { 16 | caption = layer->createCaption(14, x,y, text); 17 | caption->size(64,25); 18 | caption->align(Gorilla::TextAlign_Centre); 19 | caption->vertical_align(Gorilla::VerticalAlign_Middle); 20 | caption->background(Gorilla::rgb(255,255,255,32)); 21 | } 22 | 23 | bool isOver(const Ogre::Vector2& pos) 24 | { 25 | bool result = caption->intersects(pos); 26 | if (result && !hovered) 27 | caption->background(Gorilla::rgb(255,255,255,128)); 28 | else if (!result && hovered) 29 | caption->background(Gorilla::rgb(255,255,255,32)); 30 | hovered = result; 31 | return result; 32 | } 33 | 34 | bool hovered; 35 | Gorilla::Caption* caption; 36 | 37 | }; 38 | 39 | struct D3Panel 40 | { 41 | 42 | D3Panel(Gorilla::Silverback* silverback, Ogre::SceneManager* sceneMgr, const Ogre::Vector2& size) 43 | : mSize(size) 44 | { 45 | 46 | mScreen = silverback->createScreenRenderable(Ogre::Vector2(mSize.x,mSize.y), "dejavu"); 47 | mNode = sceneMgr->getRootSceneNode()->createChildSceneNode(); 48 | mNode->attachObject(mScreen); 49 | 50 | mGUILayer = mScreen->createLayer(0); 51 | mBackground = mGUILayer->createRectangle(0,0, mSize.x * 100, mSize.y * 100); 52 | mBackground->background_gradient(Gorilla::Gradient_NorthSouth, Gorilla::rgb(94,97,255,5), Gorilla::rgb(94,97,255,50)); 53 | mBackground->border(2, Gorilla::rgb(255,255,255,150)); 54 | 55 | mMousePointerLayer = mScreen->createLayer(15); 56 | mMousePointer = mMousePointerLayer->createRectangle(0,0,10,18); 57 | mMousePointer->background_image("mousepointer"); 58 | 59 | } 60 | 61 | Button* check(const Ogre::Ray& ray, bool& isOver) 62 | { 63 | 64 | isOver = false; 65 | 66 | Ogre::Matrix4 transform; 67 | transform.makeTransform(mNode->getPosition(), mNode->getScale(), mNode->getOrientation()); 68 | 69 | Ogre::AxisAlignedBox aabb = mScreen->getBoundingBox(); 70 | aabb.transform(transform); 71 | std::pair result = Ogre::Math::intersects(ray, aabb); 72 | 73 | if (result.first == false) 74 | return 0; 75 | 76 | Ogre::Vector3 a,b,c,d; 77 | Ogre::Vector2 halfSize = mSize * 0.5f; 78 | a = transform * Ogre::Vector3(-halfSize.x,-halfSize.y,0); 79 | b = transform * Ogre::Vector3( halfSize.x,-halfSize.y,0); 80 | c = transform * Ogre::Vector3(-halfSize.x, halfSize.y,0); 81 | d = transform * Ogre::Vector3( halfSize.x, halfSize.y,0); 82 | 83 | result = Ogre::Math::intersects(ray, c, b, a); 84 | if (result.first == false) 85 | result = Ogre::Math::intersects(ray, c, d, b); 86 | if (result.first == false) 87 | return 0; 88 | 89 | if (result.second > 6.0f) 90 | return 0; 91 | 92 | isOver = true; 93 | 94 | Ogre::Vector3 hitPos = ( ray.getOrigin() + (ray.getDirection() * result.second) ); 95 | Ogre::Vector3 localPos = transform.inverse() * hitPos; 96 | localPos.x += halfSize.x; 97 | localPos.y -= halfSize.y; 98 | localPos.x *= 100; 99 | localPos.y *= 100; 100 | 101 | // Cursor clip 102 | localPos.x = Ogre::Math::Clamp(localPos.x, 0, (mSize.x * 100) - 10); 103 | localPos.y = Ogre::Math::Clamp(-localPos.y, 0, (mSize.y * 100) - 18); 104 | 105 | mMousePointer->position(localPos.x, localPos.y); 106 | 107 | for (size_t i=0;i < mButtons.size();i++) 108 | { 109 | if (mButtons[i]->isOver(mMousePointer->position())) 110 | return mButtons[i]; 111 | } 112 | 113 | return 0; 114 | } 115 | 116 | Gorilla::Caption* makeCaption(Ogre::Real x, Ogre::Real y, const Ogre::String& text) 117 | { 118 | return mGUILayer->createCaption(14, x, y, text); 119 | } 120 | 121 | Button* makeButton(Ogre::Real x, Ogre::Real y, const Ogre::String& text) 122 | { 123 | Button* button = new Button(x,y, text, mGUILayer); 124 | mButtons.push_back(button); 125 | return button; 126 | } 127 | 128 | Gorilla::ScreenRenderable* mScreen; 129 | Ogre::SceneNode* mNode; 130 | Gorilla::Layer* mGUILayer, *mMousePointerLayer; 131 | Gorilla::Rectangle* mBackground, *mMousePointer; 132 | Ogre::Vector2 mSize; 133 | 134 | std::vector mButtons; 135 | 136 | }; 137 | 138 | class App : public Ogre::FrameListener, public OIS::KeyListener, public OIS::MouseListener 139 | { 140 | 141 | public: 142 | 143 | Ogre::Real mTimer, mTimer2; 144 | Gorilla::Silverback* mSilverback; 145 | Gorilla::Screen* mHUD, *mControlPanel; 146 | Gorilla::Layer* mHUDLayer; 147 | Gorilla::Layer* mCrosshairLayer; 148 | Gorilla::Rectangle* mCrosshair; 149 | D3Panel* mPowerPanel; 150 | Gorilla::Rectangle* mPowerValue, *mPowerValueBackground; 151 | Button* mPowerUpButton; 152 | Button* mPowerDownButton; 153 | Ogre::Real mBasePower; 154 | Ogre::SceneNode* mNode; 155 | 156 | App() : mTimer(0), mTimer2(0), mBasePower(150), mNextUpdate(0) 157 | { 158 | 159 | _makeOgre(); 160 | _makeOIS(); 161 | 162 | // Create Silverback and load in dejavu 163 | mSilverback = new Gorilla::Silverback(); 164 | mSilverback->loadAtlas("dejavu"); 165 | 166 | createHUD(); 167 | createControlPanel(); 168 | 169 | } 170 | 171 | void createHUD() 172 | { 173 | mHUD = mSilverback->createScreen(mViewport, "dejavu"); 174 | mHUDLayer = mHUD->createLayer(); 175 | 176 | Gorilla::Caption* fakeHealth = mHUDLayer->createCaption(24, 0, 0, "+ 100"); 177 | fakeHealth->width(mViewport->getActualWidth()-16); 178 | fakeHealth->height(mViewport->getActualHeight()-4); 179 | fakeHealth->align(Gorilla::TextAlign_Right); 180 | fakeHealth->vertical_align(Gorilla::VerticalAlign_Bottom); 181 | 182 | Gorilla::Caption* fakeAmmo = mHUDLayer->createCaption(24, 16, 0, ": 60"); 183 | fakeAmmo->width(mViewport->getActualWidth()); 184 | fakeAmmo->height(mViewport->getActualHeight()-4); 185 | fakeAmmo->vertical_align(Gorilla::VerticalAlign_Bottom); 186 | 187 | mCrosshairLayer = mHUD->createLayer(); 188 | mCrosshair = mCrosshairLayer->createRectangle((mViewport->getActualWidth() * 0.5f) - 11, (mViewport->getActualHeight() * 0.5f) - 11, 22, 22); 189 | mCrosshair->background_image("crosshair"); 190 | 191 | } 192 | 193 | void createControlPanel() 194 | { 195 | mPowerPanel = new D3Panel(mSilverback, mSceneMgr, Ogre::Vector2(4,1)); 196 | mPowerPanel->mNode->setPosition(Ogre::Vector3(0,1.5f,-10)); 197 | Gorilla::Caption* caption = mPowerPanel->makeCaption(0,4, "Power Level"); 198 | caption->width(400); 199 | caption->align(Gorilla::TextAlign_Centre); 200 | 201 | mPowerValueBackground = mPowerPanel->mGUILayer->createRectangle(10,35,380,10); 202 | mPowerValueBackground->background_colour(Gorilla::rgb(255,255,255,100)); 203 | 204 | mPowerValue = mPowerPanel->mGUILayer->createRectangle(10,35,200,10); 205 | mPowerValue->background_gradient(Gorilla::Gradient_NorthSouth, Gorilla::rgb(255,255,255,200), Gorilla::rgb(64,64,64,200)); 206 | mPowerDownButton = mPowerPanel->makeButton(10, 65, "-"); 207 | mPowerUpButton = mPowerPanel->makeButton(84, 65, "+"); 208 | 209 | } 210 | 211 | ~App() 212 | { 213 | std::cout << "\n** Average FPS is " << mWindow->getAverageFPS() << "\n\n"; 214 | delete mSilverback; 215 | delete mRoot; 216 | } 217 | 218 | bool frameStarted(const Ogre::FrameEvent& evt) 219 | { 220 | 221 | if (mWindow->isClosed()) 222 | return false; 223 | 224 | mKeyboard->capture(); 225 | if (mKeyboard->isKeyDown(OIS::KC_ESCAPE)) 226 | return false; 227 | mMouse->capture(); 228 | 229 | mTimer += evt.timeSinceLastFrame; 230 | 231 | if (mTimer > 1.0f / 60.0f) 232 | { 233 | mPowerPanel->mNode->yaw(Ogre::Radian(0.0005)); 234 | mTimer2 += Ogre::Math::RangeRandom(0, mTimer * 10); 235 | mTimer = 0; 236 | Ogre::Math::Clamp(mTimer2, 0, 25); 237 | Ogre::Real power = mBasePower + (Ogre::Math::Cos(mTimer2) * 5); 238 | power = Ogre::Math::Clamp(power, 0, 380); 239 | mPowerValue->width(power); 240 | } 241 | bool isOver = false; 242 | 243 | Button* button = mPowerPanel->check( mCamera->getCameraToViewportRay(0.5f,0.5f), isOver ); 244 | if (isOver) 245 | mCrosshairLayer->hide(); 246 | else 247 | mCrosshairLayer->show(); 248 | 249 | if (button != 0 && mMouse->getMouseState().buttonDown(OIS::MB_Left)) 250 | { 251 | if (button == mPowerDownButton) 252 | { 253 | mBasePower -= 1.0f; 254 | } 255 | if (button == mPowerUpButton) 256 | { 257 | mBasePower += 1.0f; 258 | } 259 | } 260 | 261 | Ogre::Vector3 trans(0,0,0); 262 | 263 | if (mKeyboard->isKeyDown(OIS::KC_W)) 264 | trans.z = -1; 265 | else if (mKeyboard->isKeyDown(OIS::KC_S)) 266 | trans.z = 1; 267 | if (mKeyboard->isKeyDown(OIS::KC_A)) 268 | trans.x = -1; 269 | else if (mKeyboard->isKeyDown(OIS::KC_D)) 270 | trans.x = 1; 271 | 272 | if (trans.isZeroLength() == false) 273 | { 274 | Ogre::Vector3 pos = mCamera->getPosition(); 275 | pos += mCamera->getOrientation() * (trans * 5.0f) * evt.timeSinceLastFrame; 276 | pos.y = 2.0f; 277 | mCamera->setPosition(pos); 278 | } 279 | 280 | return true; 281 | } 282 | 283 | bool keyPressed( const OIS::KeyEvent &e ) 284 | { 285 | return true; 286 | } 287 | 288 | bool keyReleased( const OIS::KeyEvent &e ) 289 | { 290 | return true; 291 | } 292 | 293 | bool mouseMoved( const OIS::MouseEvent &arg ) 294 | { 295 | Ogre::Real pitch = Ogre::Real(arg.state.Y.rel) * -0.005f; 296 | Ogre::Real yaw = Ogre::Real(arg.state.X.rel) * -0.005f; 297 | mCamera->pitch(Ogre::Radian(pitch)); 298 | mCamera->yaw(Ogre::Radian(yaw)); 299 | return true; 300 | } 301 | 302 | bool mousePressed( const OIS::MouseEvent &arg, OIS::MouseButtonID id ) 303 | { 304 | return true; 305 | } 306 | 307 | bool mouseReleased( const OIS::MouseEvent &arg, OIS::MouseButtonID id ) 308 | { 309 | return true; 310 | } 311 | 312 | void _makeOgre() 313 | { 314 | srand(time(0)); 315 | 316 | mRoot = new Ogre::Root("",""); 317 | mRoot->addFrameListener(this); 318 | 319 | #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX 320 | mRoot->loadPlugin(OGRE_RENDERER); 321 | #else 322 | #if 1 323 | #ifdef _DEBUG 324 | mRoot->loadPlugin("RenderSystem_Direct3D9_d"); 325 | #else 326 | mRoot->loadPlugin("RenderSystem_Direct3D9"); 327 | #endif 328 | #else 329 | #ifdef _DEBUG 330 | mRoot->loadPlugin("RenderSystem_GL_d.dll"); 331 | #else 332 | mRoot->loadPlugin("RenderSystem_GL.dll"); 333 | #endif 334 | #endif 335 | #endif 336 | 337 | mRoot->setRenderSystem(mRoot->getAvailableRenderers()[0]); 338 | 339 | Ogre::ResourceGroupManager* rgm = Ogre::ResourceGroupManager::getSingletonPtr(); 340 | rgm->addResourceLocation(".", "FileSystem"); 341 | 342 | mRoot->initialise(false); 343 | 344 | mWindow = mRoot->createRenderWindow("Gorilla", 1024, 768, false); 345 | mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC); 346 | mCamera = mSceneMgr->createCamera("Camera"); 347 | mViewport = mWindow->addViewport(mCamera); 348 | 349 | Ogre::ColourValue BackgroundColour = Ogre::ColourValue(0.1337f, 0.1337f, 0.1337f, 1.0f); 350 | Ogre::ColourValue GridColour = Ogre::ColourValue(0.2000f, 0.2000f, 0.2000f, 1.0f); 351 | 352 | mViewport->setBackgroundColour(BackgroundColour); 353 | 354 | rgm->initialiseAllResourceGroups(); 355 | 356 | mCamera->setPosition(10,2,10); 357 | mCamera->lookAt(0,2,0); 358 | mCamera->setNearClipDistance(0.05f); 359 | mCamera->setFarClipDistance(1000); 360 | 361 | mReferenceObject = new Ogre::ManualObject("ReferenceGrid"); 362 | 363 | mReferenceObject->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_LINE_LIST); 364 | 365 | Ogre::Real step = 1.0f; 366 | unsigned int count = 200; 367 | unsigned int halfCount = count / 2; 368 | Ogre::Real full = (step * count); 369 | Ogre::Real half = full / 2; 370 | Ogre::Real y = 0; 371 | Ogre::ColourValue c; 372 | for (unsigned i=0;i < count+1;i++) 373 | { 374 | 375 | if (i == halfCount) 376 | c = Ogre::ColourValue(0.5f,0.3f,0.3f,1.0f); 377 | else 378 | c = GridColour; 379 | 380 | mReferenceObject->position(-half,y,-half+(step*i)); 381 | mReferenceObject->colour(BackgroundColour); 382 | mReferenceObject->position(0,y,-half+(step*i)); 383 | mReferenceObject->colour(c); 384 | mReferenceObject->position(0,y,-half+(step*i)); 385 | mReferenceObject->colour(c); 386 | mReferenceObject->position(half,y,-half+(step*i)); 387 | mReferenceObject->colour(BackgroundColour); 388 | 389 | if (i == halfCount) 390 | c = Ogre::ColourValue(0.3f,0.3f,0.5f,1.0f); 391 | else 392 | c = GridColour; 393 | 394 | mReferenceObject->position(-half+(step*i),y,-half); 395 | mReferenceObject->colour(BackgroundColour); 396 | mReferenceObject->position(-half+(step*i),y,0); 397 | mReferenceObject->colour(c); 398 | mReferenceObject->position(-half+(step*i),y,0); 399 | mReferenceObject->colour(c); 400 | mReferenceObject->position(-half+(step*i),y, half); 401 | mReferenceObject->colour(BackgroundColour); 402 | 403 | } 404 | 405 | mReferenceObject->end(); 406 | mSceneMgr->getRootSceneNode()->attachObject(mReferenceObject); 407 | 408 | 409 | 410 | } 411 | 412 | void _makeOIS() 413 | { 414 | // Initialise OIS 415 | OIS::ParamList pl; 416 | size_t windowHnd = 0; 417 | std::ostringstream windowHndStr; 418 | mWindow->getCustomAttribute("WINDOW", &windowHnd); 419 | windowHndStr << windowHnd; 420 | pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str())); 421 | mInputManager = OIS::InputManager::createInputSystem( pl ); 422 | mKeyboard = static_cast(mInputManager->createInputObject(OIS::OISKeyboard, true)); 423 | mKeyboard->setEventCallback(this); 424 | mMouse = static_cast(mInputManager->createInputObject(OIS::OISMouse, true)); 425 | mMouse->setEventCallback(this); 426 | mMouse->getMouseState().width = mViewport->getActualWidth(); 427 | mMouse->getMouseState().height = mViewport->getActualHeight(); 428 | } 429 | 430 | Ogre::Root* mRoot; 431 | Ogre::RenderWindow* mWindow; 432 | Ogre::Viewport* mViewport; 433 | Ogre::SceneManager* mSceneMgr; 434 | Ogre::Camera* mCamera; 435 | Ogre::Real mNextUpdate; 436 | OIS::InputManager* mInputManager; 437 | OIS::Keyboard* mKeyboard; 438 | OIS::Mouse* mMouse; 439 | Ogre::ManualObject* mReferenceObject; 440 | 441 | }; 442 | 443 | int main() 444 | { 445 | App* app = new App(); 446 | app->mRoot->startRendering(); 447 | delete app; 448 | 449 | return 0; 450 | } 451 | 452 | 453 | -------------------------------------------------------------------------------- /dejavu.gorilla: -------------------------------------------------------------------------------- 1 | [Texture] 2 | file dejavu.png 3 | whitepixel 510 510 4 | 5 | [Font.14] 6 | lineheight 22 7 | spacelength 6 8 | baseline 18 9 | kerning -0.5 10 | monowidth 15 11 | range 33 126 12 | glyph_33 1 0 8 23 7 13 | glyph_34 9 0 10 23 8 14 | glyph_35 19 0 17 23 16 15 | glyph_36 36 0 13 23 12 16 | glyph_37 49 0 19 23 18 17 | glyph_38 68 0 16 23 14 18 | glyph_39 84 0 6 23 5 19 | glyph_40 90 0 8 23 7 20 | glyph_41 98 0 8 23 7 21 | glyph_42 106 0 10 23 9 22 | glyph_43 116 0 17 23 16 23 | glyph_44 133 0 7 23 6 24 | glyph_45 140 0 8 23 6 25 | glyph_46 148 0 7 23 6 26 | glyph_47 155 0 7 23 6 27 | glyph_48 162 0 13 23 12 28 | glyph_49 175 0 13 23 12 29 | glyph_50 188 0 13 23 12 30 | glyph_51 201 0 13 23 12 31 | glyph_52 214 0 13 23 12 32 | glyph_53 227 0 13 23 12 33 | glyph_54 240 0 13 23 12 34 | glyph_55 253 0 13 23 12 35 | glyph_56 266 0 13 23 12 36 | glyph_57 279 0 13 23 12 37 | glyph_58 292 0 7 23 6 38 | glyph_59 299 0 7 23 6 39 | glyph_60 306 0 17 23 16 40 | glyph_61 323 0 17 23 16 41 | glyph_62 340 0 17 23 16 42 | glyph_63 357 0 11 23 10 43 | glyph_64 368 0 20 23 19 44 | glyph_65 388 0 14 23 13 45 | glyph_66 402 0 14 23 13 46 | glyph_67 416 0 14 23 13 47 | glyph_68 430 0 16 23 14 48 | glyph_69 446 0 13 23 12 49 | glyph_70 459 0 12 23 11 50 | glyph_71 471 0 16 23 14 51 | glyph_72 487 0 15 23 14 52 | glyph_73 502 0 6 23 5 53 | glyph_74 0 23 6 23 5 54 | glyph_75 6 23 13 23 12 55 | glyph_76 19 23 12 23 10 56 | glyph_77 31 23 18 23 16 57 | glyph_78 49 23 15 23 14 58 | glyph_79 64 23 16 23 15 59 | glyph_80 80 23 12 23 11 60 | glyph_81 92 23 16 23 15 61 | glyph_82 108 23 14 23 13 62 | glyph_83 122 23 13 23 12 63 | glyph_84 135 23 13 23 11 64 | glyph_85 148 23 15 23 14 65 | glyph_86 163 23 14 23 13 66 | glyph_87 177 23 20 23 18 67 | glyph_88 197 23 14 23 13 68 | glyph_89 211 23 13 23 11 69 | glyph_90 224 23 14 23 13 70 | glyph_91 238 23 8 23 7 71 | glyph_92 246 23 7 23 6 72 | glyph_93 253 23 8 23 7 73 | glyph_94 261 23 17 23 16 74 | glyph_95 278 23 10 23 9 75 | glyph_96 288 23 10 23 9 76 | glyph_97 298 23 13 23 11 77 | glyph_98 311 23 13 23 12 78 | glyph_99 324 23 11 23 10 79 | glyph_100 335 23 13 23 12 80 | glyph_101 348 23 13 23 11 81 | glyph_102 361 23 8 23 6 82 | glyph_103 369 23 13 23 12 83 | glyph_104 382 23 13 23 12 84 | glyph_105 395 23 6 23 5 85 | glyph_106 401 23 6 23 5 86 | glyph_107 407 23 12 23 11 87 | glyph_108 419 23 6 23 5 88 | glyph_109 425 23 20 23 18 89 | glyph_110 445 23 13 23 12 90 | glyph_111 458 23 13 23 11 91 | glyph_112 471 23 13 23 12 92 | glyph_113 484 23 13 23 12 93 | glyph_114 497 23 9 23 7 94 | glyph_115 0 46 11 23 9 95 | glyph_116 11 46 8 23 7 96 | glyph_117 19 46 13 23 12 97 | glyph_118 32 46 12 23 11 98 | glyph_119 44 46 17 23 15 99 | glyph_120 61 46 12 23 11 100 | glyph_121 73 46 12 23 11 101 | glyph_122 85 46 11 23 10 102 | glyph_123 96 46 13 23 12 103 | glyph_124 109 46 7 23 6 104 | glyph_125 116 46 13 23 12 105 | glyph_126 129 46 17 23 16 106 | kerning_74 45 1 107 | kerning_84 45 -1 108 | kerning_86 45 -1 109 | kerning_89 45 -2 110 | kerning_84 65 -1 111 | kerning_86 65 -1 112 | kerning_87 65 -1 113 | kerning_89 65 -1 114 | kerning_118 65 -1 115 | kerning_121 65 -1 116 | kerning_89 66 -1 117 | kerning_89 68 -1 118 | kerning_46 70 -3 119 | kerning_58 70 -1 120 | kerning_65 70 -1 121 | kerning_97 70 -1 122 | kerning_101 70 -1 123 | kerning_105 70 -1 124 | kerning_114 70 -1 125 | kerning_117 70 -1 126 | kerning_121 70 -1 127 | kerning_45 75 -2 128 | kerning_67 75 -1 129 | kerning_79 75 -1 130 | kerning_84 75 -1 131 | kerning_121 75 -1 132 | kerning_84 76 -2 133 | kerning_86 76 -2 134 | kerning_87 76 -1 135 | kerning_89 76 -2 136 | kerning_121 76 -1 137 | kerning_88 79 -1 138 | kerning_89 79 -1 139 | kerning_46 80 -2 140 | kerning_65 80 -1 141 | kerning_84 82 -1 142 | kerning_86 82 -1 143 | kerning_89 82 -1 144 | kerning_121 82 -1 145 | kerning_45 84 -1 146 | kerning_46 84 -2 147 | kerning_58 84 -2 148 | kerning_65 84 -1 149 | kerning_67 84 -1 150 | kerning_97 84 -3 151 | kerning_99 84 -3 152 | kerning_101 84 -3 153 | kerning_111 84 -3 154 | kerning_114 84 -2 155 | kerning_115 84 -3 156 | kerning_117 84 -2 157 | kerning_119 84 -3 158 | kerning_121 84 -2 159 | kerning_45 86 -1 160 | kerning_46 86 -2 161 | kerning_58 86 -1 162 | kerning_65 86 -1 163 | kerning_97 86 -1 164 | kerning_101 86 -1 165 | kerning_111 86 -1 166 | kerning_117 86 -1 167 | kerning_46 87 -2 168 | kerning_58 87 -1 169 | kerning_65 87 -1 170 | kerning_97 87 -1 171 | kerning_101 87 -1 172 | kerning_111 87 -1 173 | kerning_67 88 -1 174 | kerning_79 88 -1 175 | kerning_45 89 -2 176 | kerning_46 89 -3 177 | kerning_58 89 -2 178 | kerning_65 89 -1 179 | kerning_67 89 -1 180 | kerning_79 89 -1 181 | kerning_97 89 -2 182 | kerning_101 89 -2 183 | kerning_111 89 -2 184 | kerning_117 89 -2 185 | kerning_45 102 -1 186 | kerning_46 102 -1 187 | kerning_45 114 -1 188 | kerning_46 114 -1 189 | kerning_46 118 -1 190 | kerning_58 118 -1 191 | kerning_46 119 -1 192 | kerning_58 119 -1 193 | kerning_46 121 -2 194 | kerning_58 121 -1 195 | kerning_112 112 -2 196 | kerning_103 105 -3 197 | 198 | 199 | [Font.9] 200 | offset 0 80 201 | lineheight 16 202 | spacelength 3 203 | baseline 11 204 | letterspacing 0 205 | monowidth 10 206 | range 33 126 207 | glyph_33 0 0 5 14 4 208 | glyph_34 5 0 6 14 5 209 | glyph_35 11 0 11 14 10 210 | glyph_36 22 0 8 14 7 211 | glyph_37 30 0 12 14 11 212 | glyph_38 42 0 10 14 9 213 | glyph_39 52 0 4 14 3 214 | glyph_40 56 0 5 14 4 215 | glyph_41 61 0 5 14 4 216 | glyph_42 66 0 7 14 6 217 | glyph_43 73 0 11 14 10 218 | glyph_44 84 0 4 14 3 219 | glyph_45 88 0 5 14 4 220 | glyph_46 93 0 4 14 3 221 | glyph_47 97 0 5 14 4 222 | glyph_48 102 0 8 14 7 223 | glyph_49 110 0 8 14 7 224 | glyph_50 118 0 8 14 7 225 | glyph_51 126 0 8 14 7 226 | glyph_52 134 0 8 14 7 227 | glyph_53 142 0 8 14 7 228 | glyph_54 150 0 8 14 7 229 | glyph_55 158 0 8 14 7 230 | glyph_56 166 0 8 14 7 231 | glyph_57 174 0 8 14 7 232 | glyph_58 182 0 5 14 4 233 | glyph_59 187 0 5 14 4 234 | glyph_60 192 0 11 14 10 235 | glyph_61 203 0 11 14 10 236 | glyph_62 214 0 11 14 10 237 | glyph_63 225 0 7 14 6 238 | glyph_64 232 0 13 14 12 239 | glyph_65 245 0 9 14 8 240 | glyph_66 254 0 9 14 8 241 | glyph_67 263 0 9 14 8 242 | glyph_68 272 0 10 14 9 243 | glyph_69 282 0 8 14 7 244 | glyph_70 290 0 8 14 6 245 | glyph_71 298 0 10 14 9 246 | glyph_72 308 0 10 14 9 247 | glyph_73 318 0 4 14 3 248 | glyph_74 322 0 4 14 3 249 | glyph_75 326 0 9 14 7 250 | glyph_76 335 0 7 14 6 251 | glyph_77 342 0 11 14 10 252 | glyph_78 353 0 10 14 9 253 | glyph_79 363 0 10 14 9 254 | glyph_80 373 0 8 14 7 255 | glyph_81 381 0 10 14 9 256 | glyph_82 391 0 9 14 8 257 | glyph_83 400 0 8 14 7 258 | glyph_84 408 0 8 14 7 259 | glyph_85 416 0 10 14 8 260 | glyph_86 426 0 9 14 8 261 | glyph_87 435 0 13 14 11 262 | glyph_88 448 0 9 14 8 263 | glyph_89 457 0 8 14 7 264 | glyph_90 465 0 9 14 8 265 | glyph_91 474 0 5 14 4 266 | glyph_92 479 0 5 14 4 267 | glyph_93 484 0 5 14 4 268 | glyph_94 489 0 11 14 10 269 | glyph_95 500 0 7 14 6 270 | glyph_96 0 14 7 14 6 271 | glyph_97 7 14 8 14 7 272 | glyph_98 15 14 8 14 7 273 | glyph_99 23 14 7 14 6 274 | glyph_100 30 14 8 14 7 275 | glyph_101 38 14 8 14 7 276 | glyph_102 46 14 5 14 4 277 | glyph_103 51 14 8 14 7 278 | glyph_104 59 14 8 14 7 279 | glyph_105 67 14 4 14 3 280 | glyph_106 71 14 4 14 3 281 | glyph_107 75 14 8 14 6 282 | glyph_108 83 14 4 14 3 283 | glyph_109 87 14 13 14 11 284 | glyph_110 100 14 8 14 7 285 | glyph_111 108 14 8 14 7 286 | glyph_112 116 14 8 14 7 287 | glyph_113 124 14 8 14 7 288 | glyph_114 132 14 6 14 4 289 | glyph_115 138 14 7 14 6 290 | glyph_116 145 14 5 14 4 291 | glyph_117 150 14 8 14 7 292 | glyph_118 158 14 8 14 7 293 | glyph_119 166 14 11 14 9 294 | glyph_120 177 14 8 14 7 295 | glyph_121 185 14 8 14 7 296 | glyph_122 193 14 7 14 6 297 | glyph_123 200 14 8 14 7 298 | glyph_124 208 14 5 14 4 299 | glyph_125 213 14 8 14 7 300 | glyph_126 221 14 11 14 10 301 | kerning_84 45 -1 302 | kerning_89 45 -1 303 | kerning_46 70 -1 304 | kerning_65 70 -1 305 | kerning_97 70 -1 306 | kerning_121 70 -1 307 | kerning_45 75 -1 308 | kerning_84 76 -1 309 | kerning_86 76 -1 310 | kerning_87 76 -1 311 | kerning_89 76 -1 312 | kerning_121 76 -1 313 | kerning_46 80 -1 314 | kerning_45 84 -1 315 | kerning_46 84 -1 316 | kerning_58 84 -1 317 | kerning_97 84 -1 318 | kerning_99 84 -2 319 | kerning_101 84 -2 320 | kerning_111 84 -2 321 | kerning_114 84 -1 322 | kerning_115 84 -1 323 | kerning_117 84 -1 324 | kerning_119 84 -1 325 | kerning_121 84 -1 326 | kerning_46 86 -1 327 | kerning_46 87 -1 328 | kerning_45 89 -1 329 | kerning_46 89 -2 330 | kerning_58 89 -1 331 | kerning_97 89 -1 332 | kerning_101 89 -1 333 | kerning_111 89 -1 334 | kerning_117 89 -1 335 | kerning_46 114 -1 336 | kerning_46 119 -1 337 | kerning_46 121 -1 338 | 339 | [Font.24] 340 | offset 0 121 341 | lineheight 38 342 | spacelength 10 343 | baseline 30 344 | kerning -0.5 345 | monowidth 25 346 | range 33 126 347 | glyph_33 1 0 14 38 12 348 | glyph_34 15 0 16 38 14 349 | glyph_35 31 0 28 38 26 350 | glyph_36 59 0 22 38 20 351 | glyph_37 81 0 32 38 30 352 | glyph_38 113 0 27 38 24 353 | glyph_39 140 0 10 38 8 354 | glyph_40 150 0 14 38 12 355 | glyph_41 164 0 14 38 12 356 | glyph_42 178 0 17 38 16 357 | glyph_43 195 0 28 38 26 358 | glyph_44 223 0 11 38 10 359 | glyph_45 234 0 13 38 11 360 | glyph_46 247 0 11 38 10 361 | glyph_47 258 0 12 38 10 362 | glyph_48 270 0 22 38 20 363 | glyph_49 292 0 22 38 20 364 | glyph_50 314 0 22 38 20 365 | glyph_51 336 0 22 38 20 366 | glyph_52 358 0 22 38 20 367 | glyph_53 380 0 22 38 20 368 | glyph_54 402 0 22 38 20 369 | glyph_55 424 0 22 38 20 370 | glyph_56 446 0 22 38 20 371 | glyph_57 468 0 22 38 20 372 | glyph_58 490 0 12 38 10 373 | glyph_59 0 38 12 38 10 374 | glyph_60 12 38 28 38 26 375 | glyph_61 40 38 28 38 26 376 | glyph_62 68 38 28 38 26 377 | glyph_63 96 38 18 38 16 378 | glyph_64 114 38 34 38 32 379 | glyph_65 148 38 23 38 21 380 | glyph_66 171 38 23 38 21 381 | glyph_67 194 38 24 38 22 382 | glyph_68 218 38 26 38 24 383 | glyph_69 244 38 22 38 20 384 | glyph_70 266 38 20 38 18 385 | glyph_71 286 38 26 38 24 386 | glyph_72 312 38 26 38 24 387 | glyph_73 338 38 11 38 9 388 | glyph_74 349 38 11 38 9 389 | glyph_75 360 38 22 38 20 390 | glyph_76 382 38 19 38 17 391 | glyph_77 401 38 29 38 27 392 | glyph_78 430 38 25 38 23 393 | glyph_79 455 38 27 38 25 394 | glyph_80 482 38 21 38 19 395 | glyph_81 0 76 27 38 25 396 | glyph_82 27 76 24 38 22 397 | glyph_83 51 76 22 38 20 398 | glyph_84 73 76 21 38 19 399 | glyph_85 94 76 25 38 23 400 | glyph_86 119 76 23 38 21 401 | glyph_87 142 76 33 38 31 402 | glyph_88 175 76 23 38 21 403 | glyph_89 198 76 21 38 19 404 | glyph_90 219 76 23 38 21 405 | glyph_91 242 76 14 38 12 406 | glyph_92 256 76 12 38 10 407 | glyph_93 268 76 14 38 12 408 | glyph_94 282 76 28 38 26 409 | glyph_95 310 76 17 38 16 410 | glyph_96 327 76 17 38 16 411 | glyph_97 344 76 21 38 19 412 | glyph_98 365 76 22 38 20 413 | glyph_99 387 76 19 38 17 414 | glyph_100 406 76 22 38 20 415 | glyph_101 428 76 21 38 19 416 | glyph_102 449 76 12 38 11 417 | glyph_103 461 76 22 38 20 418 | glyph_104 483 76 22 38 20 419 | glyph_105 0 114 10 38 8 420 | glyph_106 10 114 10 38 8 421 | glyph_107 20 114 20 38 18 422 | glyph_108 40 114 10 38 8 423 | glyph_109 50 114 33 38 31 424 | glyph_110 83 114 22 38 20 425 | glyph_111 105 114 21 38 19 426 | glyph_112 126 114 22 38 20 427 | glyph_113 148 114 22 38 20 428 | glyph_114 170 114 14 38 13 429 | glyph_115 184 114 18 38 16 430 | glyph_116 202 114 14 38 12 431 | glyph_117 216 114 22 38 20 432 | glyph_118 238 114 20 38 18 433 | glyph_119 258 114 28 38 26 434 | glyph_120 286 114 20 38 18 435 | glyph_121 306 114 20 38 18 436 | glyph_122 326 114 18 38 16 437 | glyph_123 344 114 22 38 20 438 | glyph_124 366 114 12 38 10 439 | glyph_125 378 114 22 38 20 440 | glyph_126 400 114 28 38 26 441 | kerning_66 45 -1 442 | kerning_71 45 1 443 | kerning_74 45 1 444 | kerning_81 45 1 445 | kerning_84 45 -2 446 | kerning_86 45 -1 447 | kerning_87 45 -1 448 | kerning_88 45 -1 449 | kerning_89 45 -3 450 | kerning_84 65 -2 451 | kerning_86 65 -2 452 | kerning_87 65 -1 453 | kerning_89 65 -2 454 | kerning_102 65 -1 455 | kerning_118 65 -1 456 | kerning_119 65 -1 457 | kerning_121 65 -2 458 | kerning_87 66 -1 459 | kerning_89 66 -1 460 | kerning_89 68 -1 461 | kerning_46 70 -5 462 | kerning_58 70 -2 463 | kerning_65 70 -2 464 | kerning_97 70 -2 465 | kerning_101 70 -1 466 | kerning_105 70 -2 467 | kerning_111 70 -1 468 | kerning_114 70 -2 469 | kerning_117 70 -1 470 | kerning_121 70 -2 471 | kerning_84 71 -1 472 | kerning_89 71 -1 473 | kerning_45 74 -1 474 | kerning_45 75 -3 475 | kerning_67 75 -1 476 | kerning_79 75 -1 477 | kerning_84 75 -2 478 | kerning_87 75 -1 479 | kerning_89 75 -1 480 | kerning_101 75 -1 481 | kerning_111 75 -1 482 | kerning_117 75 -1 483 | kerning_121 75 -2 484 | kerning_79 76 -1 485 | kerning_84 76 -4 486 | kerning_85 76 -1 487 | kerning_86 76 -3 488 | kerning_87 76 -2 489 | kerning_89 76 -4 490 | kerning_121 76 -2 491 | kerning_46 79 -1 492 | kerning_88 79 -2 493 | kerning_89 79 -1 494 | kerning_46 80 -4 495 | kerning_65 80 -2 496 | kerning_97 80 -1 497 | kerning_101 80 -1 498 | kerning_111 80 -1 499 | kerning_45 82 -1 500 | kerning_46 82 -1 501 | kerning_65 82 -1 502 | kerning_67 82 -1 503 | kerning_84 82 -2 504 | kerning_86 82 -1 505 | kerning_87 82 -1 506 | kerning_89 82 -2 507 | kerning_101 82 -1 508 | kerning_111 82 -1 509 | kerning_117 82 -1 510 | kerning_121 82 -1 511 | kerning_45 84 -2 512 | kerning_46 84 -3 513 | kerning_58 84 -3 514 | kerning_65 84 -2 515 | kerning_67 84 -1 516 | kerning_97 84 -5 517 | kerning_99 84 -5 518 | kerning_101 84 -5 519 | kerning_111 84 -5 520 | kerning_114 84 -4 521 | kerning_115 84 -5 522 | kerning_117 84 -4 523 | kerning_119 84 -5 524 | kerning_121 84 -4 525 | kerning_45 86 -1 526 | kerning_46 86 -4 527 | kerning_58 86 -2 528 | kerning_65 86 -2 529 | kerning_97 86 -2 530 | kerning_101 86 -2 531 | kerning_111 86 -2 532 | kerning_117 86 -2 533 | kerning_45 87 -1 534 | kerning_46 87 -3 535 | kerning_58 87 -1 536 | kerning_65 87 -1 537 | kerning_97 87 -2 538 | kerning_101 87 -1 539 | kerning_111 87 -1 540 | kerning_114 87 -1 541 | kerning_117 87 -1 542 | kerning_45 88 -1 543 | kerning_67 88 -2 544 | kerning_79 88 -2 545 | kerning_101 88 -1 546 | kerning_45 89 -3 547 | kerning_46 89 -6 548 | kerning_58 89 -4 549 | kerning_65 89 -2 550 | kerning_67 89 -1 551 | kerning_79 89 -1 552 | kerning_97 89 -4 553 | kerning_101 89 -4 554 | kerning_105 89 -1 555 | kerning_111 89 -4 556 | kerning_117 89 -3 557 | kerning_45 102 -1 558 | kerning_46 102 -2 559 | kerning_58 102 -1 560 | kerning_101 107 -1 561 | kerning_111 107 -1 562 | kerning_121 107 -1 563 | kerning_45 114 -2 564 | kerning_46 114 -2 565 | kerning_46 118 -2 566 | kerning_58 118 -1 567 | kerning_46 119 -2 568 | kerning_58 119 -1 569 | kerning_46 121 -4 570 | kerning_58 121 -2 571 | 572 | 573 | [Sprites] 574 | mousepointer 54 464 15 22 575 | ogrehead 0 464 48 48 576 | coco 3 367 64 64 577 | crosshair 49 487 22 22 578 | shadow_n 110 460 1 5 579 | shadow_ne 111 460 5 5 580 | shadow_e 111 465 5 1 581 | shadow_se 111 466 5 5 582 | shadow_s 110 466 1 5 583 | shadow_sw 105 466 5 5 584 | shadow_w 105 465 5 1 585 | shadow_nw 105 460 5 5 --------------------------------------------------------------------------------