c++ - DirectX 9 window doesnt show -


I am trying to create a simple DirectX 9 program that creates a windowed window window and shows it (anything No window yet) When I compile the program, I do not get any errors. When I run the program, the window does not look and the program ends I

  / * * To create a Window Direct window with a simple DirectX 9 program that has nothing ready on it . There was no error during compiling or running, but a window * spread and the program almost stopped immediately. Include * / # & lt; Windows.h & gt; # Include & lt; D3d9 h & gt; # Include & lt; Time.h> # Include & lt; Iostream & gt; using namespace std; // Program Settings: CONST STRATT APPTITLE = "Direct 3D_Windered"; Const int SCREENW = 1024; Const int SCREENH = 768; // DIRECT 3D Object LPDIRECT3D9 d3d = NULL; LPDIRECT3DDEVICE9 d3ddev = NULL; Bull GamesNow = False; // Macro key press #define KEY_DOWN (vk_code) ((GetAsyncKeyState (vk_code) and 0x8000) 1: 0) * * Game initialization function * / bool Game_Init (HWND window) {// init Direct3D d3d = Direct3DCreate9 (D3D_SDK_VERSION); If (D3 == tap) {return 0; } // Set Direct3D Presentation parameter D3DPRESENT_PARAMETERS d3dpp; Zoramori (& amp; d3dpp, sizeoff (d3ppp)); D3dpp.Windowed = TRUE; D3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; D3dpp.BackBufferFormat = D3DFMT_X8R8G8B8; D3dpp.BackBufferCount = 1; D3dpp.BackBufferWidth = SCREENW; D3dpp.BackBufferHeight = SCREENH; D3dpp.hDeviceWindow = window; // Create Direct 3D Device D3- gt; CreateDevice (D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, window, D3DCREATE_SOFTWARE_VERTEXPROCESSING, & amp; d3dpp, & amp; d3ddev); If (d3ddev == NULL) {return 0; } Back true; } / * * Game update function * / Zero game_run (hwnh hwd) {// Ensure that direct 3D device is valid (! D3 DDV) {return; } // Clear the backbuffer with bright green color d3ddev- & gt; Clear (0, tap, D3, DclierTagert, D3 decolor_XRGB (0, 255, 0), 1.0 F, 0); // Getting Started If Started (d3ddev-> Beginners Sense ()) {// Have to do something? // Stop Rendering d3ddev- & gt; Endsen (); // Copy buffer back to the screen d3ddev-> Present (zero, zero, zero, zero); } // Check Escape key (to exit program) if (KEY_DOWN (VK_ESCAPE)) {PostMessage (hwnd, WM_DESTROY, 0, 0); }} / * * Game shutdown function * / zero game_and (hwnd hwd) {// if the storage is free (D3DVV) {d3ddev- & gt; Release (); } If (D3D) {d3d-> Release (); }} / * * Windows event handling function * / LRESULT WINAPI winproc (HWND hWnd, uint message, wParam wParam, lParam lParam) {switch (MSG) {case WM_DESTROY: GAMEOVER = true PostQuitMessage (0); Return 0; } Return DefWindowProc (hWnd, msg, wParam, lParam); } / * * Main Windows login function * / int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, integer NCmdShow) WNDCLASSEX WC set the properties {// new window; Wc.style = CS_HREDRAW | CS_VREDRAW; Wc.lpfnWndProc = (WNDPROC) WinProc; Wc.cbClsExtra = 0; Wc.cbWndExtra = 0; Wc.hInstance = hInstance; Wc.hIcon = NULL; Wc.hCursor = LoadCursor (NULL, IDC_ARROW); Wc.hbrBackground = (HBRUSH) GetStockObject (BLACK_BRUSH); Wc.lpszMenuName = NULL; Wc.lpszClassName = APPTITLE.c_str (); Wc.hIconSm = NULL; RegisterClassEx (& amp; WC); // a new window HWND window = CreateWindow (APPTITLE.c_str (), // window class APPTITLE.c_str (), // title bar // create full-screen mode // WS_EX_TOPMOST | WS_VISIBLE | WS_POPUP, // windowed mode WS_OVERLAPPEDWINDOW, / / window style CW_USEDEFAULT, // X window CW_USEDEFAULT conditions, // Y position, // window width 480 of window 640, // window height of zero, // parent window zero, // menu hInstance, // Application instance tap); // Window Parameters // Did there was an error in creating windows? If (window == 0) {return 0; } // show window ShowWindow (window, NCMD show); UpdateWindow (window); // Start the game if (! Game_Init (window)) {return 0; } // main message loop MSG message; While (! GameOver) {if (Picommasej (and message, translated message zero, 0, 0, Pimaimowwv)) {(& message); DispatchMessage (& amp; Message); } Game_Run (window); } Game_and (window); Return message. }    

If you set the properties of the window, you must set cbSize member.

  wc.cbSize = sizeof (WNDCLASSEX);    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -