PDA

View Full Version : Implementing abstract drawing surface and abstract picture



EricLang
01-01-2009, 09:43 PM
I want to make my gameengine (currently 2D) independent of HOW graphics are displayed. What could be the best way to handle this?
Currently I'm using the Graphics32 library and want to be able to implement an OpenGL or DirectX or whatever way to display the graphics.
I need some abstract classes or maybe interfaces to do that.
Any good ideas?

igel457
01-01-2009, 10:46 PM
Hi,

in my 2D graphics engine I built an abstraction layer using abstract classes. The abstraction layer represents a complete 3D rendering system. On the top of that I built another abstraction layer that does the 2D stuff. By simply exchanging the underlying 3D abstraction layer, the whole system runs with another graphics system.

Probably you might do the same for your project, but instead of building a 3D-layer (what is important for me, because the 3D-layer is very near to the hardware and therefore gives a maximum of flexibility), you might simply create abstract classes that cope with drawing 2D pictures.

You can have a look at the sources of my engine here:
http://andorra.cvs.sourceforge.net/viewvc/andorra/andorra/src/

AdClasses.pas contains the abstract class definitions, the files in the folder "dll" implement it (see D3DXMain.pas/OGLMain.pas).

I hope this helps you,
Andreas

noeska
02-01-2009, 07:55 AM
Since your maingoal seems to be 2D you may want to look at SDL.
You are then independen of os, as SDL is available on many os.
You should be able to find more info on SDL on this site.