Skip to main content
gamedev.net
🔒 Locked

Engine and Enum Management

Started by Axiverse 2 replies 350+ views
Original Post
Axiverse
Axiverse
I'm making a graphics engine and I'm trying to allow it to use DX and Gl, but I've come across a problem.... How do you take care of Enum Inconsistancies... I'm sure that DX and GL don't use identical enums... (though it would be nice if they did), so any suggestions?
void*
void*
my suggestion would be to make your engine a little bit more high level... don't merely make it a wrapper to DX or GL. Instead, create higher-level constructs, like meshes, and make an abstract class for rendering these constructs... then, when it comes time to draw them, you can use concrete subclasses (one for DX, one for GL) which handle the proper enumerations for lighting or matrix selection or whatever have you.
Greenspun's Tenth Rule of Programming: "Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified bug-ridden slow implementation of half of Common Lisp."
Namethatnobodyelsetook
Namethatnobodyelsetook
Define your own values, and the OpenGL or DirectX layer should translate to the appropriate value for it's API.

ie:
enum
{
MC_None,
MC_CW,
MC_CCW,
MC_MAX
}MyCull;

and to convert, you can do a simple table:

D3DCULL aD3DCull[MC_MAX] = { D3DCULL_None, D3DCULL_CW, D3DCULL,CCW};

pDev->SetRenderState(D3DRS_CULLMODE, aD3DCull[cullMode]);
Axiverse
Axiverse
Yes I have thought of the tables... but what about those bitmasked things like (Thing1|Thing2)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.