Sign in to follow this  

Problems implementing a model class into engine

This topic is 4543 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello All, I am having trouble organizing my engine code in an effecient manner. Right now my engine has an interface class in a static library and has two different implementations. One implementation for the OpenGL graphics library and another implementation for the Direct3D graphics library. Right now I am coding my model class and have decided to place it in the static library. However I just realized that there is a problem with doing this. I need to link to to two other libraries that are used for loading in the two model formats that I have chose for our engine. In my opinion, linking multiple static libraries to a static library which is subsequently linked to a DLL is a bad idea. Other than coding this model class outside of the engine workspace, are there any other ways of implementing it?

Share this post


Link to post
Share on other sites
This is interesting, I am doing the same thing in my engine where I am able to specify using opengl or directx for my renderer. Anyway, I'm not sure if this helps you, but I have it organized like this:

class DirectXRenderer : public BaseRenderer,public DirectXInterface
class OpenGLRenderer : public BaseRenderer,public OpenGLInterface

in my code I they specify which renderer to use by:
App::SetRender(RenderType type);

this I set my mainRenderer to either one, its a baseRenderer essentially, so I have generic functions I use in both, like for instance I have a function named:

virtual void BaseRenderer::Render() {};

in my directX class I render using the directXbuffer
in my opengl class I render using opengl vertex arrays, etc.

So its basically genericizing my rendering class to encapsulate both renders generically. Since your using seperate static libs, you could do the same thing but keep in mind your gonna have to make it generic so both classes will understand what you want to do without rewriting code.

JK

Share this post


Link to post
Share on other sites
Quote:
Original post by Thomas Mathers
Hello All,

I am having trouble organizing my engine code in an effecient manner. Right now my engine has an interface class in a static library and has two different implementations. One implementation for the OpenGL graphics library and another implementation for the Direct3D graphics library. Right now I am coding my model class and have decided to place it in the static library. However I just realized that there is a problem with doing this. I need to link to to two other libraries that are used for loading in the two model formats that I have chose for our engine. In my opinion, linking multiple static libraries to a static library which is subsequently linked to a DLL is a bad idea. Other than coding this model class outside of the engine workspace, are there any other ways of implementing it?


You can't link a static library to another (static or dynamic) library. A static library is a collection of compiled code pieces. It contains informations to help linking, but don't reference anything which is outside the lib (it also means that if you forgot to define a symbol, the compiler and the library builder won't tell it to you).

Of course, using VS terminology, you can build a library that depends on another library, but this dependency is here to ensure that the build order will be correct (it do not do anything else).

If you create a DLL or an EXE (they are basically the same thing under Windows. The entry point and the stub is different, but the file structure is the same), you'll have to link with all the used libraries - therefore I don't see your solution as a bad one.

HTH,

Share this post


Link to post
Share on other sites

This topic is 4543 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this