a way to clip a certain area of the screen?

Started by
4 comments, last by graveyard filla 19 years, 9 months ago
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!!
FTA, my 2D futuristic action MMORPG
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...).
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-
*points to his post above where he points out glViewport DOES NOT clip* [rolleyes]
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
--- Hellsp4wn ---AstralShadow | ScreamTech

VG Cats

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!!
FTA, my 2D futuristic action MMORPG

This topic is closed to new replies.

Advertisement