The glAddSwapHintRectWIN function specifies a set of rectangles that are to be copied by SwapBuffers.

void glAddSwapHintRectWIN(
  GLint x,
  GLint y,
  GLsizei width,
  GLsizei height


The x-coordinate (in window coordinates) of the lower-left corner of the hint region rectangle.
The y-coordinate (in window coordinates) of the lower-left corner of the hint region rectangle.
The width of the hint region rectangle.
The height of the hint region rectangle.


The glAddSwapHintRectWIN function speeds up animation by reducing the amount of repainting between frames. With glAddSwapHintRectWIN, you specify a set of rectangular areas that you want copied when you call SwapBuffers. When you do not specify any rectangles with glAddSwapHintRectWIN before calling SwapBuffers, the entire framebuffer is swapped. Using glAddSwapHintRectWIN to copy only changed parts of the buffer can significantly increase the performance of SwapBuffers, especially when SwapBuffers is implemented in software.

The glAddSwapHintRectWIN function adds a rectangle to the hint region. When the PFD_SWAP_COPY flag of the PIXELFORMATDESCRIPTOR pixel format structure is set, SwapBuffers uses this region to clip the copying of the back buffer to the front buffer. You don't specify PFD_SWAP_COPY; it is set by capable hardware. The hint region is cleared after each call to SwapBuffers. With some hardware configurations, SwapBuffers can ignore the hint region and exchange the entire buffer. SwapBuffers is implemented by the system, not by the application.

OpenGL maintains a separate hint region for each window. When you call glAddSwapHintRectWIN on any rendering contexts associated with a window, the hint rectangles are combined into a single region.

Call glAddSwapHintRectWIN with a bounding rectangle for each object drawn for a frame and for each rectangle cleared to erase previous frame objects.

Note  The glAddSwapHintRectWIN function is an extension function that is not part of the standard OpenGL library but is part of the GL_WIN_swap_hint extension. To check whether your implementation of OpenGL supports glAddSwapHintRectWIN, call glGetString(GL_EXTENSIONS). If it returns GL_WIN_swap_hint, glAddSwapHintRectWIN is supported. To obtain the address of an extension function, call wglGetProcAddress.


  Windows NT/2000: Requires Windows NT 3.5 or later.
  Windows 95/98: Requires Windows 95 or later. Available as a redistributable for Windows 95.
  Header: Declared in Gl.h.
  Library: Use Opengl32.lib.

See Also

glGetString, PIXELFORMATDESCRIPTOR, SwapBuffers, wglGetProcAddress


Community Additions