Help with my graphics component

Started by
4 comments, last by elendil67 21 years, 4 months ago
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]
When you go homeTell them of us, and say:For your tomorrow,We gave our today.
Advertisement
Sorry about the structure . Heres the structure

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

When you go homeTell them of us, and say:For your tomorrow,We gave our today.
What is CGraphics supposed to do?
Well, nothing really. Its just supposed to be something that you can select your API with and call the API''s functions through.
When you go homeTell them of us, and say:For your tomorrow,We gave our today.
What do you mean "call the API''s functions through"?

Write wrappers for both OpenGL and Direct3D?
yup.

When you go homeTell them of us, and say:For your tomorrow,We gave our today.

This topic is closed to new replies.

Advertisement