n0thing

Using GL_POINT_SPRITE results in blank screen

Discussion created by n0thing on Mar 9, 2010
Latest reply on Mar 29, 2010 by victtors

void ParticleRenderer::Display(DisplayMode mode /* = PARTICLE_POINTS */)
{
switch (mode)
{
case PARTICLE_POINTS:
glColor3f(1, 1, 1);
glPointSize(m_pointSize);

_drawPoints();
break;
case PARTICLE_SPRITES:
default:
{
// setup point sprites
glEnable(GL_POINT_SPRITE_ARB);
glTexEnvi(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE);
glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
glPointSize(m_spriteSize);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glEnable(GL_BLEND);
glDepthMask(GL_FALSE);

glUseProgram(m_program);
GLuint texLoc = glGetUniformLocation(m_program, "splatTexture");
glUniform1i(texLoc, 0);

glActiveTextureARB(GL_TEXTURE0_ARB);
glBindTexture(GL_TEXTURE_2D, m_texture);

glutReportErrors();

glColor3f(1, 1, 1);

_drawPoints();

glUseProgram(0);

glutReportErrors();

glDisable(GL_POINT_SPRITE_ARB);
glDisable(GL_BLEND);
glDepthMask(GL_TRUE);
}
break;
case PARTICLE_SPRITES_COLOR:
{
// setup point sprites
glEnable(GL_POINT_SPRITE_ARB);
glTexEnvi(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE);
glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
glPointSize(m_spriteSize);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glEnable(GL_BLEND);
glDepthMask(GL_FALSE);

glUseProgram(m_program);
GLuint texLoc = glGetUniformLocation(m_program, "splatTexture");
glUniform1i(texLoc, 0);

glActiveTextureARB(GL_TEXTURE0_ARB);
glBindTexture(GL_TEXTURE_2D, m_texture);

glutReportErrors();

glColor3f(1, 1, 1);

_drawPoints(true);

glUseProgram(0);

glutReportErrors();

glDisable(GL_POINT_SPRITE_ARB);
glDisable(GL_BLEND);
glDepthMask(GL_TRUE);
}
break;
}
}

const char vertexShader[] =
{
"void main() \n"
"{ \n"
" float pointSize = 500.0 * gl_Point.size; \n"
" vec4 vert = gl_Vertex; \n"
" vert.w = 1.0; \n"
" vec3 pos_eye = vec3 (gl_ModelViewMatrix * vert); \n"
" gl_PointSize = max(1.0, pointSize / (1.0 - pos_eye.z)); \n"
" gl_TexCoord[0] = gl_MultiTexCoord0; \n"
//" gl_TexCoord[1] = gl_MultiTexCoord1; \n"
" gl_Position = ftransform(); \n"
" gl_FrontColor = gl_Color; \n"
"} \n"
};

const char pixelShader[] =
{
"uniform sampler2D splatTexture; \n"

"void main() \n"
"{ \n"
" vec4 color = (0.6 + 0.4 * gl_Color) * texture2D(splatTexture, gl_TexCoord[0].st); \n"
" gl_FragColor = \n"
" color * mix(vec4(0.0, 0.2, 0.2, color.w), vec4(0.2, 0.7, 0.7, color.w), color.w);\n"
"} \n"
};

Attached code is from Nvidia's oclNBody sample. It only works with GL_POINTS else results in a blank-screen. Tested on radeon 5770 with catalyst 10.2

 

Outcomes