Archived

This topic is now archived and is closed to further replies.

Universal type for backbuffer?

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

Is it possible to have a global pointer as backbuffer ... as opposed to a SDL surface? A function would return different types ... depending on what render device the user wants. For example SDL or D3D Surfaces. In other words ... is there an universal type?

Share this post


Link to post
Share on other sites
No, there is no directly available basic type. However, you can create one yourself using polymorphism. It''s done in two steps :
1° Decide all things the basic type should be able to do (like, resizing, reading, writing, blitting, displaying, etc...), and create a basic class that has pure virtual functions to do these things.
2° For each API (OpenGL, Direct3d, SDL) you want to support, create a class that is inherited from the base class, and set the virtual functions for these classes so that they work correctly.
(For information about polymorphism and virtual functions, check any good C++ website or book)

Victor Nicollet, INT13 game programmer

Share this post


Link to post
Share on other sites
Seeing that you''re a beginner, however (for posting in the beginners forum), I would strongly advise you NOT to try and use multiple APIs. Learning and using even one is a straining and long task even for a professional, so I think you''d be better off by using one for a couple games before moving on.

Victor Nicollet, INT13 game programmer

Share this post


Link to post
Share on other sites
"so I think you''d be better off by using one for a couple games before moving on"
Sooo true

I used the architecture of a gamemanager and turned it into a rendermanager.
It does compile and at least Initializing SDL and a Function MouseBlit work like that:
RENDERMANAGER->Initialize();
RENDERMANAGER->MouseBlit();
Right now there is only one RenderChoice.

But there are small bugs that I can''t possibly find because I don''t understand the whole thing.
For example the mouse pointer appears when I move the mouse.
I''ve been able to fix it in the SDL only application. But not in the new one.

Still I think I got something out of trying to do it.
Now back to SDL only ...

Share this post


Link to post
Share on other sites