Archived

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

Gametaku

Textureing Problem: Bad Problems

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
Do glColor3f(1.0f, 1.0f, 1.0f); before drawing your textured primative if you have lighting off, which I''m assuming you do.

------------
- outRider -

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
Guest Anonymous Poster
Yeah SDL swops R and B.
So you gotta reswop em

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
Actually, EXT_bgra is supported by the Microsoft GDI generic implementation.

http://users.ox.ac.uk/~univ1234

[edited by - bakery2k1 on October 17, 2002 8:15:19 PM]

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