Jump to content
  • Advertisement

Archived

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

initial_y

What BeginScene()/EndScene() really mean?

This topic is 5391 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

I don''t know what DIRECTX do when BeginScene()/EndScene() were called. So I can''t decide which method is better? 1. BeginScene()/EndScene once, draw all object in the period. 2. To every object call the pair.

Share this post


Link to post
Share on other sites
Advertisement
Some older cards crash if you call BeginScene() twice without a present in between... So, just once.

I do a beginscene, then render all render targets, render the back buffer and present, render to all additional swapchains and present those, then I do an endscene.

Share this post


Link to post
Share on other sites
DX9 doesn''t actually DO anything until EndScene() is called. All state changes and primitives drawn between Begin/End are just queued up and then blasted out at the card in one batch, with (some, perhaps none) optimizations occurring at the driver level for things like vertex buffers, or redundant state changes.

Check the DX9 documentation on IDirect3DDevice9.

---
http://www.gapingwolf.com

Share this post


Link to post
Share on other sites
I believe BeginScene/EndScene exist mostly for the benefit of cards like PowerVR, which cache an entire scene''s worth of draw calls, and render it in small (32x32?) chunks.

xyzzy

Share this post


Link to post
Share on other sites
From the SDK doc:

Applications written in C++ notify Microsoft® Direct3D® that scene rendering is about to begin by calling the IDirect3DDevice9::BeginScene method. IDirect3DDevice9::BeginScene causes the system to check its internal data structures and the availability and validity of rendering surfaces. It also sets an internal flag to signal that a scene is in progress. After you begin a scene, you can call the various rendering methods to render the primitives or individual vertices that make up the objects in the scene. Attempts to call rendering methods when a scene is not in progress fail. For more information, see Rendering Primitives.

After you complete the scene, call the IDirect3DDevice9::EndScene method. The IDirect3DDevice9::EndScene method flushes cached data, verifies the integrity of rendering surfaces, and clears an internal flag that signals when a scene is in progress.


In fact, EndScene() is asynchronous, so it will return after it does it magic -- but the primitives might not actually be drawn on the card yet.

---
http://www.gapingwolf.com

Share this post


Link to post
Share on other sites
another way to look at it, it does end in Scene, meaning.. a group of multiple objects comprised together to make a scene/image/picture...

yeah, most examples ive ever seen draw everything between BeginScene and EndScene.. then Present!

Share this post


Link to post
Share on other sites
Just noticed:
fact, EndScene() is asynchronous, so it will return after it does it magic.

Maybe its a mistype should say immediately if this function is asynchronous.

By definition(MSDN):

Asynchronous call

A call to a function that is executed separately so that the caller can continue processing instructions without waiting for the function to return. Contrast with Synchronous call.

-------
Homepage: http://students.washington.edu/andrey

Share this post


Link to post
Share on other sites
Silly MSDN documents heh, *although* I would imagine after reading this thread that the function is actually synchronous because having it be asynchronus (do they do this with multithreading?) would be insanely difficult, but then again I''m a d3d n00b so what do I know...

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!