Jump to content
  • Advertisement
Sign in to follow this  
Crypter

Engine--Video/Graphics help!

This topic is 4835 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

Hey everyone! Its been awhile sence I posted here, but am planning on posting more often. Anyway, Im developing a cross-platform 2d RPG game engine. I want the engine to easily support multiple APIs, like DX and OGL. I want to seperate my rendering code from the APIs. Here is the layout..
class _ISurface
{
// How should I handle surfaces???
// should I make this a base class, so I could
// derive _ISurfaceDX, _ISurfaceOGL, etc.?
// Is there a better method??
};

class _IRenderer
{
    _SVideoMode mode;

public:
    virtual int Initialize (void* args) =0;
    virtual void Shutdown () =0;
    virtual int BeginRender () =0;
    virtual int EndRender () =0;
};
I have two questions.. How should I handle primitive drawing algorithms? ie; where should I put DrawPixel(), DrawLine() etc.? I was thinking in _ISurface, but the actual implimentations are API specific. And my biggest problem.. How should I handle surfaces? I was thinking of another virtual base class, but is that a good idea..? Please share your opinions on design/layout/code etc. Anything that wil help me!! ps; Is there anyway to change my regestration name? Thanks alot!

Share this post


Link to post
Share on other sites
Advertisement
Theres GOT to be someone here who can help!

Basically, I am looking for a way to manage
textures/surfaces, and how to handle them
in my engine..While providing portibility
with DirectX/OpenGL/and othe APIs.

Please help!

Share this post


Link to post
Share on other sites
I wrap my resources with handles. A handle is defined by the core library (system independent) and is just an integer. That integer is used as a lookup value into the system dependent's specific texture manager. When you request a texture, you're given a handle. When you switch textures, you specify a handle.

For rendering, I provide an interface (IGraphics) with methods like SetTexture(TextureHandle handle) and DrawSprite(Rectangle imageSource, Point position). The system dependent renderers derive from this interface.

Share this post


Link to post
Share on other sites
I'd recommend taking a look at the source of another similar open-source engine. In particular, I work with Irrlicht quite a bit and it seems to me to have a pretty good design interface for the most part. For the particular area you mentioned, Irrlicht's solution is quite similar to what you posted: basically, it has different APIs that it works with behind the scenes, but all the end programmer sees is a call to createIrrlichtDevice(API, size, etc). createIrrlichtDevice() returns the base interface IrrlichtDevice, which during actual execution will be a D3DDevice (public IrrlichtDevice) or a OGLDevice (public IrrlichtDevice). Polymorphism is an excellent way of implementing this type of functionality.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!