Jump to content
  • Advertisement
Sign in to follow this  
PumpkinPieman

fullscreen doesn't change it's resolution.

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

Here's my problem, I noticed that when I run my program with the settings of 800 x 600 in windowed form it shows up as 800x600. However when I run it in fullscreen it shows up at my default resolution (1280x1024). Anyone know why this might be? WinMain.cpp
	NewWindow.d3d_set_window(hInstance, default_window_proc, "Application Name", "Lyradis");
	NewWindow.d3d_set_screen(800, 600, false);
	NewWindow.d3d_set_d3dscreen(D3DFMT_R5G6B5);
	NewWindow.d3d_set_clearing(true, true, false, D3DCOLOR_RGBA(0,0,0,255));

cDirect3D.cpp:
bool cDirect3D::init_window(void)
{
	WNDCLASS window_class;
	DWORD style;

	window_class.style = CS_OWNDC;
	window_class.cbClsExtra = 0;
	window_class.cbWndExtra = 0;
	window_class.hInstance = m_instance;
	window_class.hIcon = LoadIcon(NULL,IDI_APPLICATION);
	window_class.hCursor = LoadCursor(NULL,IDC_ARROW);
	window_class.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
	window_class.lpszMenuName = NULL;
	window_class.lpszClassName = m_class_name.c_str();
	window_class.lpfnWndProc = m_windowproc;

	if(!RegisterClass(&window_class)){
		MB("Failed to register window class");
		return false;
	}
	if(m_fullscreen){
      m_width=GetSystemMetrics(SM_CXSCREEN);
      m_height=GetSystemMetrics(SM_CYSCREEN);
      style=WS_POPUP;
	}else{
		style=WS_OVERLAPPED|WS_SYSMENU;
	}
	m_main_window=CreateWindow(m_class_name.c_str(),m_app_name.c_str(),style,
								0,0,m_width,m_height,NULL,NULL,
								m_instance,NULL);
	if(!m_main_window){
		MB("Failed to create window");
		return false;
	}
	ShowWindow(m_main_window,SW_SHOW);
	UpdateWindow(m_main_window);
	SetFocus(m_main_window);
	return true;
}

bool cDirect3D::init_d3d(void)
{
	HRESULT hr;
	D3DPRESENT_PARAMETERS d3dpp;
	D3DDISPLAYMODE display_mode;

	m_d3d = Direct3DCreate8( D3D_SDK_VERSION );
	if(!m_d3d ){
		MB("Error getting Direct3D");
		return false;
	}

	hr=m_d3d->GetAdapterDisplayMode(D3DADAPTER_DEFAULT,&display_mode);
	if(FAILED(hr)){
		MB("Error getting display mode");
		return false;
	}

	ZeroMemory(&d3dpp,sizeof(d3dpp));

	d3dpp.SwapEffect     = D3DSWAPEFFECT_DISCARD;
	d3dpp.hDeviceWindow  = m_main_window;
	d3dpp.BackBufferCount= 1;

	if(m_zbuffer){
		d3dpp.EnableAutoDepthStencil = TRUE;
		d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
	}

	if(m_fullscreen){
		d3dpp.Windowed          = FALSE;
		d3dpp.BackBufferWidth   = m_width;
		d3dpp.BackBufferHeight  = m_height;
		d3dpp.BackBufferFormat  = m_format;

//		d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
//		d3dpp.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_ONE;
	}else{
		d3dpp.Windowed          = TRUE;
		d3dpp.BackBufferFormat  = display_mode.Format;
	}


	hr=m_d3d->CreateDevice(D3DADAPTER_DEFAULT,
							D3DDEVTYPE_HAL,
							m_main_window,
							D3DCREATE_SOFTWARE_VERTEXPROCESSING,
							&d3dpp,
							&m_d3d_device);
	if(FAILED(hr)){
		MB("Error creating device\n");
		return false;
	}

	if(m_zbuffer){
		m_d3d_device->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
	}
	return true;
}

Share this post


Link to post
Share on other sites
Advertisement
Because you're setting your width and height to your desktops width and height in your ini_window function.


if( fullscreen )
{
m_width=GetSystemMetrics(SM_CXSCREEN);
m_height=GetSystemMetrics(SM_CYSCREEN);
}


That makes your width and height equal to your desktop.

Share this post


Link to post
Share on other sites
In windowed mode you have another bug. Creating an 800x600 window results in a client area of something like 792x592. Your backbuffer is going to be stretched from 800x600 to the client area size.

Use something like this:
RECT rc;
rc.left = rc.top = 0;
rc.right = m_width;
rc.bottom = m_height;
AdjustRect(&rc, WS_OVERLAPPEDWINDOW, false);
CreateWindow(..., rc.right - rc.left, rc.bottom - rc.top,...)

to ensure you make a window who's client area is large enough. An alternative is to make the window 800x600, and use GetClientRect() to find the actual size you should make your D3D back buffer.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!