Skip to main content
GameDev.net gamedev.net
🔒 Locked

Rendering off-screen objects

Started by ShadowOfEden Dec 11, 2008 at 11:22 AM 1 replies 700+ views
Original Post
ShadowOfEden
ShadowOfEden
(This question can be more general, but since I'm using DirectX, I wanted a DirectX specific answer (if it makes a difference)) In my side-scrolling 2D game, I make sure that my object is on screen with a simple if(...) before sending it to the render method. My question is : is it right way to do it? When calling d3dspt->Draw(...) with coordinates that are offscreen, will DirectX try to render it offscreen with no results or will it ignore the command since it cannot render at that coordinate? Sure, my game right now is so 'light' that either ways wouldn't change anything, but I want to know the right way before moving on to bigger problems.
Erik Rufelt
Erik Rufelt
Yes, it's the right way. Are you drawing triangles, or sprites?
With triangles D3D will check every triangle against the screen to see if it's visible, while you only have to check the bounding box. For sprites it probably doesn't make much of a difference in that regard, but every Draw() call takes some time and you should minimize them if possible.
ShadowOfEden
ShadowOfEden
Quote:
Original post by Erik Rufelt
but every Draw() call takes some time and you should minimize them if possible.


That's what I thought. Thanks for the fast answer.

Topic Locked

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

Sign in to reply to this topic.