Sign in to follow this  
  • entries
    102
  • comments
    146
  • views
    79726

IRenderer

Sign in to follow this  
Black Knight

355 views

So I added a IRenderer class and derived 2 classes from it an OGLRenderer and a D3DRenderer.Things are looking fine for now.I'll continue to work on it tomorrow its late now and my wife is calling me :]


#ifndef __IRENDERER_H__
#define __IRENDERER_H__

#ifdef _WIN32
#include
#endif

#include "Camera.h"

//Base renderer class interface
class IRenderer
{
protected:
Camera* m_pCamera;
float m_fFarClip;

public:
IRenderer():m_pCamera(NULL),m_fFarClip(200.0f){}
virtual ~IRenderer(){destroy();}

virtual void clear()=0;
virtual bool create(const HWND& hWnd,BYTE byColorBits,
BYTE byDepthBits,
BYTE byStencilBits,
bool bFullScreen=false,
int iWidth=800,
int iHeight=600)=0;
virtual void destroy();
virtual void startFrame(unsigned int bits,int* pTrianglesDrawn)=0;
virtual void endFrame(const HDC* hDC)=0;
virtual void resizeViewport(int xPos,int yPos,int iWidth,int iHeight)=0;
virtual void setCurrent(const HDC* hDC)=0;
virtual bool createCamera();

//data access
Camera* getCamera()const{return m_pCamera;}
void setFarClip(float fFarClip){m_fFarClip = fFarClip;}
float getFarClip()const{return m_fFarClip;};

};

///D3D Renderer
#ifndef __D3DRENDERER_H__
#define __D3DRENDERER_H__

#include "..\IRenderer.h"
#include
#include

class D3DRenderer : public IRenderer
{
private:
IDirect3D9* m_pD3D;
IDirect3DDevice9* m_pD3DDevice;
D3DPRESENT_PARAMETERS m_D3DPP;
D3DFORMAT m_D3DFormat;
HRESULT m_DeviceStatus;

public:
D3DRenderer():m_pD3D(NULL),m_pD3DDevice(NULL){}
~D3DRenderer(){destroy();}

void clear();
bool create(const HWND& hWnd,
BYTE byColorBits,
BYTE byDepthBits,
BYTE byStencilBits,
bool bFullScreen=false,
int iWidth=800,
int iHeight=600);
void destroy();
void startFrame(unsigned int bits,int* pTrianglesDrawn);
void endFrame(const HDC* hDC);
void resizeViewport(int xPos,int yPos,int iWidth,int iHeight);
void setCurrent(const HDC* hDC);

//D3DRenderer Specific methods
HRESULT resetDevice(int iWidth,int iHeight,D3DFORMAT *pFormat);

};


#endif //__D3DRENDERER_H__



//OGL




#endif //__IRENDERER_H__



Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now