I need to create a small clipped window which is a combination of a Rectangle and a Circle and Display objects that fit inside of that window clipping.
GL_SCISSOR_TEST will not work because it is just rectangle.
The only other solution i can find is GL_STENCIL*.
Is there any suggestions on how to make this peculiarly shaped polygon inclusion window can be created?
The goal of that code,disregard the glPushAttrib(GL_ALL_ATTRIB_BITS), is to make any sort of shape and make anything I draw appear only in that shape, and not outside of it.
The final product that I will be creating is an inclusion window that is in the shape of a circle/rectangle intersected, and I need a variety of different objects able to surf through that inclusion window without leaving it.
My code as I understand it creates a stencil_buffer setting all values to zero. I then create the square setting all the squares pixels to 1. I think change the stencil to draw if it is not equal to one. For some reason when I draw anything after the end of my code, It continues to draw right past the square and inside of it. This leads me to believe stencil_buffer isn’t functioning properly.
First, make sure you created your window with a stencil buffer. Call glGet with GL_STENCIL_BITS to check.
Second, you don’t want to write to the stencil buffer after you draw your defining rectangle. Call glStencilMask(0), or use GL_KEEP for all parameters of glStencilOp. (In this case, the first parameter is the important one to get right since you’re using GL_EQUAL.)