Sign in to follow this  

game engine help

This topic is 3666 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 have the following code which never fails to break at the commented line ie; hrd is always false
m_pD3D = Direct3DCreate9(D3D_SDK_VERSION);

ZeroMemory(&m_d3dpp, sizeof(m_d3dpp));
    m_d3dpp.Windowed = false;
    m_d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
    m_d3dpp.BackBufferCount = 1;
    m_d3dpp.hDeviceWindow = m_hWndMain;
    m_d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
    m_d3dpp.BackBufferWidth = m_dwWidth;
    m_d3dpp.BackBufferHeight = m_dwHeight;    
    m_d3dpp.EnableAutoDepthStencil = 1;

HRESULT hrd = m_pD3D->CreateDevice(D3DADAPTER_DEFAULT,
                      D3DDEVTYPE_HAL,
                      m_hWndMain,
                      D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                      &m_d3dpp,
                      &m_pDevice);

if(FAILED(hrd)) //error appears here
        MessageBox(NULL,"Unable to create device","Engine Error - DLL",0);

and the classes i have are
class D3XRenderDevice
{
protected:
HWND m_hWndMain; //main window
HWND m_hWnd[MAX_3DHWND]; //render window(s)
UINT m_nNumhWnd; //num of render-windows
UINT m_nActivehWnd; //active window
HINSTANCE m_hDLL; //the dll module
DWORD m_dwWidth; //duh
DWORD m_dwHeight; //duh
bool m_bWindowed; //windowed mode?
char m_chAdapter[256]; //graphics adapter name
FILE * m_pLog; //log file
bool m_bRunning; //duh
public:
D3XRenderDevice(void){};
virtual ~D3XRenderDevice(void){};
//==================
//Init/Release Stuff
//==================
virtual HRESULT Init(HWND,const HWND*,int,int,int,bool)=0;
virtual void Release(void)=0;
virtual bool IsRunning(void)=0;
//===============
//Rendering Stuff
//===============
virtual HRESULT UseWindow(UINT nHwnd)=0;
virtual HRESULT BeginRendering(bool bClearPixel,bool bClearDepth,bool bClearStencil)=0;
virtual void EndRendering(void)=0;
virtual HRESULT Clear(bool bClearPixel,bool bClearDepth,bool bClearStencil)=0;
virtual void SetClearColor(float fRed,float fGreen,float fBlue)=0;
};//class

typedef struct D3XRenderDevice *LPD3XRENDERDEVICE;

// This class is exported from the D3XD3D.dll
class D3XD3D : public D3XRenderDevice
{
public:
// TODO: add your methods here.
D3XD3D(HINSTANCE hDLL);
~D3XD3D(void);
D3XD3D *g_D3XD3D;
HRESULT Init(HWND,const HWND*,int,int,int,bool);
//interface functions
void Release(void);
bool IsRunning(void){return m_bRunning;}
HRESULT BeginRendering(bool,bool,bool);
HRESULT Clear(bool,bool,bool);
void EndRendering(void);
void SetClearColor(float,float,float);
HRESULT UseWindow(UINT hWnd);
private:
LPDIRECT3D9 m_pD3D;
LPDIRECT3DDEVICE9 m_pDevice;
LPDIRECT3DSWAPCHAIN9 m_pChain[MAX_3DHWND];
D3DPRESENT_PARAMETERS m_d3dpp;
D3DCOLOR m_ClearColor;
bool m_bIsSceneRunning;
bool m_bStencil;
//start the API
HRESULT Go(void);
//log
void Log(char*,...);
};

and im using the book "3D Game Engine Programming" as a reference, if that helps anyone ... thanks in advance

Share this post


Link to post
Share on other sites
The value of hrd should point you at least vaguely in the right direction. CreateDevice return values are as follows:

Quote:

If the method succeeds, the return value is D3D_OK. If the method fails, the return value can be one of the following: D3DERR_DEVICELOST, D3DERR_INVALIDCALL, D3DERR_NOTAVAILABLE, D3DERR_OUTOFVIDEOMEMORY.

Share this post


Link to post
Share on other sites
ok i found out its D3DERR_INVALIDCALL
but i have no idea why ...

EDIT:fixed, the depthbuffer format was missing
but now im faced with a very rapidly blinking screen

EDIT EDIT:fixed
im sorry
i didnt realise i was trying to clear a non existent depth and stencil buffer

[Edited by - exgex on December 5, 2007 8:23:20 AM]

Share this post


Link to post
Share on other sites

This topic is 3666 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.

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

Sign in to follow this