Archived

This topic is now archived and is closed to further replies.

Textureing Problem: Bad Problems

This topic is 5539 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

APIs: Opengl, with SDL (and SDL_mixer) Compiler: Borland Comand Line Problem: The coloring of my textures does not match the bitmap they were created from. Code: Texture Loading
  
int loadGLTexture ()
{
printf("starting Load texture\n");
int status = FALSE;
SDL_Surface *textureImage[1];
textureImage[0]=SDL_LoadBMP("texture.bmp");
if (textureImage[0])
{
printf ("textre Loaded \n");
status = TRUE;
glGenTextures(1, &textures[0]);
glBindTexture(GL_TEXTURE_2D, textures[0]);
glTexImage2D(GL_TEXTURE_2D, 0, 3, textureImage[0]->w, textureImage[0]->h,
0, GL_RGB, GL_UNSIGNED_BYTE, textureImage[0]->pixels);

 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE
R,GL_NEAREST);
 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE
R,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
}
if (textureImage[0])
SDL_FreeSurface(textureImage[0]);
printf("done with Load texture");
return status;

  
The picture on the left is the bmp that is loaded, and the one on the right is the texured image.

Share this post


Link to post
Share on other sites
Check the previous post, but the image also looks R/B swapped. Check the loading code (or if you can''t coz it''s SDL, write a R/B swapper or use GL_BGR or something)

Share this post


Link to post
Share on other sites
thanks, your right about having to swap them, but I''m without the function

GL_BRG, since I''m on windows and thus using opengl 1.1 (or 1.0)not sure. and thus don''t have it.

So how would I go about writing an R and B swaper?

Share this post


Link to post
Share on other sites

char *swapper = ImageData;

char temp;
for(int ind = 0; ind < IMAGE_SIZE; ind+=3)
{
temp = swapper[ind+2];
swapper[ind+2] = swapper[ind];
swapper[ind] = temp;
}


I think that might work for 24-bit BMP''s.

Share this post


Link to post
Share on other sites