diff --git a/code/nel/include/nel/3d/driver.h b/code/nel/include/nel/3d/driver.h index d090d77da..89d2530c0 100644 --- a/code/nel/include/nel/3d/driver.h +++ b/code/nel/include/nel/3d/driver.h @@ -521,6 +521,7 @@ public: * \param numTri is the number of triangle to render. */ virtual bool renderRawTriangles(CMaterial& mat, uint32 startVertex, uint32 numTri)=0; + virtual bool renderRawTriangles2( CMaterial &mat, uint32 startVertex, uint32 numTri ){ return false; } /** If the driver support it, primitive can be rendered with an offset added to each index * These are the offseted version of the 'render' functions diff --git a/code/nel/src/3d/driver/OpenGL3/driver_glsl_shader_base.cpp b/code/nel/src/3d/driver/OpenGL3/driver_glsl_shader_base.cpp index daaf9a3d7..1c4088a24 100644 --- a/code/nel/src/3d/driver/OpenGL3/driver_glsl_shader_base.cpp +++ b/code/nel/src/3d/driver/OpenGL3/driver_glsl_shader_base.cpp @@ -44,7 +44,7 @@ namespace NL3D GLint ok; nglGetShaderiv( shaderId, GL_COMPILE_STATUS, &ok ); - if( ok != 0 ) + if( ok != GL_TRUE ) { char infoLog[ MAX_SHADER_COMPILE_INFOLOG ]; nglGetShaderInfoLog( shaderId, MAX_SHADER_COMPILE_INFOLOG, NULL, infoLog ); diff --git a/code/nel/src/3d/driver/OpenGL3/driver_opengl.h b/code/nel/src/3d/driver/OpenGL3/driver_opengl.h index cb4c3e852..6c8683731 100644 --- a/code/nel/src/3d/driver/OpenGL3/driver_opengl.h +++ b/code/nel/src/3d/driver/OpenGL3/driver_opengl.h @@ -436,6 +436,7 @@ public: virtual bool renderRawPoints(CMaterial& Mat, uint32 startIndex, uint32 numPoints); virtual bool renderRawLines(CMaterial& Mat, uint32 startIndex, uint32 numLines); virtual bool renderRawTriangles(CMaterial& Mat, uint32 startIndex, uint32 numTris); + virtual bool renderRawTriangles2( CMaterial &mat, uint32 startVertex, uint32 numTri ); virtual bool renderRawQuads(CMaterial& Mat, uint32 startIndex, uint32 numQuads); // virtual bool renderLinesWithIndexOffset(CMaterial& /* mat */, uint32 /* firstIndex */, uint32 /* nlines */, uint /* indexOffset */) { nlassertex(0, (UNSUPPORTED_INDEX_OFFSET_MSG)); return false; } diff --git a/code/nel/src/3d/driver/OpenGL3/driver_opengl_program.cpp b/code/nel/src/3d/driver/OpenGL3/driver_opengl_program.cpp index ec3da6c8d..3c3b1cee5 100644 --- a/code/nel/src/3d/driver/OpenGL3/driver_opengl_program.cpp +++ b/code/nel/src/3d/driver/OpenGL3/driver_opengl_program.cpp @@ -1,5 +1,7 @@ #include "driver_opengl.h" #include "driver_glsl_program.h" +#include "driver_glsl_vertex_program.h" +#include "driver_glsl_pixel_program.h" namespace NL3D { @@ -11,7 +13,7 @@ namespace NL3D return true; } - if( program->isLinked() ) + if( !program->isLinked() ) return false; nglValidateProgram( program->getProgramId() ); @@ -31,6 +33,69 @@ namespace NL3D return true; } + + + + const char *vs = + "#version 330\n" + "in vec4 vertex;\n" + "void main( void )\n" + "{\n" + "gl_Position = vertex;\n" + "}\n"; + + const char *fs = + "#version 330\n" + "out vec4 color;\n" + "void main( void )\n" + "{\n" + "color = vec4( 1.0, 0.0, 0.0, 1.0 );\n" + "}\n"; + + bool CDriverGL3::renderRawTriangles2( CMaterial &mat, uint32 startIndex, uint32 numTris ) + { + std::string log; + + CGLSLProgram program; + CGLSLVertexProgram *vp = new CGLSLVertexProgram(); + CGLSLPixelProgram *pp = new CGLSLPixelProgram(); + + vp->shaderSource( vs ); + if( !vp->compile( log ) ) + { + nlinfo( "%s", log.c_str() ); + return false; + } + + pp->shaderSource( fs ); + if( !pp->compile( log ) ) + { + nlinfo( "%s", log.c_str() ); + return false; + } + + if( !program.attachShader( vp ) ) + return false; + + if( !program.attachShader( pp ) ) + return false; + + if( !program.link( log ) ) + { + nlinfo( "%s", log.c_str() ); + return false; + } + + if( !activeGLSLProgram( &program ) ) + return false; + + glDrawArrays( GL_TRIANGLES, startIndex * 3, numTris * 3 ); + + activeGLSLProgram( NULL ); + + return true; + } + } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/nel3d_interface.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/nel3d_interface.cpp index da19e2408..fc1bd7cd6 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/nel3d_interface.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/nel3d_interface.cpp @@ -485,7 +485,7 @@ namespace MaterialEditor NL3D::CMaterial mat; mat.setColor( NLMISC::CRGBA::White ); - id->renderRawTriangles( mat, 0, 1 ); + id->renderRawTriangles2( mat, 0, 1 ); } driver->swapBuffers();