Skip to main content
gamedev.net
🔒 Locked

SetViewport

Started by blaze02 3 replies 2.1k views
Original Post
blaze02
blaze02
I am not getting any effect from the SetViewport function. The return value from the function is successful. I've tried calling it just after the creating the device and at the start of each render loop. Am I missing something? Is there anything that the viewport depends on besides this function call? Thanks for any help.
GiantPaul
GiantPaul
Did you change the size of the window that you want your new View to use?
800x600 size etc?

D3DVIEWPORT8 *View1;

View1 = {0,0,800,600,0.0f,1.0f};
GraphicsDevice->SetViewport(&View1);



blaze02
blaze02
Quote:
Original post by GiantPaul
Did you change the size of the window that you want your new View to use?


Change the size of the window? No.
Tell if I am expecting the wrong results here...
Lets say I make my app fullscreen, 1280x1024, and I want to render only to the middle 800x600 to preserve my pixel perfect art. So I would call SetViewport with:
X = 1280 / 2 - 800 / 2 (the examples I saw use the top-left corner for X,Y)
Y = 1024 / 2 - 600 / 2
Width = 800
Height = 600
Z = 0 -> 1

After I call SetViewport, shouldn't the device only render to the inner 800x600, leaving anything outside that clear color?

As I said before though, it doesn't matter what I do with SetViewport, nothing changes.

Edit: Oh, you meant the viewport window. Yeah. Thought you were talking about my Windows window.
sirob
sirob
That sounds like it should work. Are you sure you don't override this setting later on?

This is off the top of my head, but I seem to recall that SetRenderTarget also modifies the Viewport for you. I've had a look in the docs, and can't find anything about it. As a test, I'd try resetting the correct Viewport after each call to SetRenderTarget (if you have any).

Hope this helps.
Sirob Yes.» - status: Work-O-Rama.
blaze02
blaze02
Quote:
Original post by sirob
That sounds like it should work. Are you sure you don't override this setting later on?

Absolutely.

Quote:
Original post by sirob
This is off the top of my head, but I seem to recall that SetRenderTarget also modifies the Viewport for you. I've had a look in the docs, and can't find anything about it. As a test, I'd try resetting the correct Viewport after each call to SetRenderTarget (if you have any).

And you, sir, are the lucky winner of correctness.

I haven't tested it much, but I think that is what's happening. So I guess each SetRenderState call sets the viewport to fullscreen. Thanks for the help.

Topic Locked

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

Sign in to reply to this topic.