Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


#Actualbeefsteak

Posted 01 August 2013 - 11:20 AM

A also pondered about the device- and window-class configurations I am using: Maybe some special setting
I am using in fullscreen mode causes incompatibility issues with the windows desktop manager?

 

In case it matters I have posted my configurations below:
 

// window style for window-mode: title bar, close box, minimize box
const DWORD Window::WIN_STYLE_WINDOWED = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;

// window style for fullscreen: no titlebar, popup style
const DWORD Window::WIN_STYLE_FULLSCREEN = WS_POPUP | WS_VISIBLE;

Window::Window(HINSTANCE hInstance, WNDPROC messageHandler, LPCTSTR title, int width, int height, bool pFullscreen):
window(NULL),
activeCursor(NULL),
fullscreen(pFullscreen)
{
	// start with default cursor
	activeCursor = DfCursor::C_DEFAULT;

	// define window class properties
	windowClass.style = NULL;
	windowClass.lpfnWndProc = messageHandler;
	windowClass.cbClsExtra = 0;
	windowClass.cbWndExtra = 0;
	windowClass.hInstance = hInstance;
	windowClass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APP_ICON));
	windowClass.hCursor = activeCursor == NULL ? NULL : activeCursor->getWinCursor();
	windowClass.hbrBackground = NULL;
	windowClass.lpszMenuName = NULL;
	windowClass.lpszClassName = title;
	RegisterClass(&windowClass);

	// calculate correct window size and position
	RECT clientRect;
	calculatePosition(width, height, fullscreen, &clientRect);

	window = CreateWindow(windowClass.lpszClassName,
			title,
			fullscreen ? WIN_STYLE_FULLSCREEN : WIN_STYLE_WINDOWED,
			clientRect.left, clientRect.top,
			clientRect.right - clientRect.left, clientRect.bottom - clientRect.top,
			GetDesktopWindow(), NULL, windowClass.hInstance, NULL);

	if (window == NULL) {
		throw (TEXT("Window Constructor: Failed to create a new window!"));
	}
}
DfGraphicsManager::DfGraphicsManager(ResourceManager *resourceManager, HWND window, int width, int height, bool fullscreen):
resourceManager(resourceManager),
context(NULL),
device(NULL),
desiredScreenResolutionX(width),
desiredScreenResolutionY(height) {
	context = Direct3DCreate9(D3D_SDK_VERSION);

	if (context == NULL) throw(TEXT("D3DManager Constructor: Failed to create a Direct3D Context!"));

	parameters.BackBufferWidth = width; parameters.BackBufferHeight = height;
	parameters.BackBufferFormat = D3DFMT_X8R8G8B8;
	parameters.BackBufferCount = 1;
	parameters.MultiSampleType = D3DMULTISAMPLE_NONE;
	parameters.MultiSampleQuality = 0;
	parameters.SwapEffect = D3DSWAPEFFECT_FLIP; // flip between front and back buffer
	parameters.hDeviceWindow = window;
	parameters.Windowed = !fullscreen;
	parameters.EnableAutoDepthStencil = true;
	parameters.AutoDepthStencilFormat = D3DFMT_D16;
	parameters.Flags = NULL;
	parameters.FullScreen_RefreshRateInHz = 0;
	parameters.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;

	// create the device.
	HRESULT result = context->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, window,
		D3DCREATE_MIXED_VERTEXPROCESSING, &parameters, &device);
	errorCheck(result, TEXT("D3DManager Constructor: Failed to create device!\r\n"));

	// for a 2D application: turn off z-buffer, culling and lightning
	device->SetRenderState(D3DRS_ZENABLE, false);
	device->SetRenderState(D3DRS_LIGHTING, FALSE);
	device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
}

#1beefsteak

Posted 01 August 2013 - 04:15 AM

A also pondered about the device- and window-class configurations I am using: Maybe some special setting
I am using in fullscreen mode causes incompatibility issues with the windows desktop manager?

 

In case it matters I have posted my configurations below:
 

Window::Window(HINSTANCE hInstance, WNDPROC messageHandler, LPCTSTR title, int width, int height, bool pFullscreen):
window(NULL),
activeCursor(NULL),
fullscreen(pFullscreen)
{
	// start with default cursor
	activeCursor = DfCursor::C_DEFAULT;

	// define window class properties
	windowClass.style = NULL;
	windowClass.lpfnWndProc = messageHandler;
	windowClass.cbClsExtra = 0;
	windowClass.cbWndExtra = 0;
	windowClass.hInstance = hInstance;
	windowClass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APP_ICON));
	windowClass.hCursor = activeCursor == NULL ? NULL : activeCursor->getWinCursor();
	windowClass.hbrBackground = NULL;
	windowClass.lpszMenuName = NULL;
	windowClass.lpszClassName = title;
	RegisterClass(&windowClass);

	// calculate correct window size and position
	RECT clientRect;
	calculatePosition(width, height, fullscreen, &clientRect);

	window = CreateWindow(windowClass.lpszClassName,
			title,
			fullscreen ? WIN_STYLE_FULLSCREEN : WIN_STYLE_WINDOWED,
			clientRect.left, clientRect.top,
			clientRect.right - clientRect.left, clientRect.bottom - clientRect.top,
			GetDesktopWindow(), NULL, windowClass.hInstance, NULL);

	if (window == NULL) {
		throw (TEXT("Window Constructor: Failed to create a new window!"));
	}
}
DfGraphicsManager::DfGraphicsManager(ResourceManager *resourceManager, HWND window, int width, int height, bool fullscreen):
resourceManager(resourceManager),
context(NULL),
device(NULL),
desiredScreenResolutionX(width),
desiredScreenResolutionY(height) {
	context = Direct3DCreate9(D3D_SDK_VERSION);

	if (context == NULL) throw(TEXT("D3DManager Constructor: Failed to create a Direct3D Context!"));

	parameters.BackBufferWidth = width; parameters.BackBufferHeight = height;
	parameters.BackBufferFormat = D3DFMT_X8R8G8B8;
	parameters.BackBufferCount = 1;
	parameters.MultiSampleType = D3DMULTISAMPLE_NONE;
	parameters.MultiSampleQuality = 0;
	parameters.SwapEffect = D3DSWAPEFFECT_FLIP; // flip between front and back buffer
	parameters.hDeviceWindow = window;
	parameters.Windowed = !fullscreen;
	parameters.EnableAutoDepthStencil = true;
	parameters.AutoDepthStencilFormat = D3DFMT_D16;
	parameters.Flags = NULL;
	parameters.FullScreen_RefreshRateInHz = 0;
	parameters.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;

	// create the device.
	HRESULT result = context->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, window,
		D3DCREATE_MIXED_VERTEXPROCESSING, &parameters, &device);
	errorCheck(result, TEXT("D3DManager Constructor: Failed to create device!\r\n"));

	// for a 2D application: turn off z-buffer, culling and lightning
	device->SetRenderState(D3DRS_ZENABLE, false);
	device->SetRenderState(D3DRS_LIGHTING, FALSE);
	device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
}

PARTNERS