   Full screen mode not working
  Hi all, I'm working my way through Jonathan Harbour's Beginning Game Programming - everything was going great until I hit the end of chapter 5 - where you create a full screen window. The windowed mode worked fine but when I made the changes to the code and ran it in fullscreen mode all that happens is a white rectangle appears (it's size depends on the width and height parameters) and hitting escape does nothing. I also did the first part of chapter 6 which is supposed to have the moving rectangle around the window - but nothing... same white rectangle. I'm not getting any errors - anyone have any ideas?I should mention I have Vista - and fairly new computer (about a year old) - video card is gforce 8800... I guess I should insert the code...#include <d3d9.h>#include <time.h>#define APPTITLE "Direct3D_Windowed"#define SCREEN_WIDTH 1920#define SCREEN_HEIGHT 1200//keyboard stuff#define KEY_DOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0)#define KEY_UP(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0)LRESULT CALLBACK WinProc(HWND,UINT,WPARAM,LPARAM);ATOM MyRegisterClass(HINSTANCE);int Game_Init(HWND);void Game_Run(HWND);void Game_End(HWND);LPDIRECT3D9 d3d = NULL;LPDIRECT3DDEVICE9 d3ddev = NULL;LPDIRECT3DSURFACE9 backbuffer = NULL;LPDIRECT3DSURFACE9 surface = NULL;LRESULT WINAPI WinProc(HWND hWnd, UINT msg,WPARAM wParam, LPARAM lParam){switch (msg){case WM_DESTROY:Game_End(hWnd);PostQuitMessage(0);break;}return DefWindowProc(hWnd,msg,wParam,lParam);}ATOM MyRegisterClass(HINSTANCE hInstance){WNDCLASSEX wc;wc.cbSize = sizeof(WNDCLASSEX);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(WHITE_BRUSH);wc.lpszMenuName  = NULL;wc.lpszClassName = APPTITLE;wc.hIconSm  = NULL;return RegisterClassEx(&wc);}int WINAPI WinMain(HINSTANCE hInstance,    HINSTANCE hPrevInstance,   LPSTR lpCmdLine,    int nCmdShow){MSG msg;MyRegisterClass(hInstance);HWND hWnd;hWnd = CreateWindow(APPTITLE,APPTITLE,WS_EX_TOPMOST | WS_VISIBLE | WS_POPUP,CW_USEDEFAULT,CW_USEDEFAULT,SCREEN_WIDTH,SCREEN_HEIGHT,NULL,NULL,hInstance,NULL);if(!hWnd)return FALSE;ShowWindow(hWnd,nCmdShow);UpdateWindow(hWnd);int done = 0;while (!done){if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)){if (msg.message == WM_QUIT){MessageBox(hWnd,"Received WM_QUIT message", "WinMain", MB_OK);done = 1;}TranslateMessage(&msg);DispatchMessage(&msg);}elseGame_Run(hWnd);}return msg.wParam;}int Game_Init(HWND hwnd){HRESULT result;MessageBox(hwnd,"Program is about to start","Game_Init",MB_OK);d3d = Direct3DCreate9(D3D_SDK_VERSION);if(d3d == NULL){MessageBox(hwnd,"Error initalizing Direct3D","Error",MB_OK);return 0;}D3DPRESENT_PARAMETERS d3dpp;ZeroMemory(&d3dpp,sizeof(d3dpp));d3dpp.Windowed = FALSE;d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;d3dpp.BackBufferFormat = D3DFMT_R5G6B5;d3dpp.BackBufferCount = 1;d3dpp.BackBufferWidth = SCREEN_WIDTH;d3dpp.BackBufferHeight = SCREEN_HEIGHT;d3dpp.hDeviceWindow = hwnd;d3d->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hwnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&d3dpp,&d3ddev);if (d3ddev == NULL){MessageBox(hwnd,"Error creating Direct3D device","Error", MB_OK);}srand(time(NULL));d3ddev->Clear(0,NULL,D3DCLEAR_TARGET,D3DCOLOR_XRGB(0,0,0),1.0f,0);d3ddev->GetBackBuffer(0,0,D3DBACKBUFFER_TYPE_MONO,&backbuffer);result = d3ddev->CreateOffscreenPlainSurface(100,100,D3DFMT_X8R8G8B8,D3DPOOL_DEFAULT,&surface,NULL);if (!result)return 1;return 1;}void Game_Run(HWND hwnd){RECT rect;int r,g,b;if (d3ddev == NULL)return;d3ddev->Clear(0,NULL,D3DCLEAR_TARGET,D3DCOLOR_XRGB(0,255,255),1.0F,0);if (d3ddev->BeginScene()){r = rand() % 255;g = rand() % 255;b = rand() % 255;d3ddev->ColorFill(surface,NULL,D3DCOLOR_XRGB(r,g,b));rect.left = rand() % SCREEN_WIDTH/2;rect.right = rect.left + rand() % SCREEN_WIDTH/2;rect.top = rand() % SCREEN_HEIGHT;rect.bottom = rect.top + rand() % SCREEN_HEIGHT/2;d3ddev->StretchRect(surface,NULL,backbuffer,&rect,D3DTEXF_NONE);d3ddev->EndScene();}d3ddev->Present(NULL,NULL,NULL,NULL);//check for exitif (KEY_DOWN(VK_ESCAPE))PostMessage(hwnd,WM_DESTROY,0,0);}void Game_End(HWND hwnd){MessageBox(hwnd,"Program is about to end","Game_End",MB_OK);surface->Release();if (d3ddev != NULL)d3ddev->Release();if (d3d != NULL)d3d->Release();}
  Please post the topic onto the correct category.When you are fullscreen you can't read messages or see the debugger so the easy way is to work with two monitors.The fact that you don't get massages maybe is because you don't see it.   ;Quote:Original post by Koder4FunPlease post the topic onto the correct category.Which is? My difficulties are with Directx - this seemed like the right category... Anyone else have any ideas?;  In your WinMain function right before entering the main loop you forgot to call Game_Init.   ;Quote:Original post by Shadow WolfIn your WinMain function right before entering the main loop you forgot to call Game_Init.Thank You very much!! That was exactly the problem!   