Sign in to follow this  

help with textures

This topic is 3490 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hello, I have copied the following code: // load a 256x256 RGB .RAW file as a texture GLuint LoadTextureRAW( const char * filename, int wrap ) { int width, height; unsigned char * data; FILE * file; // open texture data file = fopen( filename, "rb" ); if ( file == NULL ) return 0; // allocate buffer width = 256; height = 256; data = (unsigned char *) malloc( width * height * 4 ); // read texture data fread( data, width * height * 4, 1, file ); fclose( file ); // allocate a texture name glGenTextures( 1, &texture ); // select our current texture glBindTexture( GL_TEXTURE_2D, texture ); // select modulate to mix texture with color for shading glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); // when texture area is small, bilinear filter the closest MIP map glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST ); // when texture area is large, bilinear filter the first MIP map glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); // if wrap is true, the texture wraps over at the edges (repeat) // ... false, the texture ends at the edges (clamp) glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap ? GL_REPEAT : GL_CLAMP ); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap ? GL_REPEAT : GL_CLAMP ); // build our texture MIP maps gluBuild2DMipmaps( GL_TEXTURE_2D, 4, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data ); // free buffer free( data ); return texture; } and void drawBasePic(){ glEnable( GL_TEXTURE_2D ); glBindTexture( GL_TEXTURE_2D, texture ); glTranslatef(0,0,-0.29); glBegin( GL_QUADS ); glTexCoord2d(0.0,0.0); glVertex2d(-1.0,-0.5); glTexCoord2d(1.0,0.0); glVertex2d(+1.0,-0.5); glTexCoord2d(1.0,1.0); glVertex2d(+1.0,+0.5); glTexCoord2d(0.0,1.0); glVertex2d(-1.0,+0.5); glEnd(); glDisable(GL_TEXTURE_2D); glTranslatef(0,0,0.29); } the thing is the image is shown, but it has like purple color on it. i draw it on SOLID objects I created. i do not have red lights whatsoever... other images are drawn in green... its like something is wrong. thanks

Share this post


Link to post
Share on other sites

This topic is 3490 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this