Archived

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

yoshscout

Direct3D GetViewport

Recommended Posts

FROM THE DOCUMENTATION: IDirect3DDevice8::GetViewport Retrieves the viewport parameters currently set for the device. HRESULT GetViewport( D3DVIEWPORT8* pViewport ); Parameters pViewport [out] Pointer to a D3DVIEWPORT8 structure, representing the returned viewport parameters. Return Values If the method succeeds, the return value is D3D_OK. D3DERR_INVALIDCALL is returned if the pViewport parameter is invalid. FOR REFERENCE ALSO: typedef struct _D3DVIEWPORT8 { DWORD X; DWORD Y; DWORD Width; DWORD Height; float MinZ; float MaxZ; } D3DVIEWPORT8; MY IMPLEMENTATION: D3DCOLOR fontColor = D3DCOLOR_ARGB(255,0,255,0); TCHAR szMsg[MAX_PATH] = TEXT(""); D3DVIEWPORT8 vp = {0}; if(m_pGame->GetDevice()->GetViewport( &vp ) == D3DERR_INVALIDCALL) { sprintf( szMsg, TEXT("ERROR: Unable to get viewport stats!")); }else{ sprintf( szMsg, TEXT("%i x %i @ FPS: %0.2f"), vp.Width, vp.Height, m_pGame->GetFPS()); } m_pFont->DrawText(15, 15, fontColor, szMsg); WHAT HAPPENS: On some computers, it works properly. On some however it is unable to get the stats! Almost all computers actually do the latter. My implementation is obviously correct as it is identical to everyones examples i have seen of its use. I have experimented with not initializing the structure and it still fails. Anyone know wuts going on?

Share this post


Link to post
Share on other sites
Are you creating a pure device? The following is from the SDK documentation:

quote:

D3DCREATE_PUREDEVICE
Specifies that Direct3D does not support Get* calls for anything that can be stored in state blocks. It also tells Direct3D not to provide any emulation services for vertex processing. This means that if the device does not support vertex processing, then the application can use only post-transformed vertices.



This means that you can not use any gets from the D3D Device if you have created the device as pure.


_______________________________________
Understanding is a three edged sword...


[edited by - Sean Doherty on November 13, 2003 10:55:25 PM]

[edited by - Sean Doherty on November 13, 2003 10:57:30 PM]

Share this post


Link to post
Share on other sites
actually there is a long way of enumerating that BUT i debugged and checked it to be of value 50 which i think is HAL Vertexs + Pure device flags, is this one of the cases they mean about get* processes?

Share this post


Link to post
Share on other sites
The following is from the SDK documentation:

quote:

D3DCREATE_PUREDEVICE
Specifies that Direct3D does not support Get* calls for anything that can be stored in state blocks. It also tells Direct3D not to provide any emulation services for vertex processing. This means that if the device does not support vertex processing, then the application can use only post-transformed vertices.



This means that you can not use any gets from the D3D Device if you have created the device as pure.


_______________________________________
Understanding is a three edged sword...


[edited by - Sean Doherty on November 13, 2003 10:57:19 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by Sean Doherty
Are you creating a pure device? The following is from the SDK documentation:

quote:

D3DCREATE_PUREDEVICE
Specifies that Direct3D does not support Get* calls for anything that can be stored in state blocks. It also tells Direct3D not to provide any emulation services for vertex processing. This means that if the device does not support vertex processing, then the application can use only post-transformed vertices.



This means that you can not use any gets from the D3D Device if you have created the device as pure.




The SDK documentation for Directx 9 makes it clear that you can use the GetViewPort method with a D3DCREATE_PUREDEVICE:

quote:

Typically, methods that return state will not work on a device that is created using D3DCREATE_PUREDEVICE. This method is an exception, because Microsoft® Direct3D® needs to track viewport data, even on a pure device.



I have checked the Directx 8 documentation and it doesnt say this, so it may or may not be true for Directx 8.



Share this post


Link to post
Share on other sites
quote:

The SDK documentation for Directx 9 makes it clear that you can use the GetViewPort method with a D3DCREATE_PUREDEVICE:



Jingo,

1) If you look at the original post, you can see that he is using DirectX 8.

quote:

I have checked the Directx 8 documentation and it doesnt say this, so it may or may not be true for Directx 8.




2) The DirectX 8 SDK documentation does say that you can't use a get with a pure device.


_______________________________________
Understanding is a three edged sword...




[edited by - Sean Doherty on November 14, 2003 6:55:32 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by Sean Doherty
2) Sorry to correct you, but the DirectX 8 SDK documentation does say that you can't use a get with a pure device.



I never said that it didnt.

[edited by - Jingo on November 14, 2003 6:41:32 PM]

Share this post


Link to post
Share on other sites
quote:

The SDK documentation for Directx 9 makes it clear that you can use the GetViewPort method with a D3DCREATE_PUREDEVICE:


quote:
--------------------------------------------------------------------------------

Typically, methods that return state will not work on a device that is created using D3DCREATE_PUREDEVICE. This method is an exception, because Microsoft® Direct3D® needs to track viewport data, even on a pure device.

--------------------------------------------------------------------------------



I have checked the Directx 8 documentation and it doesnt say this, so it may or may not be true for Directx 8.



Sorry Jingo,

You are correct; I misread the quote above. You were actually wondering why DirectX 9 supports the GetViewPort and DirectX 8 does not support GetViewPort with a Pure Device. Assuming that I am interpreting you correctly now; you have me wondering if the same thing.

Maybe S1CA could clarify if this is correct and why?


_______________________________________
Understanding is a three edged sword...





[edited by - Sean Doherty on November 14, 2003 6:55:53 PM]

Share this post


Link to post
Share on other sites