Archived

This topic is now archived and is closed to further replies.

A dumb question

This topic is 5777 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

This is probably a dumb question, but I''m trying to modify the d3d Tutorial 1. sample from the DX 8.1 SDK to work in full-screen, and I don''t know how to do it. I have highlighted the changes that I''ve made to the sample code below. Thanks for help. INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, INT ) { // Register the window class WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, "D3D Tutorial", NULL }; RegisterClassEx( &wc ); // Create the application''s window HWND hWnd = CreateWindow( "D3D Tutorial", "D3D Tutorial 01: CreateDevice", WS_EX_TOPMOST, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), NULL, NULL, wc.hInstance, NULL ); // Initialize Direct3D if( SUCCEEDED( InitD3D( hWnd ) ) ) { // Show the window ShowWindow( hWnd, SW_SHOWDEFAULT ); UpdateWindow( hWnd ); // Enter the message loop MSG msg; while( GetMessage( &msg, NULL, 0, 0 ) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); } } ... Here''s InitD3D() : HRESULT InitD3D( HWND hWnd ) { // Create the D3D object, which is needed to create the D3DDevice. if( NULL == ( g_pD3D = Direct3DCreate8( D3D_SDK_VERSION ) ) ) return E_FAIL; // Get the current desktop display mode D3DDISPLAYMODE d3ddm; if( FAILED( g_pD3D->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &d3ddm ) ) ) return E_FAIL; // Set up the structure used to create the D3DDevice. D3DPRESENT_PARAMETERS d3dpp; ZeroMemory( &d3dpp, sizeof(d3dpp) ); d3dpp.Windowed = FALSE; // -If I set this to FALSE // and try to run the program // nothing happens. When this // is TRUE I only get a // full-screen window // (which is not what I want). d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferFormat = d3ddm.Format; // Create the Direct3D device. if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &g_pd3dDevice ) ) ) { return E_FAIL; } // Device state would normally be set here return S_OK; }

Share this post


Link to post
Share on other sites
try this and replace the windowed = false;

  
d3dpp.Windowed = FALSE;
d3dpp.BackBufferWidth = g_width;
d3dpp.BackBufferHeight = g_height;
d3dpp.BackBufferFormat = D3DFMT_R5G6B5;
//or try D3DFMT_X1R5G5B5 but usually the bufferformat is the other one.



letting g_width and g_height be your window dimensions. I''m pretty sure because your not setting the window dimensions correctly it my be pooping out on you.

I hope that helps...



-Pac
"The thing I like about friends in my classes is that they can''t access my private members directly."
"When listening to some one tell about their problem (whether it''s code or not), don''t listen to what went right or wrong, but what they assumed....."

Share this post


Link to post
Share on other sites
I suggest taking a peek at the d3d sdk samples. They all use the d3d framework classes. It shouldnt be hard to modify one of those samples and modify it to your needs. This way you get the whole enchilada of window/fullscreen, device type etc. handling code for free and can focus on the actual problem.

HTH

Share this post


Link to post
Share on other sites
The stuff your missing is the fullscreen parameters, try this.

d3dpp.BackBufferWidth = d3ddm.Width;
d3dpp.BackBufferHeight =d3ddm.Height;
d3dpp.FullScreen_PresentationInterval=PRESENT_INTERVAL_DEFAULT ;d3dpp.FullScreen_RefreshRateInHz =d3ddm.RefreshRate;

Share this post


Link to post
Share on other sites
>>I''m trying to modify the d3d Tutorial 1. sample from the DX 8.1 SDK to work in full-screen

>> When this is TRUE I only get a full-screen window (which is not what I want).

What DO you want, then?

All this sample does is it creates a D3D device. It does not render anything on the screen. So if you modify it to do fullscreen, I would expect a blank window. What do you expect?

Also, install/switch to debug DX runtimes and set debug level to maximum. This will greatly help you in finding DX-related bugs.

As for D3D framework: I didn''t use them from the beginning, because they had too much new stuff at once. Tutorials start simple and add one bit of functionality at a time. Framework, on the other hand, throws everything at you. I don''t use it now because I need more control over windows, devices, etc., and also because I use MFC and my own wrapper classes to throw exceptions from HRESULTs. However, I did take code out of them, modifying it to suit my needs (ie: display mode enumeration, timer function).

Share this post


Link to post
Share on other sites
What I meant was that if d3dpp.Windowed is true, I get a Windows window that can be moved around. I wanted a "real" full-screen that didn''t have any those things that normal Windows windows have.

Well, anyway, I got it working now.

Thanks for helping me out!

Share this post


Link to post
Share on other sites