• Advertisement
Sign in to follow this  

DirectX: How to make resolution different than window size

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

Hey Guys, Does anyone know how you could initialize directx such that even though the window size may be say... 800x600, that internally it's treated as 1024x768? This seems to be possible because you can resize a window after it's created (manually with the mouse) and it doesnt change the game's resolution, it just squishes and stretches to fit the area. However I can't find how to do that at initialization time. Thank you!

Share this post


Link to post
Share on other sites
Advertisement
I'm not sure exactly what it is you are trying to achieve, but here goes anyway. When you create the Direct3D device, you fill out the D3DPRESENT_PARAMETERS structures. Set the BackBufferWidth and BackBufferHeight to your desired rendering resolution.

When you call Present(), the image, which is actually rendered at the resolution specified in the above members, is stretched to fill out the client area of the window.

You can create set the backbuffer dimensions to be the size of the entire desktop area (the current desktop resolution), and then before you render anything, set the viewport to be the size of the client area of the window, and at present time, have Present() only show the rendered area. This results in the image rendered being displayed at the actual size regardless of the size of the window.


RECT rClient;
GetClientRect( hWindow, &rClient );
D3DVIEWPORT vp = {0};
vp.Width = rClient.right - rClient.left;
vp.Height = rCLient.bottom - rClient.top;
vp.MinZ = 0;
vp.MaxZ = 1;
pD3DDevice->SetViewport( &vp );
pD3DDevice->BeginScene();
// Render your scene here.
pD3DDevice->EndScene();
pD3DDevice->Present( &rClient, &rClient, hWindow, NULL );

Share this post


Link to post
Share on other sites
Quote:
Original post by Atrix256
Hey Guys,

Does anyone know how you could initialize directx such that even though the window size may be say... 800x600, that internally it's treated as 1024x768?

This seems to be possible because you can resize a window after it's created (manually with the mouse) and it doesnt change the game's resolution, it just squishes and stretches to fit the area.

However I can't find how to do that at initialization time.

Thank you!
Is this for a 2-d game?

Share this post


Link to post
Share on other sites
This is a 3d game, but there are 2d elements to it (so ie rendering in 3d and 2d)

What i'm trying to acheive is i'm making an editor (with wxWidgets) for my game which embeds an "engine view" window into the editor.

I don't want this window to be full sized, but I don't want to have to go through and change a bunch of logic in my code to accommodate the other screen size :/

Thanks a bunch Amr, I will give that a shot! (:

Share this post


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

  • Advertisement