• Advertisement

Archived

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

Help...Abstract Render probs

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

Hi, I''ve been working on an abstract render that can be used with openGL and Direct3D. Now the problem I''m having is with the way diffuse colours are sent through the API''s. Direct3D uses a single unsigned long store as RGBA where as OpenGL can use an array of four bytes (0 = red, 1 = green, etc) which when read as a single long value is the reverse of Direct3D. I know I could convert between the two on the fly, but I was hoping that there may be an easier solution, maybe a setting to reverse the order in OpenGL or D3D? I''m using DrawPrimativeStrided for Direct3D and glColorPointer in OpenGL. ANY suggestions would be welcome, thanks...

Share this post


Link to post
Share on other sites
Advertisement
  
void byteSwapLong(long * ptr)
{
void * p = (void *)ptr;
_asm
{
mov ebx, p
mov eax, [ebx]
bswap eax
mov [ebx], eax
}
}

Share this post


Link to post
Share on other sites
You could use a vertex shader/vertex program and swizzle the colour as you process vertices.

Although I''d be inclined to settle on one colour order (ARGB, RGBA, ABGR or BGRA being the most common) for your abstract API and convert any data on the fly. If you abstract highly enough, most of this colour conversion for average engine uses could be done at load time (i.e. loaders which convert to the native format on the target platform - we do this for example for development version endian swapping for some console platforms).

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites
Thanks for the help guys,

I think I''ll just use the byteSwapLong that was posted by TerranFury for run time conversions. I was worried that this might be slow, but thinking about it, I don''t think it would make much difference.

-Digitalblur

Share this post


Link to post
Share on other sites

  • Advertisement