Original Post
Hi there! The situation I'm currently trying to implement a particle system using point sprites. The tutorial I' using as a reference is this one: CodeSampler P.S.Tut. On the image below you can see the comparison between the tutorial's sample and my application (As you can see the sprites in the sample app appear to be much bigger than mine):
The problem So what I want to do now is to change my particle's sizes. Sadly the "glPointSize(x)" function won't change a thing [sad]. To be honest I didn't quite understand what all the point-sprite-code is about. So I weren't able to figure out what the problem is... Could you help me a little? Thank's so much!!! The code Just for reference, here's my code: Point sprite initialization: Point sprite rendering:
void initPointSprites( void )
{
// Create point sprite extensions
char *ext = (char*)glGetString( GL_EXTENSIONS );
if( strstr( ext, "GL_ARB_point_parameters" ) == NULL )
{
MessageBoxA(NULL,"GL_ARB_point_parameters extension was not found", "ERROR",MB_OK|MB_ICONEXCLAMATION);
return;
}
else
{
glPointParameterfARB = (PFNGLPOINTPARAMETERFARBPROC)wglGetProcAddress("glPointParameterfARB");
glPointParameterfvARB = (PFNGLPOINTPARAMETERFVARBPROC)wglGetProcAddress("glPointParameterfvARB");
if( !glPointParameterfARB || !glPointParameterfvARB )
{
MessageBoxA(NULL,"One or more GL_ARB_point_parameters functions were not found", "ERROR",MB_OK|MB_ICONEXCLAMATION);
return;
}
}
// Create texture
AUX_RGBImageRec *pTextureImage = auxDIBImageLoad( L"default.bmp" );
if( pTextureImage != NULL )
{
glGenTextures( 1, &g_textureID );
glBindTexture( GL_TEXTURE_2D, g_textureID );
glTexParameteri( GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexImage2D( GL_TEXTURE_2D, 0, 3, pTextureImage->sizeX, pTextureImage->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, pTextureImage->data );
}
if( pTextureImage )
{
if( pTextureImage->data )
free( pTextureImage->data );
free( pTextureImage );
}
MessageBoxA(NULL,"Point sprites successfully initialized!", "Info",MB_OK);
}
void CParticleEmitter::render( void )
{
// Setup OpenGL
glEnable(GL_TEXTURE_2D);
bindMyTexture();
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE );
// Do some strange stuff I don't quite understand
float quadratic[] = { 0.01f, 0.0f, 0.01f };
glPointParameterfvARB( GL_POINT_DISTANCE_ATTENUATION_ARB, quadratic );
float maxSize = 0.0f;
glGetFloatv( GL_POINT_SIZE_MAX_ARB, &maxSize );
if( maxSize > 100.0f ) maxSize = 100.0f;
glPointSize( maxSize );
// Do even more strange stuff I don't quite understand
glPointParameterfARB( GL_POINT_FADE_THRESHOLD_SIZE_ARB, 60.0f );
glPointParameterfARB( GL_POINT_SIZE_MIN_ARB, 5.0f );
glPointParameterfARB( GL_POINT_SIZE_MAX_ARB, maxSize );
glTexEnvf( GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE );
glEnable( GL_POINT_SPRITE_ARB );
// Render particles
glBegin( GL_POINTS );
{
for( int i=0; i<maxParticleCount; i++ )
{
if( mParticles.isUsed )
{
glColor4f( mParticles.curColor.x,
mParticles.curColor.y,
mParticles.curColor.z,
mParticles.curAlpha );
glVertex3f( mParticles.curPos.x, mParticles.curPos.y, mParticles.curPos.z );
}
}//end for
}
glEnd();
glDisable( GL_POINT_SPRITE_ARB );
glDisable(GL_TEXTURE_2D);
}