home *** CD-ROM | disk | FTP | other *** search
/ Hackers Magazine 57 / CdHackersMagazineNr57.iso / Software / Multimedia / k3d-setup-0.7.11.0.exe / lib / site-packages / OpenGL / raw / GL / EXT / framebuffer_multisample.py < prev    next >
Encoding:
Python Source  |  2008-12-07  |  5.1 KB  |  102 lines

  1. '''OpenGL extension EXT.framebuffer_multisample
  2.  
  3. Overview (from the spec)
  4.     
  5.     This extension extends the EXT_framebuffer_object framework to
  6.     enable multisample rendering.
  7.     
  8.     The new operation RenderbufferStorageMultisampleEXT() allocates
  9.     storage for a renderbuffer object that can be used as a multisample
  10.     buffer.  A multisample render buffer image differs from a
  11.     single-sample render buffer image in that a multisample image has a
  12.     number of SAMPLES that is greater than zero.  No method is provided
  13.     for creating multisample texture images.
  14.     
  15.     All of the framebuffer-attachable images attached to a framebuffer
  16.     object must have the same number of SAMPLES or else the framebuffer
  17.     object is not "framebuffer complete".  If a framebuffer object with
  18.     multisample attachments is "framebuffer complete", then the
  19.     framebuffer object behaves as if SAMPLE_BUFFERS is one.
  20.     
  21.     In traditional multisample rendering, where
  22.     DRAW_FRAMEBUFFER_BINDING_EXT is zero and SAMPLE_BUFFERS is one, the
  23.     GL spec states that "the color sample values are resolved to a
  24.     single, displayable color each time a pixel is updated."  There are,
  25.     however, several modern hardware implementations that do not
  26.     actually resolve for each sample update, but instead postpones the
  27.     resolve operation to a later time and resolve a batch of sample
  28.     updates at a time.  This is OK as long as the implementation behaves
  29.     "as if" it had resolved a sample-at-a-time. Unfortunately, however,
  30.     honoring the "as if" rule can sometimes degrade performance.
  31.     
  32.     In contrast, when DRAW_FRAMEBUFFER_BINDING_EXT is an
  33.     application-created framebuffer object, MULTISAMPLE is enabled, and
  34.     SAMPLE_BUFFERS is one, there is no implicit per-sample-update
  35.     resolve.  Instead, the application explicitly controls when the
  36.     resolve operation is performed.  The resolve operation is affected
  37.     by calling BlitFramebufferEXT (provided by the EXT_framebuffer_blit
  38.     extension) where the source is a multisample application-created
  39.     framebuffer object and the destination is a single-sample
  40.     framebuffer object (either application-created or window-system
  41.     provided).
  42.     
  43.     This design for multisample resolve more closely matches current
  44.     hardware, but still permits implementations which choose to resolve
  45.     a single sample at a time.  If hardware that implementes the
  46.     multisample resololution "one sample at a time" exposes
  47.     EXT_framebuffer_multisample, it could perform the implicit resolve
  48.     to a driver-managed hidden surface, then read from that surface when
  49.     the application calls BlitFramebufferEXT.
  50.     
  51.     Another motivation for granting the application explicit control
  52.     over the multisample resolve operation has to do with the
  53.     flexibility afforded by EXT_framebuffer_object.  Previously, a
  54.     drawable (window or pbuffer) had exclusive access to all of its
  55.     buffers.  There was no mechanism for sharing a buffer across
  56.     multiple drawables.  Under EXT_framebuffer_object, however, a
  57.     mechanism exists for sharing a framebuffer-attachable image across
  58.     several framebuffer objects, as well as sharing an image between a
  59.     framebuffer object and a texture.  If we had retained the "implicit"
  60.     resolve from traditional multisampled rendering, and allowed the
  61.     creation of "multisample" format renderbuffers, then this type of
  62.     sharing would have lead to two problematic situations:
  63.     
  64.       * Two contexts, which shared renderbuffers, might perform
  65.         competing resolve operations into the same single-sample buffer
  66.         with ambiguous results.
  67.     
  68.       * It would have introduced the unfortunate ability to use the
  69.         single-sample buffer as a texture while MULTISAMPLE is ENABLED.
  70.     
  71.     By using the BlitFramebufferEXT from EXT_framebuffer_blit as an
  72.     explicit resolve to serialize access to the multisampeld contents
  73.     and eliminate the implicit per-sample resolve operation, we avoid
  74.     both of these problems.
  75.  
  76. The official definition of this extension is available here:
  77.     http://oss.sgi.com/projects/ogl-sample/registry/EXT/framebuffer_multisample.txt
  78.  
  79. Automatically generated by the get_gl_extensions script, do not edit!
  80. '''
  81. from OpenGL import platform, constants, constant, arrays
  82. from OpenGL import extensions
  83. from OpenGL.GL import glget
  84. import ctypes
  85. EXTENSION_NAME = 'GL_EXT_framebuffer_multisample'
  86. GL_RENDERBUFFER_SAMPLES_EXT = constant.Constant( 'GL_RENDERBUFFER_SAMPLES_EXT', 0x8CAB )
  87. GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT = constant.Constant( 'GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT', 0x8D56 )
  88. GL_MAX_SAMPLES_EXT = constant.Constant( 'GL_MAX_SAMPLES_EXT', 0x8D57 )
  89. glRenderbufferStorageMultisampleEXT = platform.createExtensionFunction( 
  90.     'glRenderbufferStorageMultisampleEXT', dll=platform.GL,
  91.     extension=EXTENSION_NAME,
  92.     resultType=None, 
  93.     argTypes=(constants.GLenum, constants.GLsizei, constants.GLenum, constants.GLsizei, constants.GLsizei,),
  94.     doc = 'glRenderbufferStorageMultisampleEXT( GLenum(target), GLsizei(samples), GLenum(internalformat), GLsizei(width), GLsizei(height) ) -> None',
  95.     argNames = ('target', 'samples', 'internalformat', 'width', 'height',),
  96. )
  97.  
  98.  
  99. def glInitFramebufferMultisampleEXT():
  100.     '''Return boolean indicating whether this extension is available'''
  101.     return extensions.hasGLExtension( EXTENSION_NAME )
  102.