Vertex Buffers In DX and OpenGL

Started by
3 comments, last by MeshMan 20 years, 1 month ago
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.
Advertisement
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).
________________________________________________Chris McGuirkLead Programmer - Axiom 3D EngineC# gaming, the way of the future!http://www.axiom3d.org
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.
Looking at the OGRE engine right now...
Where does is the function in the interface that does this?

Thanks.
Some combination of GL_BGRA and GL_UNSIGNED_SHORT_1_5_5_5_REV. OpenGL allows pretty much any format, at least for textures.

This topic is closed to new replies.

Advertisement