Rendering the debug triangle with GLSL now works.

--HG--
branch : gsoc2013-dfighter
hg/feature/gsoc2013-dfighter
dfighter1985 11 years ago
parent b3ea9ee787
commit f5358f712c

@ -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

@ -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 );

@ -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; }

@ -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;
}
}

@ -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();

Loading…
Cancel
Save