diff --git a/examples/AnimatedMesh/main.cpp b/examples/AnimatedMesh/main.cpp index ce57e59c9..9d4394a08 100644 --- a/examples/AnimatedMesh/main.cpp +++ b/examples/AnimatedMesh/main.cpp @@ -33,6 +33,8 @@ int main() return EXIT_FAILURE; } + NzDebugDrawer::Initialize(); + // Maintenant nous pouvons utiliser le moteur comme bon nous semble, tout d'abord nous allons charger les ressources // Charger une ressource se fait actuellement manuellement, mais un ResourceManager est à venir diff --git a/src/Nazara/Renderer/DebugDrawer.cpp b/src/Nazara/Renderer/DebugDrawer.cpp index 8f0474a4a..ad9858383 100644 --- a/src/Nazara/Renderer/DebugDrawer.cpp +++ b/src/Nazara/Renderer/DebugDrawer.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -19,7 +20,7 @@ namespace { static NzColor primaryColor = NzColor::Red; static NzColor secondaryColor = NzColor::Green; - static NzShader* shader = nullptr; + static const NzShader* shader = nullptr; static NzVertexBuffer* vertexBuffer = nullptr; static NzVertexDeclaration* vertexDeclaration = nullptr; static bool depthTest = true; @@ -241,69 +242,14 @@ bool NzDebugDrawer::Initialize() { // Shader { - const char* fragmentSource110 = - "#version 110\n" - "uniform vec3 color;\n" - "void main()\n" - "{\n" - " gl_FragColor = vec4(color, 1.0);\n" - "}\n"; - - const char* fragmentSource140 = - "#version 140\n" - "uniform vec3 color;\n" - "out vec4 RenderTarget0;\n" - "void main()\n" - "{\n" - " RenderTarget0 = vec4(color, 1.0);\n" - "}\n"; - - const char* vertexSource110 = - "#version 110\n" - "attribute vec3 Position;\n" - "uniform mat4 WorldViewProjMatrix;\n" - "void main()\n" - "{\n" - " gl_Position = WorldViewProjMatrix * vec4(Position, 1.0);\n" - "}\n"; - - const char* vertexSource140 = - "#version 140\n" - "in vec3 Position;\n" - "uniform mat4 WorldViewProjMatrix;\n" - "void main()\n" - "{\n" - " gl_Position = WorldViewProjMatrix * vec4(Position, 1.0);\n" - "}\n"; - - bool useGLSL140 = (NzOpenGL::GetVersion() >= 310); - - shader = new NzShader(nzShaderLanguage_GLSL); - if (!shader->Load(nzShaderType_Fragment, (useGLSL140) ? fragmentSource140 : fragmentSource110)) + shader = NzShaderBuilder::Get(nzShaderBuilder_None); + if (!shader) { - NazaraError("Failed to load fragment shader"); - Uninitialize(); - + NazaraError("Failed to build debug shader"); return false; } - if (!shader->Load(nzShaderType_Vertex, (useGLSL140) ? vertexSource140 : vertexSource110)) - { - NazaraError("Failed to load vertex shader"); - Uninitialize(); - - return false; - } - - if (!shader->Compile()) - { - NazaraError("Failed to compile shader"); - Uninitialize(); - - return false; - } - - colorLocation = shader->GetUniformLocation("color"); + colorLocation = shader->GetUniformLocation("DiffuseColor"); } // VertexDeclaration @@ -393,12 +339,6 @@ void NzDebugDrawer::SetSecondaryColor(const NzColor& color) void NzDebugDrawer::Uninitialize() { - if (shader) - { - delete shader; - shader = nullptr; - } - if (vertexBuffer) { delete vertexBuffer;