• Advertisement
Sign in to follow this  

OpenGL 2D clip

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

Hey guys, long time no post. I've been doing a game in 2D using ogl for some time. I am kinda new to opengl but i manage. I am kinda stuck though when trying to make some kind of clipping to the thngs i am drawing. I have an image of a television. When i turn it on on my game, i want it to render the game inside the television (so basically, i want a the scene to be rendered only on this rectangular region, and any part of the scene outside this television will not be drawn). I could fake this by separating the tv into layers, one at the front (frame) then back, and then draw the scene in between. Thing is, i dont want to do this. Is it possible to set like a clip or something similar in open gl? Thanks in advance!

Share this post


Link to post
Share on other sites
Advertisement
why yes, in fact. It's built in:

http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/scissor.html

That basically restricts drawing to a certain area of the screen. What you should probably do is draw the outside of the TV, but not the interior portion (like, draw 4 quads that surround the middle). Then draw the inside with the scissor box active.

Share this post


Link to post
Share on other sites
Thank you very much! I currently made the crappy layer subdivision solution, but this is in fact what i was looking for! I was going the wrong way with glClipPlane :(

Thanks again man!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement