RGBA Problem

Hi! I 'm working on loader of quake 2 model data and everything seems to be
good except colors eg. I’v got blue where it should be red …

I think that i’ve got BGRA not RGBA . So I’ve got Pc it is low endian

My initialzation :

SDL_GL_SetAttribute(SDL_GL_RED_SIZE,8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE,8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE,8);
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE,8);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE,16);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1);

screen=SDL_SetVideoMode(640,480,32,SDL_OPENGL|SDL_FULLSCREEN);
if(screen==0)
{
printf(“Failed: %s”,SDL_GetError());
return(1);
}

I’m useing SDL_image to load texture from file like below:

SDL_Surface *LoadTex(char *name)
{
SDL_Surface *texture;
SDL_Surface *image;

image=IMG_Load(name); //Get image from file
texture=SDL_DisplayFormatAlpha(image); // Convert it into screen parameters
SDL_FreeSurface(image); //free original image
return(texture);
}

And use this texture like this:

fglTexImage2D(GL_TEXTURE_2D,0,3,((*obj)->texture)->w,((*obj)->texture)->h,0,
GL_RGBA,GL_UNSIGNED_BYTE,((*obj)->texture)->pixel

For diffrent formats of the same picture
eg. pcx,bmp,tga result is always the same.

Thanks for reading…

Greetings Scorpion–

Tego nie znajdziesz w ?adnym sklepie!
[ http://oferty.onet.pl ]

fglTexImage2D(GL_TEXTURE_2D,0,3,((*obj)->texture)->w,((*obj)->texture)->h,0,
GL_RGBA,GL_UNSIGNED_BYTE,((*obj)->texture)->pixel

Use GL_BGRA instead of GL_RGBA.

Marius

Hi!
I think there’s also a GLenum called “GL_BGRA” - try using this one for
texture-transfer.
Other thing: I also had the “blue is now red” - problem using SDL_image,
but as I only had to load jpg’s I just took some really fast jpg-decoder
and my problems were gone. The only bad thing about it: it uses
intel-asm, so it’s not really portable.
St0fF.>glTexImage2D(GL_TEXTURE_2D,0,3,((*obj)->texture)->w,((*obj)->texture)->h,0,

           GL_RGBA,GL_UNSIGNED_BYTE,((*obj)->texture)->pixel

=========================================================
!!! COMMODORE – anything else is just a COMPROMISE !!!

St0fF 64 / N30PLA51A - 4 Love, Code, Composition & Design

What’s the difference between a VIC-Chip and a GeForce-GPU?
The Age …

SDL_DisplayFormatAlpha is not guaranteed to get the texture into RGBA
format. In fact, I don’t recall offhand if it’s even guaranteed to get
the texture into the OpenGL context’s internalformat.

SDL_GL_LoadTexture in testgl.c shows how to do it right, but it’s a mess.On Sun, Apr 21, 2002 at 04:32:20PM +0200, scorpion wrote:

Hi! I 'm working on loader of quake 2 model data and everything seems to be
good except colors eg. I’v got blue where it should be red …

I think that i’ve got BGRA not RGBA . So I’ve got Pc it is low endian

My initialzation :

SDL_GL_SetAttribute(SDL_GL_RED_SIZE,8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE,8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE,8);
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE,8);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE,16);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1);

screen=SDL_SetVideoMode(640,480,32,SDL_OPENGL|SDL_FULLSCREEN);
if(screen==0)
{
printf(“Failed: %s”,SDL_GetError());
return(1);
}

I’m useing SDL_image to load texture from file like below:

SDL_Surface *LoadTex(char *name)
{
SDL_Surface *texture;
SDL_Surface *image;

image=IMG_Load(name); //Get image from file
texture=SDL_DisplayFormatAlpha(image); // Convert it into screen parameters
SDL_FreeSurface(image); //free original image
return(texture);
}


Joseph Carter What’re you looking at?

  • bma wonders if this will make the Knghtbrd .sig

-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 273 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20020421/8bcd9eaa/attachment.pgp

Beware of win32. OpenGL 1.1 headers suck.On Sun, Apr 21, 2002 at 04:54:38PM -0400, Marius Andra wrote:

fglTexImage2D(GL_TEXTURE_2D,0,3,((*obj)->texture)->w,((*obj)->texture)->h,0,
GL_RGBA,GL_UNSIGNED_BYTE,((*obj)->texture)->pixel

Use GL_BGRA instead of GL_RGBA.


Joseph Carter Sanity is counterproductive

add a GF2/3, a sizable hard drive, and a 15" flat panel and
you’ve got a pretty damned portable machine.
a GeForce Two-Thirds?
Coderjoe: yes, a GeForce two-thirds, ie, any card from ATI.

-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 273 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20020421/30ac2191/attachment.pgp