How can I use DirectX for creating a windowed application?
To create a windowed application using the Direct3D API set of DirectX, you have to first create a device to access your display adapter/graphics card. First of all, create a Direct3D Object and then set a presentation parameter structure that contains the details of your window (like whether it is a windowed/full screen one, it's back buffer format etc).Then create the Direct3D device from the Direct3D object using this presentation parameter structure. The sample application "DirectXApp.zip" shows how to use Direct3D to access a window. By making changes to the presentation parameter structure "d3dpp" in "DirectXApp.zip" you can switch between windowed/full screen modes!
For Window
/* Presentation parameter structure is used to create the D3D Device */
D3DPRESENT_PARAMETERS d3dpp;
/* We have to first zero out the structure to set the necessary elements only */
ZeroMemory( &d3dpp, sizeof(d3dpp) );
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.Windowed = TRUE; /* To get a windowed display */
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
/* Then create the device using d3dpp */
For Fullscreen
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory( &d3dpp, sizeof(d3dpp) );
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.Windowed = FALSE;
/* The Width you want or GetSystemMetrics(SM_CXSCREEN) to get the desktop Width*/
d3dpp.BackBufferWidth = 800;
/* The Height you want or GetSystemMetrics(SM_CYSCREEN) to get the desktop Height*/
d3dpp.BackBufferHeight= 600;
/*You can specify better formats if your card supports it*/
d3dpp.BackBufferFormat = D3DFMT_R5G6B5;
/* Then create the device using d3dpp */
FAQ Menu
Sponsored links
SFTP components for .NET
Add complete SSH and SFTP support to your .NET framework application
Add complete SSH and SFTP support to your .NET framework application
3 Months Free - ASP.NET Web Hosting
3 Months Free & No Setup Fees on ASP.NET 3.5/2.0 Hosting on Windows 2008/2003 Servers ? Click Here!
3 Months Free & No Setup Fees on ASP.NET 3.5/2.0 Hosting on Windows 2008/2003 Servers ? Click Here!
PureCM Software Configuration Management
Version control and integrated issue tracking - powerful and easy to use. Get your FREE trial now!
Version control and integrated issue tracking - powerful and easy to use. Get your FREE trial now!
Virtual File System SDK
Create your own file systems in Windows and .NET applications
Create your own file systems in Windows and .NET applications
CSTSOFT Instrumentation .NET & ActiveX Components
A collection of 13 instrumentation .NET/ActiveX/VCL components including Gauge,Knob,LED,Trend etc.
A collection of 13 instrumentation .NET/ActiveX/VCL components including Gauge,Knob,LED,Trend etc.
