Skip to main content
gamedev.net
🔒 Locked

Going fullscreen

Started by Marusu Jun 16, 2010 at 8:09 AM 3 replies 2k views
Original Post
Marusu
Marusu
Hello, I've tried to make a function for switching between fullscreen and windowed, but encoutered problems.
Code:
[source=c++]HRESULT CDirect3D::ChangeWindowMode(){	CWindow::ChangeWindowMode();	D3DPRESENT_PARAMETERS pp;	ZeroMemory(&pp, sizeof(pp));	RECT rc;	GetClientRect(m_hWindow, &rc);	//pp.AutoDepthStencilFormat = D3DFMT_D16;	//pp.BackBufferCount = 1;	//pp.BackBufferFormat = D3DFMT_UNKNOWN; // D3DFMT_UNKNOWN - Uses desktop bit depth.	//pp.BackBufferHeight = rc.bottom;	//pp.BackBufferWidth = rc.right;	//pp.EnableAutoDepthStencil = TRUE; // TRUE - Indicate that application manages depth buffers.	//pp.hDeviceWindow = m_hWindow;	//pp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; // D3DPRESENT_INTERVAL_ONE - monitors refresh rate in Hz, D3DPRESENT_INTERVAL_IMMEDIATE - maximum refresh rate.	//pp.SwapEffect = D3DSWAPEFFECT_DISCARD; // D3DSWAPEFFECT_DISCARD - allows video card to control swapping.	//pp.Windowed = FALSE;	pp.AutoDepthStencilFormat = D3DFMT_D16;	pp.BackBufferCount = 1;	pp.BackBufferFormat = D3DFMT_UNKNOWN; // D3DFMT_UNKNOWN - Uses desktop bit depth.	pp.EnableAutoDepthStencil = TRUE; // TRUE - Indicate that application manages depth buffers.	pp.hDeviceWindow = m_hWindow;	pp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; // D3DPRESENT_INTERVAL_ONE - monitors refresh rate in Hz, D3DPRESENT_INTERVAL_IMMEDIATE - maximum refresh rate.	pp.SwapEffect = D3DSWAPEFFECT_DISCARD; // D3DSWAPEFFECT_DISCARD - allows video card to control swapping.	pp.Windowed = TRUE;	m_pDevice->Reset(&pp);	return S_OK;}

It works like this, even the resoliution of screen changes, but could it be called fullscreen (it looks like one though)? The commented code makes m_pDevice->Clear(...); function fail. Mainly because I change pp.Windowed to false. What might be causing it?

CWindow::ChangeWindowMode(); changes the width, height and dwstyle of the window to match that of a fullscreen.
Evil Steve
Evil Steve
What do the Debug Runtimes say?

In fullscreen mode you need to specify a valid backbuffer format - D3DFMT_UNKNOWN isn't a valid format.
Marusu
Marusu
Thank you for your reply.
Unfortunately, output doesn't say anything. Thanks for the link, though.
I did set debug radiobox and maxed out output level. Also this is how my header looks:
#include "MWindows.h"
#include
#include
#include

#pragma comment(lib, "d3d9.lib")
#ifdef _DEBUG
#pragma comment(lib, "d3dx9.lib")
#else
#pragma comment(lib, "d3dx9d.lib")
#endif
#pragma comment(lib, "strmiids.lib")

#include "MWorldObjects.h"

I didn't see anything new on output so how am I supposed to be sure that everything is correctly configured? And how do I know if my project is managed or not?

Adding back buffer format: D3DFMT_X8R8G8B8; solved the problem.
Evil Steve
Evil Steve
Quote:
Original post by Marusu
Thank you for your reply.
Unfortunately, output doesn't say anything. Thanks for the link, though.
I did set debug radiobox and maxed out output level.

I didn't see anything new on output so how am I supposed to be sure that everything is correctly configured?
You should get some sort of output from the debug runtimes if they're working correctly; the only time I've seen no output is if you have a very old SDK and a new DirectX version (E.g. DX9.0b SDK and DX9.0c or above runtime). If your SDK is less than 5 years old, that shouldn't be a problem.
Do you still get nothing if you download and run DebugView?
What OS are you running? If it's Vista or Windows 7, are you running as Administrator?

Quote:
Original post by Marusu
And how do I know if my project is managed or not?
If you're using C++, it's an unmanaged project.

Quote:
Original post by Marusu
Adding back buffer format: D3DFMT_X8R8G8B8; solved the problem.
Hooray! [smile]
Marusu
Marusu
Quote:

Do you still get nothing if you download and run DebugView?

Yes, I do get some information:
Quote:

[1108] >> MSEnv extensibility IClassFactory::LockServer(TRUE), lock count: 1
[1108] Debug Location toolbar found with id 32309248
[1108] Debug Location toolbar found with id 32309248
[1108] Debug Location toolbar found with id 32309248
[1108] >> MSEnv extensibility IClassFactory::LockServer(TRUE), lock count: 2
[1108] >> MSEnv extensibility IClassFactory::LockServer(TRUE), lock count: 3
[1108] >> MSEnv extensibility IClassFactory::LockServer(FALSE), lock count: 2
[1108] >> MSEnv extensibility IClassFactory::LockServer(FALSE), lock count: 1


Quote:

What OS are you running? If it's Vista or Windows 7, are you running as Administrator?

Im using windows 7 64-bit with visual studio proffesional edition. I tried running as administrator, but still get nothing new except messages I always get:
Quote:

'MWindows.exe': Loaded 'C:\Users\<...>\Desktop\Win32+DirectX\MWindows\Debug\MWindows.exe', Symbols loaded.
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\user32.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\gdi32.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\lpk.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\usp10.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\msvcrt.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\advapi32.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\sechost.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\rpcrt4.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\sspicli.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\cryptbase.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\ole32.dll'
'MWindows.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.21022.8_none_96748342450f6aa2\msvcp90d.dll', Symbols loaded.
'MWindows.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.21022.8_none_96748342450f6aa2\msvcr90d.dll', Symbols loaded.
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\d3d9.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\version.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\d3d8thk.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\dwmapi.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\D3DX9_42.dll'
'MWindows.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4926_none_508ed732bcbc0e5a\msvcr90.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\d2d1.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\imm32.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\msctf.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\uxtheme.dll'
'MWindows.exe': Loaded 'C:\Program Files (x86)\Fraps\fraps.dll', Binary was not built with debug information.
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\atiumdag.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\atiumdva.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\oleaut32.dll'
The thread 'Win32 Thread' (0x1280) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x1360) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x12b8) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x12b4) has exited with code 0 (0x0).
'MWindows.exe': Unloaded 'C:\Windows\SysWOW64\atiumdva.dll'
'MWindows.exe': Unloaded 'C:\Windows\SysWOW64\atiumdag.dll'
The thread 'Win32 Thread' (0xbd0) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x4c0) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x6b4) has exited with code 0 (0x0).
The program '[4424] MWindows.exe: Native' has exited with code 0 (0x0).

I made my program to close because of FAILED HRESULT from IDirect3DDevice9::Clear(...); so I believe I should get something about it.

Quote:

If your SDK is less than 5 years old, that shouldn't be a problem.

Since it's windows 7 and I downloaded newest DirectX SDK before half a year, my windows updates are also up to date, so I beleive it's not the problem .

Here's an image of my controls:
64 bit
It's 64-bit though.
I'll look at 32-bit.
WTF???
It's different:
32 bit
So it seems, that I was trying to configure the wrong thing from the very beginning.
Now it works!
Quote:

'MWindows.exe': Loaded 'C:\Users\<...>\Desktop\Win32+DirectX\MWindows\Debug\MWindows.exe', Symbols loaded.
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\user32.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\gdi32.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\lpk.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\usp10.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\msvcrt.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\advapi32.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\sechost.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\rpcrt4.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\sspicli.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\cryptbase.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\ole32.dll'
'MWindows.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.21022.8_none_96748342450f6aa2\msvcp90d.dll', Symbols loaded.
'MWindows.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.21022.8_none_96748342450f6aa2\msvcr90d.dll', Symbols loaded.
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\d3d9.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\version.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\d3d8thk.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\dwmapi.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\D3DX9_42.dll'
'MWindows.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4926_none_508ed732bcbc0e5a\msvcr90.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\d2d1.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\imm32.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\msctf.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\uxtheme.dll'
'MWindows.exe': Loaded 'C:\Program Files (x86)\Fraps\fraps.dll', Binary was not built with debug information.
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\d3d9d.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\winmm.dll'
Direct3D9: :====> ENTER: DLLMAIN(697cd9a0): Process Attach: 00000bd0, tid=00000cf8
Direct3D9: :====> EXIT: DLLMAIN(697cd9a0): Process Attach: 00000bd0
Direct3D9: (INFO) :Direct3D9 Debug Runtime selected.
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\atiumdag.dll'
'MWindows.exe': Loaded 'C:\Windows\SysWOW64\atiumdva.dll'
Direct3D9: (INFO) :======================= Hal HWVP device selected

Direct3D9: (INFO) :HalDevice Driver style b

Direct3D9: :DoneExclusiveMode
Direct3D9: (INFO) :Using FF to VS converter

Direct3D9: (INFO) :Using FF to PS converter

D3D9 Helper: Warning: Default value for D3DRS_POINTSIZE_MAX is 2.19902e+012f, not 1.79508e-316f. This is ok.
Direct3D9: (WARN) :Ignoring redundant SetRenderState - 7

Direct3D9: (WARN) :Ignoring redundant SetRenderState - 137

'MWindows.exe': Loaded 'C:\Windows\SysWOW64\oleaut32.dll'
Direct3D9: :Subclassing window 00120694
Direct3D9: :StartExclusiveMode
Direct3D9: (INFO) :Using FF to VS converter

Direct3D9: (INFO) :Using FF to PS converter

D3D9 Helper: Warning: Default value for D3DRS_POINTSIZE_MAX is 2.19902e+012f, not 1.79508e-316f. This is ok.
Direct3D9: :WM_SYSKEYUP: wParam=0000000d lParam=e01c0001
Direct3D9: :WM_SIZE hWnd=120694 wp=0000, lp=01BA0310 dwFlags=00000001
Direct3D9: :WM_SIZE: Window restored, sending WM_ACTIVATEAPP
Direct3D9: :StartExclusiveMode
Direct3D9: (ERROR) :Display mode is unsupported
Direct3D9: (ERROR) :Display mode is unsupported
Direct3D9: (ERROR) :Display mode is unsupported
Direct3D9: (ERROR) :Display mode is unsupported
Direct3D9: (ERROR) :Unable to set the new mode. CreateDevice/Reset Fails
Direct3D9: (ERROR) :ResetEx failed and ResetEx/TestCooperativeLevel/Release are the only legal APIs to be called subsequently
Direct3D9: :DoneExclusiveMode
Direct3D9: :INACTIVE: 00000bd0: Restoring original mode (1680x1050x22x60) at adapter index 0
Direct3D9: :Unsubclassing window 00120694
D3D9 Helper: IDirect3DDevice9::Reset failed: D3DERR_INVALIDCALL
Direct3D9: (ERROR) :Device is in an invalid state. Only Reset, TestCooperativeLevel, CheckDeviceState or Release could be called
D3D9 Helper: IDirect3DDevice9::Clear failed: D3DERR_INVALIDCALL
The thread 'Win32 Thread' (0x780) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x1344) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x974) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x1064) has exited with code 0 (0x0).
'MWindows.exe': Unloaded 'C:\Windows\SysWOW64\atiumdva.dll'
'MWindows.exe': Unloaded 'C:\Windows\SysWOW64\atiumdag.dll'
The thread 'Win32 Thread' (0x8a4) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x2d8) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x1318) has exited with code 0 (0x0).
Direct3D9: :====> ENTER: DLLMAIN(697cd9a0): Process Detach 00000bd0, tid=00000cf8
Direct3D9: (INFO) :MemFini!
Direct3D9: :====> EXIT: DLLMAIN(697cd9a0): Process Detach 00000bd0
The program '[3024] MWindows.exe: Native' has exited with code 0 (0x0).



Thank you very much, it works! Yay! [lol]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.