1
votes

I have a question about clipping in OpenGL. So I have a small viewport and I want to render one part of a large image. If I draw a large image like

glEnable(GL_TEXTURE_RECTANGLE)

glColor3f(1,1,1)

glTexCoord2f(0,height)
glVertex2f(0,0)

glTexdoord2f(width,height)
glVertex2f(width,0)

glTexCoord2f(width,0)
glVertex2f(width,height)

glTexCoord(0,0)
glVertex2f(0,height)

The width and height is the size of the image(texture), which is much larger than the viewport.

My question is: Is OpenGL going to firstly clip the rectangle with respect to the size of viewport and then draw, or firstly render the whole image and then clip?

1

1 Answers

1
votes

It will first clip the geometry, then draw. More specifically, OpenGL does all the geometry processing before going down to render individual framebuffer elements (pixels). Here's a relevant quote from the 3.3 GL spec (Section 2.4):

The final resulting primitives are clipped to a viewing volume in preparation for the next stage, rasterization. The rasterizer produces a series of framebuffer addresses and values using a two-dimensional description of a point, line segment, or polygon.