School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 307,118 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,982 people online right now. Registration is fast and FREE... Join Now!




Initiation of DirectX failes

 

Initiation of DirectX failes, C++

FrozenSnake

5 Nov, 2009 - 12:47 PM
Post #1

D.I.C Regular
***

Joined: 30 Jul, 2008
Posts: 485



Thanked: 31 times
My Contributions
I try to split up my DirectX stuff and GUI stuff into two classes. It has come to the part where it compiles, but this snippet return false:
CODE
if(FAILED(pd3d->CreateDevice(D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL, hwnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp, &pd3dDevice)))
{
    MessageBox(NULL, "CD failed!", "Fatal error!", MB_OK);
    return false;
}
It is part of the class DxManager, I think it's the hwnd that fails. hwnd is part of the Gui class

Here is the Gui class
CODE
class Gui
{
public:
    Gui();
    virtual ~Gui();
    bool InitWindow(HINSTANCE hInstance);    
static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
protected:
    HINSTANCE    hInstance;
    HWND        hwnd;
private:
    int            width, height;
};
and here is the DxManager class
CODE
class DxManager : public Gui
{
public:
    DxManager();
    virtual ~DxManager();
    bool InitDirect3D();
    void StartRender();
    void StopRender();
    void CleanUp();
    void BlitToSurface();
private:
    bool fullscreen;
};


Anyone that can help me understand what is wrong?

*** EDIT ***
I used some breakpoints and found this (check attachments), If I comment the snippet at the beginning of the thread the app will run like it should without any errors. So I guess my guess about HWND was correct. It looks like it lose it's value, is it possible to make it keep it?

This post has been edited by FrozenSnake: 5 Nov, 2009 - 05:36 PM


Attached thumbnail(s)
Attached Image
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 01:35PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month