| @@ -16,6 +16,7 @@ liblol_a_SOURCES = \ | |||
| eglapp.cpp eglapp.h \ | |||
| \ | |||
| loldebug.h debugfps.cpp debugfps.h debugsphere.cpp debugsphere.h \ | |||
| debugrecord.cpp debugrecord.h debugstats.cpp debugstats.h | |||
| debugrecord.cpp debugrecord.h debugstats.cpp debugstats.h \ | |||
| debugquad.cpp debugquad.h | |||
| liblol_a_CPPFLAGS = @LOL_CFLAGS@ | |||
| @@ -0,0 +1,183 @@ | |||
| // | |||
| // Lol Engine | |||
| // | |||
| // Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||
| // This program is free software; you can redistribute it and/or | |||
| // modify it under the terms of the Do What The Fuck You Want To | |||
| // Public License, Version 2, as published by Sam Hocevar. See | |||
| // http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||
| // | |||
| #if defined HAVE_CONFIG_H | |||
| # include "config.h" | |||
| #endif | |||
| #include <cstdio> | |||
| #include <cmath> | |||
| #include "core.h" | |||
| #include "lolgl.h" | |||
| #include "loldebug.h" | |||
| namespace lol | |||
| { | |||
| /* | |||
| * DebugTri implementation class | |||
| */ | |||
| class DebugTriData | |||
| { | |||
| friend class DebugTri; | |||
| private: | |||
| int initialised; | |||
| #if defined HAVE_GL_2X || defined HAVE_GLES_2X | |||
| GLuint buflist[2]; | |||
| Shader *shader; | |||
| #elif defined HAVE_GL_1X || defined HAVE_GLES_1X | |||
| GLuint buflist[2]; | |||
| #endif | |||
| }; | |||
| /* | |||
| * Public DebugTri class | |||
| */ | |||
| DebugTri::DebugTri() | |||
| : data(new DebugTriData()) | |||
| { | |||
| data->initialised = 0; | |||
| } | |||
| void DebugTri::TickGame(float deltams) | |||
| { | |||
| Entity::TickGame(deltams); | |||
| } | |||
| void DebugTri::TickDraw(float deltams) | |||
| { | |||
| Entity::TickDraw(deltams); | |||
| if (IsDestroying()) | |||
| { | |||
| if (data->initialised) | |||
| { | |||
| #if defined HAVE_GL_2X || defined HAVE_GLES_2X | |||
| glDeleteBuffers(2, data->buflist); | |||
| Shader::Destroy(data->shader); | |||
| #elif defined HAVE_GL_1X || defined HAVE_GLES_1X | |||
| glDeleteBuffers(2, data->buflist); | |||
| #endif | |||
| data->initialised = 0; | |||
| } | |||
| } | |||
| else if (!data->initialised) | |||
| { | |||
| #if defined HAVE_GL_2X || defined HAVE_GLES_2X | |||
| glGenBuffers(2, data->buflist); | |||
| static char const *vertexshader = | |||
| "#version 130\n" | |||
| "in vec2 in_Position;\n" | |||
| "in vec3 in_Color;\n" | |||
| "out vec3 pass_Color;\n" | |||
| "void main()\n" | |||
| "{\n" | |||
| " gl_Position = vec4(in_Position, 0.0f, 1.0f);\n" | |||
| " pass_Color = in_Color;\n" | |||
| "}\n"; | |||
| static char const *fragmentshader = | |||
| "#version 130\n" | |||
| "in vec3 pass_Color;\n" | |||
| "void main()\n" | |||
| "{\n" | |||
| " gl_FragColor = vec4(pass_Color, 1.0);\n" | |||
| "}\n"; | |||
| data->shader = Shader::Create(vertexshader, fragmentshader); | |||
| #elif defined HAVE_GL_1X || defined HAVE_GLES_1X | |||
| glGenBuffers(2, data->buflist); | |||
| #endif | |||
| data->initialised = 1; | |||
| } | |||
| static GLfloat const verts[6][2] = | |||
| { | |||
| { -0.9f, 0.9f }, { 0.9f, 0.9f }, { -0.9f, -0.9f }, | |||
| { -0.9f, -0.9f }, { 0.9f, 0.9f }, { 0.9f, -0.9f }, | |||
| }; | |||
| static GLfloat const cols[6][4] = | |||
| { | |||
| { 0.8f, 0.2f, 0.2f, 1.0f }, { 0.2f, 0.2f, 0.8f, 1.0f }, { 0.8f, 0.8f, 0.2f, 1.0f }, | |||
| { 0.8f, 0.8f, 0.2f, 1.0f }, { 0.2f, 0.2f, 0.8f, 1.0f }, { 0.2f, 0.8f, 0.2f, 1.0f }, | |||
| }; | |||
| #if defined HAVE_GL_2X || defined HAVE_GLES_2X | |||
| data->shader->Bind(); | |||
| GLuint attr_pos, attr_col; | |||
| attr_pos = data->shader->GetAttribLocation("in_Position"); | |||
| attr_col = data->shader->GetAttribLocation("in_Color"); | |||
| glEnableVertexAttribArray(attr_pos); | |||
| glEnableVertexAttribArray(attr_col); | |||
| glBindBuffer(GL_ARRAY_BUFFER, data->buflist[0]); | |||
| glBufferData(GL_ARRAY_BUFFER, 12 * sizeof(GLfloat), verts, GL_STATIC_DRAW); | |||
| glVertexAttribPointer(attr_pos, 2, GL_FLOAT, GL_FALSE, 0, 0); | |||
| glBindBuffer(GL_ARRAY_BUFFER, data->buflist[1]); | |||
| glBufferData(GL_ARRAY_BUFFER, 24 * sizeof(GLfloat), cols, GL_STATIC_DRAW); | |||
| glVertexAttribPointer(attr_col, 4, GL_FLOAT, GL_FALSE, 0, 0); | |||
| glDrawArrays(GL_TRIANGLES, 0, 6); | |||
| glDisableVertexAttribArray(attr_pos); | |||
| glDisableVertexAttribArray(attr_col); | |||
| #elif defined HAVE_GL_1X || defined HAVE_GLES_1X | |||
| glMatrixMode(GL_PROJECTION); | |||
| glPushMatrix(); | |||
| glLoadIdentity(); | |||
| glMatrixMode(GL_MODELVIEW); | |||
| glPushMatrix(); | |||
| glLoadIdentity(); | |||
| glDisableClientState(GL_NORMAL_ARRAY); | |||
| glDisableClientState(GL_TEXTURE_COORD_ARRAY); | |||
| glDisable(GL_TEXTURE_2D); | |||
| glEnableClientState(GL_VERTEX_ARRAY); | |||
| glEnableClientState(GL_COLOR_ARRAY); | |||
| #if defined HAVE_GL_1X | |||
| glBindBuffer(GL_ARRAY_BUFFER, data->buflist[0]); | |||
| glBufferData(GL_ARRAY_BUFFER, 12 * sizeof(GLfloat), verts, GL_STATIC_DRAW); | |||
| glVertexPointer(2, GL_FLOAT, 0, NULL); | |||
| glBindBuffer(GL_ARRAY_BUFFER, data->buflist[1]); | |||
| glBufferData(GL_ARRAY_BUFFER, 24 * sizeof(GLfloat), cols, GL_STATIC_DRAW); | |||
| glColorPointer(4, GL_FLOAT, 0, NULL); | |||
| #else | |||
| glVertexPointer(2, GL_FLOAT, 0, verts); | |||
| glColorPointer(4, GL_FLOAT, 0, cols); | |||
| #endif | |||
| glDrawArrays(GL_TRIANGLES, 0, 6); | |||
| glDisableClientState(GL_VERTEX_ARRAY); | |||
| glDisableClientState(GL_COLOR_ARRAY); | |||
| glMatrixMode(GL_PROJECTION); | |||
| glPopMatrix(); | |||
| glMatrixMode(GL_MODELVIEW); | |||
| glPopMatrix(); | |||
| #endif | |||
| } | |||
| DebugTri::~DebugTri() | |||
| { | |||
| delete data; | |||
| } | |||
| } /* namespace lol */ | |||
| @@ -0,0 +1,43 @@ | |||
| // | |||
| // Lol Engine | |||
| // | |||
| // Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||
| // This program is free software; you can redistribute it and/or | |||
| // modify it under the terms of the Do What The Fuck You Want To | |||
| // Public License, Version 2, as published by Sam Hocevar. See | |||
| // http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||
| // | |||
| // | |||
| // The DebugTri class | |||
| // ------------------ | |||
| // | |||
| #if !defined __DH_DEBUGTRI_H__ | |||
| #define __DH_DEBUGTRI_H__ | |||
| #include "entity.h" | |||
| namespace lol | |||
| { | |||
| class DebugTriData; | |||
| class DebugTri : public Entity | |||
| { | |||
| public: | |||
| DebugTri(); | |||
| virtual ~DebugTri(); | |||
| protected: | |||
| virtual void TickGame(float deltams); | |||
| virtual void TickDraw(float deltams); | |||
| private: | |||
| DebugTriData *data; | |||
| }; | |||
| } /* namespace lol */ | |||
| #endif // __DH_DEBUGTRI_H__ | |||
| @@ -17,6 +17,7 @@ | |||
| #define __DH_LOLDEBUG_H__ | |||
| #include "debugfps.h" | |||
| #include "debugquad.h" | |||
| #include "debugrecord.h" | |||
| #include "debugsphere.h" | |||
| #include "debugstats.h" | |||
| @@ -17,6 +17,7 @@ | |||
| <ClInclude Include="..\src\bitfield.h" /> | |||
| <ClInclude Include="..\src\core.h" /> | |||
| <ClInclude Include="..\src\debugfps.h" /> | |||
| <ClInclude Include="..\src\debugquad.h" /> | |||
| <ClInclude Include="..\src\debugrecord.h" /> | |||
| <ClInclude Include="..\src\debugsphere.h" /> | |||
| <ClInclude Include="..\src\debugstats.h" /> | |||
| @@ -56,6 +57,7 @@ | |||
| <ClCompile Include="..\deushax\game.cpp" /> | |||
| <ClCompile Include="..\src\audio.cpp" /> | |||
| <ClCompile Include="..\src\debugfps.cpp" /> | |||
| <ClCompile Include="..\src\debugquad.cpp" /> | |||
| <ClCompile Include="..\src\debugrecord.cpp" /> | |||
| <ClCompile Include="..\src\debugsphere.cpp" /> | |||
| <ClCompile Include="..\src\debugstats.cpp" /> | |||
| @@ -15,6 +15,9 @@ | |||
| <ClInclude Include="..\src\debugfps.h"> | |||
| <Filter>lolengine</Filter> | |||
| </ClInclude> | |||
| <ClInclude Include="..\src\debugquad.h"> | |||
| <Filter>lolengine</Filter> | |||
| </ClInclude> | |||
| <ClInclude Include="..\src\debugrecord.h"> | |||
| <Filter>lolengine</Filter> | |||
| </ClInclude> | |||
| @@ -121,6 +124,9 @@ | |||
| <ClCompile Include="..\src\debugfps.cpp"> | |||
| <Filter>lolengine</Filter> | |||
| </ClCompile> | |||
| <ClCompile Include="..\src\debugquad.cpp"> | |||
| <Filter>lolengine</Filter> | |||
| </ClCompile> | |||
| <ClCompile Include="..\src\debugrecord.cpp"> | |||
| <Filter>lolengine</Filter> | |||
| </ClCompile> | |||
| @@ -17,6 +17,7 @@ | |||
| <ClInclude Include="..\src\bitfield.h" /> | |||
| <ClInclude Include="..\src\core.h" /> | |||
| <ClInclude Include="..\src\debugfps.h" /> | |||
| <ClInclude Include="..\src\debugquad.h" /> | |||
| <ClInclude Include="..\src\debugrecord.h" /> | |||
| <ClInclude Include="..\src\debugsphere.h" /> | |||
| <ClInclude Include="..\src\debugstats.h" /> | |||
| @@ -56,6 +57,7 @@ | |||
| <ClCompile Include="..\deushax\mapviewer.cpp" /> | |||
| <ClCompile Include="..\src\audio.cpp" /> | |||
| <ClCompile Include="..\src\debugfps.cpp" /> | |||
| <ClCompile Include="..\src\debugquad.cpp" /> | |||
| <ClCompile Include="..\src\debugrecord.cpp" /> | |||
| <ClCompile Include="..\src\debugsphere.cpp" /> | |||
| <ClCompile Include="..\src\debugstats.cpp" /> | |||
| @@ -15,6 +15,9 @@ | |||
| <ClInclude Include="..\src\debugfps.h"> | |||
| <Filter>lolengine</Filter> | |||
| </ClInclude> | |||
| <ClInclude Include="..\src\debugquad.h"> | |||
| <Filter>lolengine</Filter> | |||
| </ClInclude> | |||
| <ClInclude Include="..\src\debugrecord.h"> | |||
| <Filter>lolengine</Filter> | |||
| </ClInclude> | |||
| @@ -121,6 +124,9 @@ | |||
| <ClCompile Include="..\src\debugfps.cpp"> | |||
| <Filter>lolengine</Filter> | |||
| </ClCompile> | |||
| <ClCompile Include="..\src\debugquad.cpp"> | |||
| <Filter>lolengine</Filter> | |||
| </ClCompile> | |||
| <ClCompile Include="..\src\debugrecord.cpp"> | |||
| <Filter>lolengine</Filter> | |||
| </ClCompile> | |||
| @@ -22,6 +22,7 @@ | |||
| <ClInclude Include="..\src\bitfield.h" /> | |||
| <ClInclude Include="..\src\core.h" /> | |||
| <ClInclude Include="..\src\debugfps.h" /> | |||
| <ClInclude Include="..\src\debugquad.h" /> | |||
| <ClInclude Include="..\src\debugrecord.h" /> | |||
| <ClInclude Include="..\src\debugsphere.h" /> | |||
| <ClInclude Include="..\src\debugstats.h" /> | |||
| @@ -65,6 +66,7 @@ | |||
| <ClCompile Include="..\monsterz\title.cpp" /> | |||
| <ClCompile Include="..\src\audio.cpp" /> | |||
| <ClCompile Include="..\src\debugfps.cpp" /> | |||
| <ClCompile Include="..\src\debugquad.cpp" /> | |||
| <ClCompile Include="..\src\debugrecord.cpp" /> | |||
| <ClCompile Include="..\src\debugsphere.cpp" /> | |||
| <ClCompile Include="..\src\debugstats.cpp" /> | |||
| @@ -15,6 +15,9 @@ | |||
| <ClInclude Include="..\src\debugfps.h"> | |||
| <Filter>lolengine</Filter> | |||
| </ClInclude> | |||
| <ClInclude Include="..\src\debugquad.h"> | |||
| <Filter>lolengine</Filter> | |||
| </ClInclude> | |||
| <ClInclude Include="..\src\debugrecord.h"> | |||
| <Filter>lolengine</Filter> | |||
| </ClInclude> | |||
| @@ -126,6 +129,9 @@ | |||
| <ClCompile Include="..\src\debugfps.cpp"> | |||
| <Filter>lolengine</Filter> | |||
| </ClCompile> | |||
| <ClCompile Include="..\src\debugquad.cpp"> | |||
| <Filter>lolengine</Filter> | |||
| </ClCompile> | |||
| <ClCompile Include="..\src\debugrecord.cpp"> | |||
| <Filter>lolengine</Filter> | |||
| </ClCompile> | |||