Archived

This topic is now archived and is closed to further replies.

-Moxie-

Interrogating screen size

Recommended Posts

-Moxie-    122
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

Share this post


Link to post
Share on other sites
bmoberly    122
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

Share this post


Link to post
Share on other sites
-Moxie-    122
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?

Share this post


Link to post
Share on other sites
Smoogle    122
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.

Share this post


Link to post
Share on other sites
-Moxie-    122
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.

Share this post


Link to post
Share on other sites