Jump to content
  • Advertisement


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


BeginScene() & Render Loop

This topic is 6082 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

To all DirectX gurus ... The standard render loop for my D3D programs is generally structured as follows : { Set View Matrix Transform Vertices via world matrices BeginScene(); Draw Primitives EndScene(); } Is this the most efficient method, or is there a better way ? Is it best to keep the code between BeginScene() and EndScene() as short as possible ?

Share this post

Link to post
Share on other sites
good question.

i think the EndScene() call flushes all buffers and waits for pending operations to complete.
and puts the card back into "normal operation" so you can do 2d stuff (gdi etc.).

keeping the code inside as short as possible should not be a good idea, since all you do between the BeginScene() EndScene() pari is executed in parallel with the GPU, at least if you do it right.
so moving work bevore/after the rendering-block, that could be done WHILE pushing polys would decrease performance.
if you transform more than one object, transform the first, then render it, and while the 1st renders, transform the next etc.

if you can avoid to touch any geometry with the CPU, means no transform & stuff, no reading vertices and so on.
if you just want your objects in the right place then
for every frame

if is_this_1st_frame goto skip_render

for every object
// do whatever you can "per-object" here, just bevore rendering

set world-matrix
render object // let D3D transform it for you



do game-logic etc.
calculate new positions for objects
calculate new view-matrix etc.

D3D8: Present() -- or -- D3D7-: Flip()


i think this general approach should be o.k. for speed - if anyone has better suggestions or i have made wrong assumptions about EndScene(), please correct me.


--- foobar
We push more polygons before breakfast than most people do in a day

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!