color format

Helo everyone

I’m using direct3d vertex format where color is 32 bits integer (ARGB). I want to redirect vertices stream to OGL renderer but I have problem with color - is it possible to use ARGB packed color (32 bit integer) in OpenGL ??

chanel | alpha | red | green | blue |
bits | 24-31 | 16-23 | 8-15 | 0-7 |

best regards
Martin

OpenGL supports 32 bit colors only in RGBA format (byte order). Ie

DWORD bits on x86
[31...24] [23...16] [15...8] [7...0]
 alpha      blue     green     red

Should be easy enough to swizzle to that format. Corresponding vertex layout setup:

glColorPointer(4,GL_UNSIGNED_BYTE,sizeof(Vertex),&first_vertex.color);

This isn’t advanced …

we missunderstood - I have color in d3d format which means ARGB and I want to use this color for Opengl vertices - but opengl uses RGBA so :

I have color in format

chanel |alpha|red |green|blue |
bits |0-7 |8-15|16-23|24-31|

and I have to use this color in OpenGL renderer - I found extension ext_BGRA but I need something like ext_ARGB.

Isn’t this advanced ???

best regards!

There is no way. You can use ARGB as texture data, but not for vertex colors.

You must convert the colors to OpenGL’s format.

//still not advanced
unsigned int
make_GLish_color(unsigned int DXish_color)
{
  return((DXish_color&0xFF00FF00)|
         ((DXish_color&0xFF0000)>>16)|
         ((DXish_color&0xFF)<<16);
}

Maybe color matrix?

Mamy takie same nazwiska

I guess this post is one big confusion. So, you have got a windows-sheme texture and you want to upload it to opengl, right?
Use BGRA - that’s what you need:
B G R A
0-7 8-15 16-23 24 - 31

No, he’s got ARGB vertices. You can’t feed those to the GL at all. You could do the swizzling in a vertex program, but it’s better to do it manually on load, as zeckensack explained, so that you can forget about it at runtime.

– Tom