Fullscreen sucks?

Started by
6 comments, last by Hippokrates 21 years, 7 months ago
In windowed mode (D3D8) I am getting ~400 FPS but in Fullscreen just ~45 - ~150. What kind of joke is that?? Here is my initialization code (a bit messy i admit )

bool CGraphics3D::Init(HWND hWnd, LPDISPLAYMODE pDisplayMode) {
	//Lokale Variablen
	D3DDISPLAYMODE d3ddm;
	D3DPRESENT_PARAMETERS d3dpp;
	HRESULT hr;
	
	if(g_bDoDebug) {
		Log("\nBetrete: CGraphics3D::Init:\n");
	}

	if(!(SAFE_CHECK(hWnd))) {
		return ReportError(NULL, NULL, "Kein gueltiges Fenster Handle uebergeben (CGraphics3D::Init)");
	}

	m_lpD3D = Direct3DCreate8(D3D_SDK_VERSION);
	if(NULL == m_lpD3D) {
		return ReportError(NULL, NULL, "Fehler beim Anlegen des D3D Hauptobjektes (CGraphics3D::Init)");
	}
	if(g_bDoDebug) {
		Log(" --> Direct3D Hauptobjekt angelegt\n");
	}
	if(pDisplayMode->bWindowed) {
		hr = m_lpD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm);
		if(FAILED(hr)) {
			return ReportError(NULL, &hr, "Fehler beim Suchen des Displaymodus (windowed mode) (CGraphics3D::Init)");
		}
	}
	ZeroMemory(&d3dpp, sizeof(D3DPRESENT_PARAMETERS));
	d3dpp.Windowed = pDisplayMode->bWindowed;
	d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
	if(pDisplayMode->bWindowed) {
		d3dpp.BackBufferFormat = d3ddm.Format;
		if(g_bDoDebug) {
			Log(" --> Adaptiere aktuelle Auflösung\n");
		}
	}else {
		d3dpp.BackBufferWidth = pDisplayMode->iScreenWidth;
		d3dpp.BackBufferHeight = pDisplayMode->iScreenHeight;
		switch(pDisplayMode->iColorDepth) {
		case 16:
			d3dpp.BackBufferFormat = D3DFMT_R5G6B5;
			if(g_bDoDebug) {
				Log(" --> Setze Auflösung auf: %d * %d * %d %s\n", pDisplayMode->iScreenWidth, pDisplayMode->iScreenHeight, pDisplayMode->iColorDepth, "(R5G6B5)");
			}
			break;
		case 32:
			d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8;
			if(g_bDoDebug) {
				Log(" --> Setze Auflösung auf: %d * %d * %d %s\n", pDisplayMode->iScreenWidth, pDisplayMode->iScreenHeight, pDisplayMode->iColorDepth, "(A8R8G8B8)");
			}
			break;
		}
	}
	d3dpp.EnableAutoDepthStencil = true;
	if(0 == pDisplayMode->iStencilBufferDepth) {
		switch(pDisplayMode->iZBufferDepth) {
			case 16:
				d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
				if(g_bDoDebug) {
					Log(" --> Wähle 16 Bit Z Buffer Format\n");
				}
				break;
			case 32:
				d3dpp.AutoDepthStencilFormat = D3DFMT_D32;
				if(g_bDoDebug) {
					Log(" --> Wähle 32 Bit Z Buffer Format\n");
				}
				break;
		}
	}else {
		if(15 == pDisplayMode->iZBufferDepth && 1 == pDisplayMode->iStencilBufferDepth) {
			d3dpp.AutoDepthStencilFormat = D3DFMT_D15S1;
			if(g_bDoDebug) {
				Log(" --> Wähle 15 Bit Z Buffer und 1 Bit Stencil Buffer\n");
			}
		}else if(24 == pDisplayMode->iZBufferDepth && 8 == pDisplayMode->iStencilBufferDepth) {
			d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8;
			if(g_bDoDebug) {
				Log(" --> Wähle 24 Bit Z Buffer und 8 Bit Stencil Buffer\n");
			}
		}else if(24 == pDisplayMode->iZBufferDepth && 4 == pDisplayMode->iStencilBufferDepth) {
			d3dpp.AutoDepthStencilFormat = D3DFMT_D24X4S4;
			if(g_bDoDebug) {
				Log(" --> Wähle 24 Bit Z Buffer und 4 Bit Stencil Buffer (4 Bit ungenutzt)\n");
			}
		}
	}
	
	if(pDisplayMode->bAntiAliasing) {
		hr = m_lpD3D->CheckDeviceMultiSampleType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3dpp.BackBufferFormat, pDisplayMode->bWindowed, D3DMULTISAMPLE_3_SAMPLES);
		if(SUCCEEDED(hr)) {
			hr = m_lpD3D->CheckDeviceMultiSampleType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3dpp.AutoDepthStencilFormat, pDisplayMode->bWindowed, D3DMULTISAMPLE_3_SAMPLES);
			if(SUCCEEDED(hr)) {
				d3dpp.MultiSampleType = D3DMULTISAMPLE_3_SAMPLES;
				if(g_bDoDebug) {
					Log(" --> Aktiviere Full Scene Antialiasing\n");
				}
			}
		}else {
			if(g_bDoDebug) {
				Log(" --> Kein Full Scene Antialiasing verfügbar\n");
			}
		}
	}
	d3dpp.hDeviceWindow = hWnd;	
	hr = m_lpD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &m_lpD3DDevice);
	if(FAILED(hr)) {
		hr = m_lpD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &m_lpD3DDevice);
		if(FAILED(hr)) {
			return ReportError(NULL, &hr, "Fehler beim Anlegen des D3D Devices (CGraphics3D::Init)");
		}
		if(g_bDoDebug) {
			Log(" --> Erstelle Device mit Software Vertex Processing\n");
		}
	}else {
		if(g_bDoDebug) {
			Log(" --> Erstelle Device mit Hardware Vertex Processing\n");
		}
	}
	m_pDisplayMode = new DISPLAYMODE;
	if(pDisplayMode->bWindowed) {
		m_pDisplayMode->bWindowed = true;
		m_pDisplayMode->iZBufferDepth = pDisplayMode->iZBufferDepth;
		m_pDisplayMode->iStencilBufferDepth = pDisplayMode->iStencilBufferDepth;
		m_pDisplayMode->iScreenWidth = d3ddm.Width;
		m_pDisplayMode->iScreenHeight = d3ddm.Height;
		switch(d3ddm.Format) {
			case D3DFMT_A8R8G8B8:
				m_pDisplayMode->iColorDepth = 32;
				break;
			case D3DFMT_X1R5G5B5:
				m_pDisplayMode->iColorDepth = 16;
				break;
			case D3DFMT_A1R5G5B5:
				m_pDisplayMode->iColorDepth = 16;
				break;
			case D3DFMT_R5G6B5:
				m_pDisplayMode->iColorDepth = 16;
				break;
		}
	}else {
		memcpy(m_pDisplayMode, pDisplayMode, sizeof(DISPLAYMODE));
	}
	hr = D3DXCreateSprite(m_lpD3DDevice, &m_pSprite);
	if(FAILED(hr)) {
		return ReportError(NULL, &hr, "Fehler beim Anlegen des Sprites (CGraphics3D::Init)");
	}
	if(g_bDoDebug) {
		Log("Verlasse: CGraphics3D::Init\n\n");
	}
	return true;
}
 
Is there a case I did not include?
Im Anfang war die Tat...Faust
Advertisement
can you send me the whole thing?

enver.berisha@web.de

Its because your limited by the refresh rate of your monitor in fullscreen. Use the search for a better explanation.

Steve
DirectX Programmer
Soon to be the new Bill Gates
Member of the Unban Mindwipe Society (UMWS)
Are you sure? He''s using SWAP_EFFECT_DISCARD not COPY_VSYNC, it should redraw every cycle, not every refresh rate.

Dreddnafious Maelstrom

"If i saw farther, it was because I stood on the shoulders of giants."

Sir Isaac Newton
"Let Us Now Try Liberty"-- Frederick Bastiat
When you are in fullscreen, your frame rate is limited to the refresh rate.
Try setting d3dpp.FullScreen_PresentationInterval to D3DPRESENT_INTERVAL_IMMEDIATE.
Thanks @ all.
Setting the Fullscreen Presentation Interval did indeed do the trick ^^.
BTW:
Does it have any side effects not to use VSYNC ?
Im Anfang war die Tat...Faust
quote:
BTW:
Does it have any side effects not to use VSYNC ?

You can get tearing from one frame to the next at high frame rates. But i don''t see the point in this (there was a discussion a couple of months back). You can only see 60 of the 900 or whatever frames rendered, so theres just no point. The only reason for disabling vsync is if your app is running at ~59FPS, that way you''ll be capped to 30FPS (half the refresh rate).
As i said, search the forums, there was a discussion about all this.

HTH,
Steve

Steve
DirectX Programmer
Soon to be the new Bill Gates
Member of the Unban Mindwipe Society (UMWS)

This topic is closed to new replies.

Advertisement