Hello all,
I'm having a little problem here with the Leadwerks engine. For now I've only used the Leadwerks engine in the main() function to test things and play around with it. Now, I wanted to make a simple demo with Classes and everything using Leo. So, I create a class which is supposed to be the class to hold the base of the application. It contains only an instance to the Engine class, creates the window, terminates it and run the main loop. Now, there is another class that holds other instances from other classes, such as the World class, Camera and Cube class. In the first class, a pointer to the second class is constructed and its "update" method is called, which is supposed to render the cube, the camera and update the world. But, the thing is that it doesn't work at all. Here is a more concrete example with some small code:
class Application
{
public:
Application();
~Application();
void init();
void release();
int run();
private:
Engine m_Engine;
Game* m_Game;
};
class Game
{
public:
Game();
~Game();
void init();
void release();
void run();
private:
World m_World;
Cube m_Cube;
Camera m_Camera;
};
*note that the two classes are in separate headers; it's only a small pseudo-code example.
This is only a simple example, but it shows exactly how I'm trying to do things: the Application class creates an Engine object and in the "run" function, starts the main loop. The "game" class is also instanced in the Application class, then, its "run" function is called as well in the Application's run method. Everything compiles, but when I run the thing, it just crashes. Microsoft Visual Studio C++ 2008 Express returns an unhandled exception at 0xthingy-thing in the application: Access violation reading location 0xI-don't-know.
My drivers are up to date, I ran several Leadwerks application before and when I put the World instance in the same class as the Engine one, it works fine. What's wrong? Why can't I separate Leadwerks components into several classes? The only thing I can do it to write a sort of interface for every functions in the engine, but that's a waste of time. There should be a way to use the engine's components in an OOP design, no? I could use the C style version of the engine and incorporate it in classes, but that would be re-writing LEO.
Thanks in advance for your answers.
EDIT:
I forgot to mention that, in our project, we are putting all of our classes in a specific DLL we're compiling relating to it's function, which means that, for example, if we have a toaster, a dinner table and an oven class, we would put it in the "kitchen" DLL to export to the main executable.