I am working on a small game engine. One of the features of this is that it must support DirectX and OpenGL rendering.
I use Vertex Buffer Objects and I have a structure to determine the format of my vertices. The problem is that I would like to be able to use the same structure for both DirectX and OpenGL so that I can switch from my DirectX rendering component to OpenGL without changing the vertices of my objects.
Is it possible?
I am currently using the following structure for DirectX:
struct Vertex{ float position[3];
together with:
#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX1 )
as a flexible vertex format.
My understanding of OpenGL tells me that when I want to draw my object, I can say the color with this command:
glColorPointer(4, GL_FLOAT, sizeof(Vertex), BUFFER_OFFSET24);
in the drawing procedure, assuming that the color has 4 components. And really, it works. However, I do not believe that I can tell OpenGL to use an unsigned integer for this task, so I use:
struct Vertex{ float position[3];
this structure is for my OpenGL code.
source share