Jump to content
  • Advertisement
Sign in to follow this  
graveyard filla

OpenGL a way to clip a certain area of the screen?

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

hi, im working on a map editor for my game. anyway, i make the screen resolution extra big, so i can fit my map on the screen plus buttons and stuff surrounding it. the problem is the way my map scrolls, i draw a slightly different amount of the tiles depending on the scrolling situation. this is fine in game since the the screen size naturally clips the map (also i have a menu bar on the side which also clips it... hmm, you know, i can just draw a black quad over the edges so it clips!!! ok, so the problem is solved, but im still curious, is there any OpenGL command to set a clipping area on the screen like SDL has? thanks for any help!!

Share this post


Link to post
Share on other sites
Advertisement
the scissor test can be used to restrict drawing to a certain part of the screen (glScissor iirc).

glViewport might give the effect of clipping but infact DOES NOT do so if the implimention follows the spec properly (I mention this because someone complained once than his ATI drivers were broken coz his glViewport command was clipping on his NV card but not on his laptop with an ATI one...).

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I would imagine that changing the settings on your viewport from the entire height and width of the screen to a specific section of the screen would solve this problem. When you define your viewport with glViewport(), you can specify a region of the screen to draw to. You would normally use glViewport(0, 0, width, height) to use the entire screen as your viewport. Try changing that to the area you actually want to render things to the screen.

You should check out some information on nehe.gamedev.net for the multiple viewport tutorial. It's lesson #42 on his site.

-noix-

Share this post


Link to post
Share on other sites
You could also use the stencil buffer. First draw a quad to the stencil buffer to define the map area, and turn on stencil testing and render the map. Then draw a quad to the whole screen that "NOT"s all the pixels, so that the drawable area inverts. Of course, this will be somewhat slower, but it's only an editor, right? And you can't be using the stencil buffer already ^^. Maybe not the best solution, but it might work ;P

Share this post


Link to post
Share on other sites
thanks guys. actually, my method seems a lot easier, so im gunna stick with it. just draw a black quad over the area which i want clipped... thanks again!!

Share this post


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

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!