Jump to content
  • Advertisement
Sign in to follow this  
exgex

game engine help

This topic is 3878 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!