• Advertisement

Archived

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

Help with my graphics component

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

I'm making a modular engine for all of my games. I'll show you the structure:
  
                          CEngine
                           / |                           /  |                           /   |                           /    |                       CAudio CWindow CInput
                             |
                         CGraphics
                            /                       COpenGL CDirect3D
  
Come to think of it, it looks like a stick figure. But what I'm having trouble with is the CGraphics component. I don't know what to do with it. As I see it, I have to options: - Option #1: Put a function in CGraphics to select the API to use. From then on, for all of the functions, use a pointer pointing to the selected API for all of the calls.
  
class CGraphics
{
    void SelectAPI(int API)
    {
       if(API==0) { m_pRenderer = &CDirect3D; }
       if(API==1) { m_pRenderer = &COpenGL; }
    }

    int Create(int blah)
    {
        m_pRenderer->Create(blah);
    }
  
- Option #2: Make CGraphics an abstract class, so the user would make a pointer of CGraphics and simply point it to either API and call all of the functions from there.
  
CGraphics *pGraphics = &CDirect3D;

pGraphics->Create(blah);
  
I am leaning toward Option #2, but what do you think? Thanks for your consideration! [edited by - elendil67 on December 1, 2002 2:45:37 PM]

Share this post


Link to post
Share on other sites
Advertisement
Sorry about the structure . Heres the structure

CEngine
|
CWindow, CInput, CAudio
|
CGraphics
|
CDirect3D, COpenGL

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
What is CGraphics supposed to do?

Share this post


Link to post
Share on other sites
Well, nothing really. Its just supposed to be something that you can select your API with and call the API''s functions through.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
What do you mean "call the API''s functions through"?

Write wrappers for both OpenGL and Direct3D?

Share this post


Link to post
Share on other sites

  • Advertisement