Jump to content
  • Advertisement

Archived

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

Corrosive

How do i set to Full Screen in DX9???

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

Hi, im new to DX programming and trying to test some stuff, just to learn how it works... Im trying to set DX9 to Full Screen but whe i set the D3DPRESENT_PARAMS.windowed to FALSE it dont show the window anymore, i cant use full screen scenes!!! Have tried some tests but none worked out... how can i accomplish this? I need an answer really fast because i have some University work to do and want to do it with DX stuff!!! thanks.

Share this post


Link to post
Share on other sites
Advertisement
I normally just don''t give an answer, as you usually should do a little research yourself.


ZeroMemory(&Parms,sizeof(D3DPRESENT_PARAMETERS));
Parms.Windowed=false;
Parms.SwapEffect=D3DSWAPEFFECT_FLIP;
Parms.FullScreen_RefreshRateInHz=D3DPRESENT_RATE_DEFAULT;
Parms.PresentationInterval=D3DPRESENT_INTERVAL_IMMEDIATE;
Parms.BackBufferFormat=Display.Format;
Parms.BackBufferWidth=Display.Width;
Parms.BackBufferHeight=Display.Height;
Parms.BackBufferCount=1;
Parms.EnableAutoDepthStencil=true;
Parms.AutoDepthStencilFormat=D3DFMT_D24S8;


The autoDepthStencilFormat (zBuffer) you can change to whatever you want.

Share this post


Link to post
Share on other sites
Thanks, and i can assure you that i was researching, just found a little strange it didnt worked because i was setting almost everything like you did, just one or two fields a little diferent but i will try that!!! thanks...

Share this post


Link to post
Share on other sites
It´s me again, it didnt work, i tried so many combinations already and it just refuse to show a window. The program executes and then just finalize withou showing any window. But if i set windowed to true it works? what im doing wrong? some configuration in parameters?

Share this post


Link to post
Share on other sites
How are you calling CreateDevice?

Do you turn on ZBuffering?

do you clear target and z buffer in your rendering call?

A lot of things ''could'' be wrong.

Share this post


Link to post
Share on other sites
I will put my sourcecode here:


HRESULT InitD3D( HWND hWnd )
{
// Create the D3D object, which is needed to create the D3DDevice.

if( NULL == ( g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
return E_FAIL;

// Set up the structure used to create the D3DDevice. Most parameters are

// zeroed out. We set Windowed to TRUE, since we want to do D3D in a

// window, and then set the SwapEffect to "discard", which is the most

// efficient method of presenting the back buffer to the display. And

// we request a back buffer format that matches the current desktop display

// format.

D3DPRESENT_PARAMETERS d3dpp; //Cria a estrutura para os parâmetros do Direct3D

ZeroMemory( &d3dpp, sizeof(d3dpp) ); //Zera a estrutura

d3dpp.Windowed = FALSE; //Define modo Janela como falso

//d3dpp.hDeviceWindow = hWnd; //Seta a janela do aplicativo

d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; //Sem efeitos Swap

d3dpp.BackBufferFormat = g_pDisplay.Format; //Define o formato de cores da resolução

d3dpp.BackBufferWidth = g_pDisplay.Width;
d3dpp.BackBufferHeight = g_pDisplay.Height;
d3dpp.BackBufferCount = 1;
d3dpp.EnableAutoDepthStencil=true;
d3dpp.AutoDepthStencilFormat=D3DFMT_D24S8;
d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT; //Define o refresh de atualização em Ful Screen

d3dpp.PresentationInterval=D3DPRESENT_INTERVAL_IMMEDIATE;

// Create the Direct3D device. Here we are using the default adapter (most

// systems only have one, unless they have multiple graphics hardware cards

// installed) and requesting the HAL (which is saying we want the hardware

// device rather than a software one). Software vertex processing is

// specified since we know it will work on all cards. On cards that support

// hardware vertex processing, though, we would see a big performance gain

// by specifying hardware vertex processing.

if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp, &g_pd3dDevice ) ) )
{
return E_FAIL;
}

//Enumerar os modos do adaptador, necessário para o modo Full-Screen

nmodes = g_pD3D->GetAdapterModeCount(D3DADAPTER_DEFAULT, D3DFMT_X8R8G8B8);

hr = g_pD3D->EnumAdapterModes(D3DADAPTER_DEFAULT, D3DFMT_X8R8G8B8, 1, &g_pDisplay);
if(FAILED(hr))
return E_FAIL;

g_pd3dDevice->SetRenderState(D3DRS_ZENABLE, TRUE );




//if( FAILED( g_pd3dDevice->CreateRenderTarget(800, 600, D3DFMT_R8G8B8, D3DMULTISAMPLE_NONE , NULL, FALSE, &g_pD3DSurface, NULL)))

// return E_FAIL;


if( FAILED( g_pd3dDevice->CreateVertexBuffer( 4*sizeof(CUSTOMVERTEX),
0, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &g_pVB, NULL ) ) )
return E_FAIL;

//Aloca memória para o buffer de vértices

VOID* pVertices;

if( FAILED( g_pVB->Lock( 0, // Fill from the start of

// the buffer.

sizeof(objetos), // Size of the data to

// load.

(void**)&pVertices, // Returned vertex data.

0 ) ) ) // Send default flags to

// the lock.

return E_FAIL;

memcpy( pVertices, objetos, sizeof(objetos) );
g_pVB->Unlock();





return S_OK;
}


and now my render function:


VOID Render(HWND hWnd)
{
if( NULL == g_pd3dDevice )
return;

//Aqui vai o código para inicializar o foco de teclado

if (lpdikeyboard) lpdikeyboard->Acquire();
hr = lpdikeyboard->GetDeviceState(sizeof(KBuff),(LPVOID) &KBuff);
if(FAILED(hr))
{
if(hr == DIERR_INPUTLOST)
lpdikeyboard->Acquire(); //se estiver perdido, tentar recuperar

}


if(KEYDOWN(KBuff, DIK_ESCAPE))
{
msg.message = WM_QUIT;
}

// Clear the backbuffer to a blue color

g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER , D3DCOLOR_XRGB(0,0,255), 1.0f, 0 );

// Begin the scene

if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
{
// Rendering of scene objects can happen here

g_pd3dDevice->SetStreamSource(0, g_pVB, 0, sizeof(CUSTOMVERTEX));
g_pd3dDevice->SetFVF(D3DFVF_CUSTOMVERTEX );
g_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2);

// End the scene

g_pd3dDevice->EndScene();
}

// Present the backbuffer contents to the display

g_pd3dDevice->Present( NULL, NULL, hWnd, NULL );
}


as you can see, my d3dpp.windowed is set to false.. this setting make the program simple do nothing, but if i set to true it works... why it isnt setting to FullScreen?

i will put my winmain function too only to assure that every point of my code to this problem can be viewed and it may help in a solution...


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_POPUP|WS_VISIBLE, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), NULL, NULL, NULL, NULL );

// Initialize Direct3D

if( SUCCEEDED( InitD3D( hWnd ) ) )
{
// Show the window

ShowWindow( hWnd, SW_SHOWDEFAULT );
UpdateWindow( hWnd );
SetFocus(hWnd);
hinst = wc.hInstance;
DI_Init(hWnd);
// Enter the message loop

ZeroMemory( &msg, sizeof(msg) );
while( msg.message!=WM_QUIT)
{

if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
else
Render(hWnd);
}
}

UnregisterClass( "D3D Tutorial", wc.hInstance );
return 0;
}


i hope you can figure out what is happening, because i looked in SDK documentation over and over to solve this problem and couldnt.. im new to DX programming so i could make a just noob mistake but want to know what it is... thanks!!!

Share this post


Link to post
Share on other sites
Um... Shouldn''t you call EnumAdapterModes to fill in your g_pDisplay structure BEFORE you use the g_pDisplay fields to initialize your d3dpp structure?

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!