SetViewport problem
hello,everybody!
i have a problem when setting viewport
BackBufferWidth=1024;
BackBufferHeight=768;
D3DVIEWPORT9 myviewport;
myviewport.x=0;
myviewport.y=96;
myviewport.width=1024;
myviewport.height=576;
myviewport.MinZ=0.0f;
myviewport.MaxZ=1.0f;
g_pd3dDevice->SetViewport(&myviewport)
i want to make my app look like a wide-screen movie,something like this:
*******************************************
*******************************************
*******************************************
*******************************************
*******************************************
*******************************************
my render state:(i am rendering point sprite using Fix Function Pipeline)
D3DRS_ZENABLE TRUE
D3DRS_LIGHTING FALSE
D3DSAMP_MINFILTER D3DTEXF_LINEAR
D3DSAMP_MAGFILTER D3DTEXF_LINEAR
before rendering pointsprite:
D3DRS_ZWRITEENABLE FALSE
D3DRS_ALPHABLENDENABLE TRUE
D3DRS_DESTBLEND D3DBLEND_ONE
rendering sprite:
D3DRS_POINTSPRITEENABLE TRUE
D3DRS_POINTSCALEENABLE TRUE
D3DRS_POINTSIZE 1.0f
D3DRS_POINTSIZE_MIN 1.0f
D3DRS_POINTSCALE_A 0.0f
D3DRS_POINTSCALE_B 0.0f
D3DRS_POINTSCALE_C 1.0f
after rendering pointsprite:
D3DRS_POINTSCALEENABLE FALSE
D3DRS_ZWRITEENABLE TRUE
D3DRS_ALPHABLENDENABLE FALSE
i set only one viewport,and the top and bottom area(which i didn't take care of) sometimes flash between black and the back image of my application window.
the sprite could be rendered correctly in the viewport i set
i am not sure if i described this correctly,i captured a few pictures of my application but i don't know how to post them here.
If you use swapeffect flip, you could get away with clearing the area only twice, instead of each frame. Once for the current back buffer, once for the front buffer as it becomes the backbuffer. If you use more backbuffers (BackBufferCount > 1), you'll need more clears before they all have the top/bottom area cleared.
If you use swapeffect copy, you can clear just once. The backbuffer is left alone, and copied to the front buffer, so your cleared area remains.
If you use swapeffect discard, you must assume the entire backbuffer is trashed, and clear or redraw over the entire buffer each frame. This mode is the only mode that supports multisampling, and is generally the most efficient mode to use.
In general, set the viewport to the whole surface. Clear. Set the viewport to the area you want to draw in. Draw. Present. Repeat.
If you use swapeffect copy, you can clear just once. The backbuffer is left alone, and copied to the front buffer, so your cleared area remains.
If you use swapeffect discard, you must assume the entire backbuffer is trashed, and clear or redraw over the entire buffer each frame. This mode is the only mode that supports multisampling, and is generally the most efficient mode to use.
In general, set the viewport to the whole surface. Clear. Set the viewport to the area you want to draw in. Draw. Present. Repeat.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement