PDA

View Full Version : How to get point stripes function to with textured polygons?



mobilevisuals
09-18-2009, 10:48 AM
I can't get point stripes to work at the same time as textured polygons. When I draw the textured polygons,
the point stripes looses its textures. What I am doing wrong?

The call glDrawArrays(GL_TRIANGLE_STRIP, 1, 900); makes the point stripes loose its textures. When I remove that call the point stripes get back its texture. So it must be this that messes it up.This is my code:
---------

void CParticles::DrawParticles(TReal aTime)
{
// Move the viewer away from the particles
glLoadIdentity();
glTranslatef( 0, 0, -5 );
glRotatef( aTime, 0, 1, 0 );

// Enable vertex and color arrays.
//draw background:

glEnable( GL_TEXTURE_2D );
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnableClientState( GL_VERTEX_ARRAY );//**
glEnableClientState( GL_COLOR_ARRAY );
//ddrawing of backgrund-------------->
glBindTexture(GL_TEXTURE_2D, iBackgroundTexture.iID);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 32,
32, 0, GL_RGBA, GL_UNSIGNED_BYTE, ParticleBackground);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
GL_REPEAT glTexEnvx( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
glVertexPointer(3, GL_BYTE, 0, ParticleBackground);

glTexCoordPointer(2, GL_BYTE, 0, backgroundCoords);

glDrawArrays(GL_TRIANGLE_STRIP, 1, 900);

//end draw background<--


glVertexPointer( 3, GL_FIXED, 0, iParticleCoords );
glColorPointer( 4, GL_FIXED, 0, iParticleColors );

// Use the particle texture
glBindTexture( GL_TEXTURE_2D, iParticleTexture.iID );
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

// Draw the array of particles
glTexEnvi( GL_POINT_SPRITE_OES, GL_COORD_REPLACE_OES, GL_TRUE );
glDrawArrays( GL_POINTS, 0, iParticleCount );
glTexEnvi( GL_POINT_SPRITE_OES, GL_COORD_REPLACE_OES, GL_FALSE );

glDisableClientState( GL_VERTEX_ARRAY );
glDisableClientState( GL_COLOR_ARRAY );
}

Kari Pulli
09-24-2009, 10:59 AM
I only see one glTexture2D call, and that's for glBindTexture(GL_TEXTURE_2D, iBackgroundTexture.iID);
I don't see any glTexture2D call for glBindTexture( GL_TEXTURE_2D, iParticleTexture.iID ); so I don't think that texture has been defined.

mobilevisuals
10-02-2009, 05:27 AM
I made a new version of the method with 2 calls to glTexImage2D, with the same result as before. Do you have any idea why the point stripes are not being shown? They are white as it is now. This the code:

void CParticles::DrawParticles(TReal aTime)
{
// Move the viewer away from the particles
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0, 0, -5);
glEnable(GL_TEXTURE_2D);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
glBindTexture(GL_TEXTURE_2D, im31.iID);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGBA,
GL_BYTE, backgroundCoords);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
glVertexPointer(3, GL_FIXED, 0, ParticleBackground);

glTexCoordPointer(2, GL_BYTE, 0, backgroundCoords);
glDrawArrays(GL_TRIANGLE_STRIP, 1, 900);
//end draw background
glVertexPointer(3, GL_FIXED, 0, iParticleCoords);
// Use the particle texture
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0,
GL_RGBA, GL_UNSIGNED_BYTE, ParticleBackground);
glBindTexture(GL_TEXTURE_2D, iParticleTexture.iID);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

// Draw the array of particles
glTexEnvi(GL_POINT_SPRITE_OES, GL_COORD_REPLACE_OES, GL_TRUE );
glDrawArrays(GL_POINTS, 0, iParticleCount);
glTexEnvi(GL_POINT_SPRITE_OES, GL_COORD_REPLACE_OES, GL_FALSE );
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
}


I only see one glTexture2D call, and that's for glBindTexture(GL_TEXTURE_2D, iBackgroundTexture.iID);
I don't see any glTexture2D call for glBindTexture( GL_TEXTURE_2D, iParticleTexture.iID ); so I don't think that texture has been defined.

mobilevisuals
10-26-2009, 12:35 AM
I got this to work after making a new project.