Archived

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

Vertex Buffers In DX and OpenGL

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

Hello all! I''ve made a FVF buffer for OpenGL that acts almost identical to the way DirectX handles vertex buffers. My problem is that when i pack a DWORD in the vertex buffer for the diffuse color of a vertex, i get the following: OpenGL: vertex.color = 0xFF0000FF // This gives red DirectX: vertex.color = 0xFFFF0000 // Also gives red OpenGL appears to be ABGR DirectX appears to be ARGB My engine has a rendering interface so really this needs to match up. Is there anyway of chaning it in DX OR OpenGL so that this ARGB or ABGR can be changed? Thanks.

Share this post


Link to post
Share on other sites
Your best bet is to have your own Color structure of sorts, with a, r, b, and g as normalized float values [0,1]. Then, have a method on your rendering interface to take that and return a DWORD from it, then implement that for DX and GL. Use your color structure throughout the code, then when it comes time to filling or modifying buffers, call the method on the rendering interface to return the correct format.

(source of info: http://www.ogre3d.org).

Share this post


Link to post
Share on other sites
Don''t think you can change this in DirectX, although I might be wrong.

You could however lock the vertex buffer in directX before rendering, and flip the 2nd and 4th bytes of the colour.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Some combination of GL_BGRA and GL_UNSIGNED_SHORT_1_5_5_5_REV. OpenGL allows pretty much any format, at least for textures.

Share this post


Link to post
Share on other sites