Advertisement Jump to content
Sign in to follow this  

Arghhh : ( Directx CreateDevice

This topic is 4936 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 a really really strange problem so if anyone can see why this code is giving me errors when running this code shall run good what i know and the projects i made earlier runs gr8 and creates the D3D DEVICE but now i cant even CREATE A DEVICE :'(
#include <windows.h>
#include <d3dx9.h>

    LPDIRECT3D9 d3d;
   LPDIRECT3DDEVICE9 graphDevice;   

/*  Declare Windows procedure  */

/*  Make the class name into a global variable  */
char szClassName[ ] = "WindowsApp";

int WINAPI WinMain (HINSTANCE hThisInstance,
                    HINSTANCE hPrevInstance,
                    LPSTR lpszArgument,
                    int nFunsterStil)

    HWND hwnd;               /* This is the handle for our window */
    MSG messages;            /* Here messages to the application are saved */
    WNDCLASSEX wincl;        /* Data structure for the windowclass */

    /* The Window structure */
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */ = CS_DBLCLKS;                 /* Catch double-clicks */
    wincl.cbSize = sizeof (WNDCLASSEX);

    /* Use default icon and mouse-pointer */
    wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
    wincl.lpszMenuName = NULL;                 /* No menu */
    wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
    wincl.cbWndExtra = 0;                      /* structure or the window instance */
    /* Use Windows's default color as the background of the window */
    wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;

    /* Register the window class, and if it fails quit the program */
    if (!RegisterClassEx (&wincl))
        return 0;

    /* The class is registered, let's create the program*/
    hwnd = CreateWindowEx (
           0,                   /* Extended possibilites for variation */
           szClassName,         /* Classname */
           "Windows App",       /* Title Text */
           WS_OVERLAPPEDWINDOW, /* default window */
           CW_USEDEFAULT,       /* Windows decides the position */
           CW_USEDEFAULT,       /* where the window ends up on the screen */
           544,                 /* The programs width */
           375,                 /* and height in pixels */
           HWND_DESKTOP,        /* The window is a child-window to desktop */
           NULL,                /* No menu */
           hThisInstance,       /* Program Instance handler */
           NULL                 /* No Window Creation data */

    /* Make the window visible on the screen */
    ShowWindow (hwnd, nFunsterStil);

   HRESULT res;
   d3d = Direct3DCreate9( D3D_SDK_VERSION );
   ZeroMemory( &params, sizeof(params) );
   params.SwapEffect = D3DSWAPEFFECT_DISCARD;
   params.BackBufferCount = 1; 
   params.hDeviceWindow = hwnd;
   params.Windowed = true;
   params.BackBufferFormat = D3DFMT_UNKNOWN;
   //params.EnableAutoDepthStencil = false;
   //params.AutoDepthStencilFormat = D3DFMT_D16;

      MessageBox(hwnd,"no hardware vertex","",0);                                                         
      res = d3d->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hwnd,
      if (res = D3DERR_INVALIDCALL) MessageBox(hwnd,"big error","",0);


    /* Run the message loop. It will run until GetMessage() returns 0 */
    while (GetMessage (&messages, NULL, 0, 0))
        /* Translate virtual-key messages into character messages */
        /* Send message to WindowProcedure */

    /* The program return-value is 0 - The value that PostQuitMessage() gave */
    return messages.wParam;

/*  This function is called by the Windows function DispatchMessage()  */

LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    switch (message)                  /* handle the messages */
        case WM_DESTROY:
            PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
        default:                      /* for messages that we don't deal with */
            return DefWindowProc (hwnd, message, wParam, lParam);

    return 0;

how to make the script into a little scroll window??? thx hunter_ex [Edited by - Hunter_Ex on July 18, 2005 7:19:18 PM]

Share this post

Link to post
Share on other sites
Whats the error?
pAdapterInfo is of type D3DAdapterInfo. Lookup how to set it up if ya need it.

params.BackBufferWidth = 544;
params.BackBufferHeight = 375;
params.BackBufferFormat = pAdapterInfo->d3ddmDesktop.Format;

Hope this helps.

Share this post

Link to post
Share on other sites
the error is that i get D3DERR_INVALIDCALL on createDevice : (

that shall not happen ive made alot of d3d apps
something strange has happen

the D3DFMT_UNKNOWN / i tryed replace it with screen.Format;

but with no succes

plzz help

Share this post

Link to post
Share on other sites
First, use [source][/source] to get a white syntax-highlighted box with a scrollbar, or [code][/code] to merely get a fixed-width font. (Beware, lines won't autowrap, and will make your post really wide if you have long lines.)

As for what's wrong, unfortunately I can't see anything offhand. But if you enable the debug version of the DirectX runtime, it might very likely tell you more about your problem. Should be in the DirectX properties found in the control panel. Go to the Direct3D tab in those settings, and you should be able to switch between the retail and debug version, and change the debug output level, in order to get more information on things that are occurring. Might help a lot.

Share this post

Link to post
Share on other sites
okay trough the debugger i found out that te window handle was "0x0"

but how can it be that if i create then window in the same event as i create the device in the time?? with the same window??

Share this post

Link to post
Share on other sites
ohh yea i got it to work

the problem was that the window i supplied was not correctly derived from the parent class so it used a 0x0 window witch causes crash


thanx for helping

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!