Archived

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

Briskon

2 Questions

Recommended Posts

2 Questions>.............. 1. I''ve been following a series of DX 8 tutorials on the net. The guy who''s writing them always calls the g_pdevice->GetBackBuffer(...............) function just befor he calls BeginScene(), so that all the rendering is done to the back buffer. Is this necessary? I thought when you create a back buffer in your in initialization function it is automatically used during rendering. And then it gets flipped with the call to Present(). Am I correct? is there any need to call GetBackBuffer? 2. TriangleStrips: When you create a triangle strip and specify the vertices v1, v2, v3 in clockwise order, the next vertices v3, v4 and v2 are counterclockwise. So how come they aren''t culled? Thanks for any help.

Share this post


Link to post
Share on other sites
1) its normally automatic, BUT, sometimes you can choose to render into different buffers, such as when rendering into CubeTexture surfaces and such. It''s possible that the guy is also rendering into other surfaces, and does not revert back to the "standard" backbuffer, so just as a precaution, he re-initializes that to be the target drawing surface (target as in the destination rendering surface). I''d say keep the code in there anyways, its likely it will not cause any decrease in performance, but your software will be more robust.

www.cppnow.com

Share this post


Link to post
Share on other sites
2)... very good question. Just to release the obvious that everyone will ask: do you have culling enabled, and which cull mode is set.

At first I was going to mention that v2, v3, v4 are also clockwise in order (when you draw it out), but it''s clear that every second triangle is actually CCW in strips...

What happens if you dont make the 4 points clockwise, but rather strip-wise (the regular strp approach; I don''t know how else to state it )...

Also, what happens when you specify the 4 points in CCW order?

www.cppnow.com

Share this post


Link to post
Share on other sites
I''ve done some searching and I think I read somewhere today that Direct3D automatically switches culling for even numbered primitives...................
Ie:
Triangle 1 (CW)
Triangle 2 (CCW)
Triangle 3 (CW)
Triangle 4 (CCW)
....and so on

Share this post


Link to post
Share on other sites
You are correct. Here is an excerpt from the "D3DPRIMITIVETYPE Enumerated Type" page in the DirectX 9 SDK help:

D3DPT_TRIANGLESTRIP

Renders the vertices as a triangle strip. The backface-culling flag is automatically flipped on even-numbered triangles.

Share this post


Link to post
Share on other sites
quote:
I''ve been following a series of DX 8 tutorials on the net.
The guy who''s writing them always calls the g_pdevice->GetBackBuffer(...............) function just befor he calls BeginScene(), so that all the rendering is done to the back buffer.

Is this necessary? I thought when you create a back buffer in your in initialization function it is automatically used during rendering. And then it gets flipped with the call to Present(). Am I correct? is there any need to call GetBackBuffer?


Whenever you issue a (rendering) command, it''s not necessarily carried out by d3d. Instead, it is just stored in a command queue. Present() doesn''t necessarily flush this command queue, in fact, up to 3 frames can be queued as far as I recall.

Sometimes, like when you''re synching the display with audio, this isn''t desirable, so locking the back buffer means you want the data you just "ordered" the device to render. This forces the device to flush the command queue.

Though that''s not a good thing to do all the time, do it only when needed.

Peace,
Muhammad Haggag

Share this post


Link to post
Share on other sites