I'm currently designing a Game Engine in C#. The engine has multiple driver types (OpenGL, DirectX). However each driver type requires different key codes when the user presses a button. But for some reason, using preprocessors isn't working... mind you I'm very new to using them.
I really think (like in most cases) the best way to get someone to understand what i'm trying to do is to show some code.
Here is my KeyCode enumeration (or part of it):
public enum KeyCode
{
#if DRIVER_TYPE_OPENGL
A = 83,
B = 84
#elif DRIVER_TYPE_DRIECTX
A = 65,
B = 66
#endif
}
At the top of my OpenGL Window class, I have done this:
#define DRIVER_TYPE_OPENGL
and at the top of my DirectX Window class, I have done this:
#define DRIVER_TYPE_DRIECTX
From what I understand, I should now be able to do something like this:
IDisplay display = new OpenGLDisplay(WIDTH, HEIGHT, TITLE);
while (true)
{
// Do stuff with display
// Process input like so:
if (Keyboard.IsKeyDown(KeyCode.A))
{
Console.WriteLine("You're using OpenGL driver, good on you!")
}
// Swap buffers and stuff
}
display.Close();
But instead, I get an error saying: "KeyCode does not contain a definition for 'A'"
What am I doing wrong?
Thanks in advance for any help!