------

[ AD ] Port Monitor ( Try to use a Best WebSite Monitoring Tool )

------
Lesson Overview
 

Making your game fullscreen is easy, but requires changing a few details of the program,

as well as adding a couple lines of code.

 

In this lesson we will cover two things. 

First, we will go over how to globalize your screen resolution and why you would do this.  Second, we'll cover the mechanics of making a window go into fullscreen mode.

 

Setting Up the Screen Size 


// define the screen resolution
#define SCREEN_WIDTH  800
#define SCREEN_HEIGHT 600

 

 

 hWnd = CreateWindowEx(NULL,
                          L"WindowClass",
                          L"Our Direct3D Program",
                          WS_OVERLAPPEDWINDOW,
                          300, 300,
                          SCREEN_WIDTH, SCREEN_HEIGHT,   

                          NULL,
                          NULL,
                          hInstance,
                          NULL);



Changing to Fullscreen Mode


hWnd = CreateWindowEx(NULL,
                          L"WindowClass",
                          L"Our Direct3D Program",
                          WS_EX_TOPMOST | WS_POPUP,    // fullscreen values
                          0, 0,    // the starting x and y positions should be 0
                          SCREEN_WIDTH, SCREEN_HEIGHT,
                          NULL,
                          NULL,
                          hInstance,
                          NULL);

 

Next, we have to tell DirectX about our new screen resolution. 

We do this by making a few changes to the d3dpp struct we built in the last
lesson. 

Let's look at what they are before we see what they do.


D3DPRESENT_PARAMETERS d3dpp;    // create a struct to hold various device information

ZeroMemory(&d3dpp, sizeof(d3dpp));    // clear out the struct for use
d3dpp.Windowed = FALSE;    // program fullscreen, not windowed
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;    // discard old frames
d3dpp.hDeviceWindow = hWnd;    // set the window to be used by Direct3D
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;  //set the back buffer format to 32-bit
d3dpp.BackBufferWidth = SCREEN_WIDTH;    //set the width of the buffer
d3dpp.BackBufferHeight = SCREEN_HEIGHT;   //set the height of the buffer

'온라인게임 > DirectX' 카테고리의 다른 글

SlimDX  (0) 2010.10.07
Direct 3D Basics  (0) 2010.09.03

+ Recent posts