PDA

View Full Version : Weird colors w/ my textures!



chracatoa
05-20-2003, 03:48 PM
Ok, I'm just saving my framebuffer to a texture and drawing it as a texture in the exact same place and the colors are different, like they're dithered or something! The position is right, though.

[on a related note, interesting enough even my splats look like concentric circles instead of a nice gradient, I wonder what I am doing wrong].

Here's my code:
glBindTexture( GL_TEXTURE_2D, texName );
glCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, Vx, Vy, Sx, Sy);

glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glDisable(GL_ALPHA_TEST);
glDisable(GL_BLEND);
glColor4f(1,1,1,1);

glBegin(GL_QUADS);
glTexCoord2f(0., 0.);
glVertex2f(0, 0);
glTexCoord2f((float)Sx/1024.0, 0.);
glVertex2f(1,1);
glTexCoord2f((float)Sx/1024.0, (float)Sy/1024.0);
glVertex2f(1,1);
glTexCoord2f(0., (float)Sy/1024.0);
glVertex2f(0,1);
glEnd();


And this is how I create the texture: (I have also tried GL_NEAREST w/o success)

glBindTexture( GL_TEXTURE_2D, texName );
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (GLsizei)1024, (GLsizei)1024, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);

chracatoa
05-21-2003, 09:58 AM
I have finally fixed:

The correct version is:

glTexImage2D(GL_TEXTURE_2D, 0,


/*****/ GL_RGBA8, /*****/


(GLsizei)1024, (GLsizei)1024, 0, GL_RGBA,
GL_UNSIGNED_BYTE, 0);

Obli
05-22-2003, 09:45 AM
Interesting. Thank you.

Maybe you can use TexSubImage to get some additional performance.