Skip to main content
gamedev.net
🔒 Locked

Interrogating screen size

Started by -Moxie- 5 replies 450+ views
Original Post
-Moxie-
-Moxie-
How can I get the screen height and width from a IDirect3DDevice pointer? Or is it something I need to get from the HWND that I use to create the device? How about textures attached to ID3DXSPRITEs? Is there a way to get their height and width after they are created? Thanks
bmoberly
bmoberly
Hey - I may not be understanding your first question, but can''t you use IDirect3DDevice8::GetViewport? This will fill a viewport structure with, among other things, the width and height of the render target surface.

As for your second question, can''t you call IDirect3DTexture8::GetLevelDesc? This should fill a D3DSURFACE_DESC structure with, among other things, the width and height, of the texture.

All of the above is in the sdk documentation, but maybe I''m misunderstanding your question, and you''re trying to do something more complex.

Good luck.

bmoberly
-Moxie-
-Moxie-
Thanks for the response.

When I try to use GetViewport with the following code:


D3DVIEWPORT8 vp;
hr = m_pd3dDevice->GetViewport(&vp)



I get a status back for "Invalid Call" which the docs says "D3DERR_INVALIDCALL is returned if the pViewport parameter is invalid."

Is there something I need to do to initialize the structure?
elis-cool
elis-cool
why dont you just use (if its a fullscreen app) GetSystemMetrics()
[email=esheppard@gmail.com]esheppard@gmail.com[/email]
Smoogle
Smoogle
I don''t have the documentation with me, but my best guess would be to zero the structure, and possibly see if there is a ''size'' member.
-Moxie-
-Moxie-
I don''t think I can use GetSystemMetrics because I''m using a framework that sets up D3d for me based on optimum screen size. So if the desktop size is different from the d3ddevice size, won''t that cause a problem?

I tried to zero it out. Both by setting all the members to 0 and also using ZeroMemory(&vp, sizeof(D3DVIEWPORT8)). There is no size member.
Kikuchiyo
Kikuchiyo
Try this :

D3DDISPLAYMODE modeInfo;
m_pd3dDevice->GetDisplayMode( &modeInfo );


This should get you width, height, refresh rate & pixel format info.
Kikuchiyo

Topic Locked

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

Sign in to reply to this topic.