Problems with my DirectX program

This is a discussion on Problems with my DirectX program within the Game Programming forums, part of the General Programming Boards category; My DirectX program doesn't work. It gives me no errors, but if I run it, it gives me errors. What's ...

  1. #1
    Registered User
    Join Date
    Aug 2006

    Problems with my DirectX program

    My DirectX program doesn't work. It gives me no errors, but if I run it, it gives me errors. What's wrong with it?

    I do not write my mywin.h and basic.h here, because they are not important and work correctly. Procedures from those header files are Logi, MkWin and ReggWin and TPump, so do not be confused of them, just ignore them.

    My code is here:


    #define WIN32_LEAN_AND_MEAN
    #include <D3d9.h> 
    #include "mywin.h"
    #include "basic.h"
    #pragma comment(lib,"User32.lib") 
    #pragma comment(lib, "d3d9.lib") 
    WNDPROC wndProc; 
    HINSTANCE hInstance; 
    HWND _hwnd;
    HRESULT hr;
    IDirect3D9 *g_D3D=NULL;
    D3DFORMAT format=D3DFMT_R5G6B5;
    IDirect3DDevice9 *p_device=NULL;
    char logi_name []= "error.txt";
    char className [] = "WinClass";
    char const caption [] = "Window";
    int width=500;
    int height=500;
    int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrevInst, char * cmdParam, int cmdShow)
    //Registrating window class.
    hr=ReggWin (wndProc, className, hInst);
    Logi("Error, can't regg window class.",logi_name);
    //Making Window.
    hr=MkWin (caption, className, hInst, _hwnd, cmdShow, width, height);
    Logi("Error, can't create window.",logi_name);
    //Creating DirectX object
    g_D3D = Direct3DCreate9( D3D_SDK_VERSION);
    Logi("Error, can't create DirectX device.", logi_name);
    pp.BackBufferCount= 1; //We only need a single back buffer
    pp.MultiSampleType=D3DMULTISAMPLE_NONE; //No multi-sampling
    pp.MultiSampleQuality=0; //No multi-sampling
    pp.SwapEffect = D3DSWAPEFFECT_DISCARD; // Throw away previous frames, we don't need them
    pp.hDeviceWindow=_hwnd; //This is our main (and only) window
    pp.Flags=0; //No flags to set
    pp.FullScreen_RefreshRateInHz=D3DPRESENT_RATE_DEFAULT; //Default Refresh Rate
    pp.PresentationInterval=D3DPRESENT_INTERVAL_DEFAULT; //Default Presentation rate
    pp.BackBufferFormat=format; //Display format
    pp.EnableAutoDepthStencil=FALSE; //No depth/stencil buffer
    pp.Windowed = TRUE;
    hr=g_D3D->CreateDevice(D3DADAPTER_DEFAULT, //The default adapter, on a multi-monitor system
    //there can be more than one.
    D3DDEVTYPE_HAL, //Use hardware acceleration rather than the software renderer
    //Our Window
    //Process vertices in software. This is slower than in hardware,
    //But will work on all graphics cards.
    //Our D3DPRESENT_PARAMETERS structure, so it knows what we want to build
    //This will be set to point to the new device
    Logi("Error, can't create DirectX device.", logi_name);     //I get this error message!
    //Message pump
    //Destroying DirectX object
    LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    switch (message) {
    case WM_DESTROY:
    PostQuitMessage (0);
    return 0;
    return DefWindowProc (hwnd, message, wParam, lParam );

  2. #2
    Registered User
    Join Date
    May 2006
    ... What are the errors it gives you ? That's important, you know.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Blackjack program, having problems with the ace
    By yigster in forum C Programming
    Replies: 6
    Last Post: 05-07-2009, 07:41 AM
  2. Replies: 19
    Last Post: 05-30-2007, 06:47 PM
  3. Problems with my c letter count program
    By cram55 in forum C Programming
    Replies: 10
    Last Post: 05-30-2007, 05:10 AM
  4. Program calculation problems?
    By rebel in forum C++ Programming
    Replies: 7
    Last Post: 11-28-2005, 03:31 PM
  5. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 12:39 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21