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_object.py < prev    next >
Encoding:
Python Source  |  2008-12-07  |  16.1 KB  |  306 lines

  1. '''OpenGL extension EXT.framebuffer_object
  2.  
  3. Overview (from the spec)
  4.     
  5.     This extension defines a simple interface for drawing to rendering
  6.     destinations other than the buffers provided to the GL by the
  7.     window-system.
  8.     
  9.     In this extension, these newly defined rendering destinations are
  10.     known collectively as "framebuffer-attachable images".  This
  11.     extension provides a mechanism for attaching framebuffer-attachable
  12.     images to the GL framebuffer as one of the standard GL logical
  13.     buffers: color, depth, and stencil.  (Attaching a
  14.     framebuffer-attachable image to the accum logical buffer is left for
  15.     a future extension to define).  When a framebuffer-attachable image
  16.     is attached to the framebuffer, it is used as the source and
  17.     destination of fragment operations as described in Chapter 4.
  18.     
  19.     By allowing the use of a framebuffer-attachable image as a rendering
  20.     destination, this extension enables a form of "offscreen" rendering.
  21.     Furthermore, "render to texture" is supported by allowing the images
  22.     of a texture to be used as framebuffer-attachable images.  A
  23.     particular image of a texture object is selected for use as a
  24.     framebuffer-attachable image by specifying the mipmap level, cube
  25.     map face (for a cube map texture), and z-offset (for a 3D texture)
  26.     that identifies the image.  The "render to texture" semantics of
  27.     this extension are similar to performing traditional rendering to
  28.     the framebuffer, followed immediately by a call to CopyTexSubImage.
  29.     However, by using this extension instead, an application can achieve
  30.     the same effect, but with the advantage that the GL can usually
  31.     eliminate the data copy that would have been incurred by calling
  32.     CopyTexSubImage.
  33.     
  34.     This extension also defines a new GL object type, called a
  35.     "renderbuffer", which encapsulates a single 2D pixel image.  The
  36.     image of renderbuffer can be used as a framebuffer-attachable image
  37.     for generalized offscreen rendering and it also provides a means to
  38.     support rendering to GL logical buffer types which have no
  39.     corresponding texture format (stencil, accum, etc).  A renderbuffer
  40.     is similar to a texture in that both renderbuffers and textures can
  41.     be independently allocated and shared among multiple contexts.  The
  42.     framework defined by this extension is general enough that support
  43.     for attaching images from GL objects other than textures and
  44.     renderbuffers could be added by layered extensions.
  45.     
  46.     To facilitate efficient switching between collections of
  47.     framebuffer-attachable images, this extension introduces another new
  48.     GL object, called a framebuffer object.  A framebuffer object
  49.     contains the state that defines the traditional GL framebuffer,
  50.     including its set of images.  Prior to this extension, it was the
  51.     window-system which defined and managed this collection of images,
  52.     traditionally by grouping them into a "drawable".  The window-system
  53.     API's would also provide a function (i.e., wglMakeCurrent,
  54.     glXMakeCurrent, aglSetDrawable, etc.) to bind a drawable with a GL
  55.     context (as is done in the WGL_ARB_pbuffer extension).  In this
  56.     extension however, this functionality is subsumed by the GL and the
  57.     GL provides the function BindFramebufferEXT to bind a framebuffer
  58.     object to the current context.  Later, the context can bind back to
  59.     the window-system-provided framebuffer in order to display rendered
  60.     content.
  61.     
  62.     Previous extensions that enabled rendering to a texture have been
  63.     much more complicated.  One example is the combination of
  64.     ARB_pbuffer and ARB_render_texture, both of which are window-system
  65.     extensions.  This combination requires calling MakeCurrent, an
  66.     operation that may be expensive, to switch between the window and
  67.     the pbuffer drawables.  An application must create one pbuffer per
  68.     renderable texture in order to portably use ARB_render_texture.  An
  69.     application must maintain at least one GL context per texture
  70.     format, because each context can only operate on a single
  71.     pixelformat or FBConfig.  All of these characteristics make
  72.     ARB_render_texture both inefficient and cumbersome to use.
  73.     
  74.     EXT_framebuffer_object, on the other hand, is both simpler to use
  75.     and more efficient than ARB_render_texture.  The
  76.     EXT_framebuffer_object API is contained wholly within the GL API and
  77.     has no (non-portable) window-system components.  Under
  78.     EXT_framebuffer_object, it is not necessary to create a second GL
  79.     context when rendering to a texture image whose format differs from
  80.     that of the window.  Finally, unlike the pbuffers of
  81.     ARB_render_texture, a single framebuffer object can facilitate
  82.     rendering to an unlimited number of texture objects.
  83.  
  84. The official definition of this extension is available here:
  85.     http://oss.sgi.com/projects/ogl-sample/registry/EXT/framebuffer_object.txt
  86.  
  87. Automatically generated by the get_gl_extensions script, do not edit!
  88. '''
  89. from OpenGL import platform, constants, constant, arrays
  90. from OpenGL import extensions
  91. from OpenGL.GL import glget
  92. import ctypes
  93. EXTENSION_NAME = 'GL_EXT_framebuffer_object'
  94. GL_INVALID_FRAMEBUFFER_OPERATION_EXT = constant.Constant( 'GL_INVALID_FRAMEBUFFER_OPERATION_EXT', 0x506 )
  95. GL_MAX_RENDERBUFFER_SIZE_EXT = constant.Constant( 'GL_MAX_RENDERBUFFER_SIZE_EXT', 0x84E8 )
  96. glget.addGLGetConstant( GL_MAX_RENDERBUFFER_SIZE_EXT, (1,) )
  97. GL_FRAMEBUFFER_BINDING_EXT = constant.Constant( 'GL_FRAMEBUFFER_BINDING_EXT', 0x8CA6 )
  98. glget.addGLGetConstant( GL_FRAMEBUFFER_BINDING_EXT, (1,) )
  99. GL_RENDERBUFFER_BINDING_EXT = constant.Constant( 'GL_RENDERBUFFER_BINDING_EXT', 0x8CA7 )
  100. glget.addGLGetConstant( GL_RENDERBUFFER_BINDING_EXT, (1,) )
  101. GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT = constant.Constant( 'GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT', 0x8CD0 )
  102. GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT = constant.Constant( 'GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT', 0x8CD1 )
  103. GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT = constant.Constant( 'GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT', 0x8CD2 )
  104. GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT = constant.Constant( 'GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT', 0x8CD3 )
  105. GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT = constant.Constant( 'GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT', 0x8CD4 )
  106. GL_FRAMEBUFFER_COMPLETE_EXT = constant.Constant( 'GL_FRAMEBUFFER_COMPLETE_EXT', 0x8CD5 )
  107. GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT = constant.Constant( 'GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT', 0x8CD6 )
  108. GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT = constant.Constant( 'GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT', 0x8CD7 )
  109. GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT = constant.Constant( 'GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT', 0x8CD9 )
  110. GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT = constant.Constant( 'GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT', 0x8CDA )
  111. GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT = constant.Constant( 'GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT', 0x8CDB )
  112. GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT = constant.Constant( 'GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT', 0x8CDC )
  113. GL_FRAMEBUFFER_UNSUPPORTED_EXT = constant.Constant( 'GL_FRAMEBUFFER_UNSUPPORTED_EXT', 0x8CDD )
  114. GL_MAX_COLOR_ATTACHMENTS_EXT = constant.Constant( 'GL_MAX_COLOR_ATTACHMENTS_EXT', 0x8CDF )
  115. glget.addGLGetConstant( GL_MAX_COLOR_ATTACHMENTS_EXT, (1,) )
  116. GL_COLOR_ATTACHMENT0_EXT = constant.Constant( 'GL_COLOR_ATTACHMENT0_EXT', 0x8CE0 )
  117. GL_COLOR_ATTACHMENT1_EXT = constant.Constant( 'GL_COLOR_ATTACHMENT1_EXT', 0x8CE1 )
  118. GL_COLOR_ATTACHMENT2_EXT = constant.Constant( 'GL_COLOR_ATTACHMENT2_EXT', 0x8CE2 )
  119. GL_COLOR_ATTACHMENT3_EXT = constant.Constant( 'GL_COLOR_ATTACHMENT3_EXT', 0x8CE3 )
  120. GL_COLOR_ATTACHMENT4_EXT = constant.Constant( 'GL_COLOR_ATTACHMENT4_EXT', 0x8CE4 )
  121. GL_COLOR_ATTACHMENT5_EXT = constant.Constant( 'GL_COLOR_ATTACHMENT5_EXT', 0x8CE5 )
  122. GL_COLOR_ATTACHMENT6_EXT = constant.Constant( 'GL_COLOR_ATTACHMENT6_EXT', 0x8CE6 )
  123. GL_COLOR_ATTACHMENT7_EXT = constant.Constant( 'GL_COLOR_ATTACHMENT7_EXT', 0x8CE7 )
  124. GL_COLOR_ATTACHMENT8_EXT = constant.Constant( 'GL_COLOR_ATTACHMENT8_EXT', 0x8CE8 )
  125. GL_COLOR_ATTACHMENT9_EXT = constant.Constant( 'GL_COLOR_ATTACHMENT9_EXT', 0x8CE9 )
  126. GL_COLOR_ATTACHMENT10_EXT = constant.Constant( 'GL_COLOR_ATTACHMENT10_EXT', 0x8CEA )
  127. GL_COLOR_ATTACHMENT11_EXT = constant.Constant( 'GL_COLOR_ATTACHMENT11_EXT', 0x8CEB )
  128. GL_COLOR_ATTACHMENT12_EXT = constant.Constant( 'GL_COLOR_ATTACHMENT12_EXT', 0x8CEC )
  129. GL_COLOR_ATTACHMENT13_EXT = constant.Constant( 'GL_COLOR_ATTACHMENT13_EXT', 0x8CED )
  130. GL_COLOR_ATTACHMENT14_EXT = constant.Constant( 'GL_COLOR_ATTACHMENT14_EXT', 0x8CEE )
  131. GL_COLOR_ATTACHMENT15_EXT = constant.Constant( 'GL_COLOR_ATTACHMENT15_EXT', 0x8CEF )
  132. GL_DEPTH_ATTACHMENT_EXT = constant.Constant( 'GL_DEPTH_ATTACHMENT_EXT', 0x8D00 )
  133. GL_STENCIL_ATTACHMENT_EXT = constant.Constant( 'GL_STENCIL_ATTACHMENT_EXT', 0x8D20 )
  134. GL_FRAMEBUFFER_EXT = constant.Constant( 'GL_FRAMEBUFFER_EXT', 0x8D40 )
  135. GL_RENDERBUFFER_EXT = constant.Constant( 'GL_RENDERBUFFER_EXT', 0x8D41 )
  136. GL_RENDERBUFFER_WIDTH_EXT = constant.Constant( 'GL_RENDERBUFFER_WIDTH_EXT', 0x8D42 )
  137. GL_RENDERBUFFER_HEIGHT_EXT = constant.Constant( 'GL_RENDERBUFFER_HEIGHT_EXT', 0x8D43 )
  138. GL_RENDERBUFFER_INTERNAL_FORMAT_EXT = constant.Constant( 'GL_RENDERBUFFER_INTERNAL_FORMAT_EXT', 0x8D44 )
  139. GL_STENCIL_INDEX1_EXT = constant.Constant( 'GL_STENCIL_INDEX1_EXT', 0x8D46 )
  140. GL_STENCIL_INDEX4_EXT = constant.Constant( 'GL_STENCIL_INDEX4_EXT', 0x8D47 )
  141. GL_STENCIL_INDEX8_EXT = constant.Constant( 'GL_STENCIL_INDEX8_EXT', 0x8D48 )
  142. GL_STENCIL_INDEX16_EXT = constant.Constant( 'GL_STENCIL_INDEX16_EXT', 0x8D49 )
  143. GL_RENDERBUFFER_RED_SIZE_EXT = constant.Constant( 'GL_RENDERBUFFER_RED_SIZE_EXT', 0x8D50 )
  144. GL_RENDERBUFFER_GREEN_SIZE_EXT = constant.Constant( 'GL_RENDERBUFFER_GREEN_SIZE_EXT', 0x8D51 )
  145. GL_RENDERBUFFER_BLUE_SIZE_EXT = constant.Constant( 'GL_RENDERBUFFER_BLUE_SIZE_EXT', 0x8D52 )
  146. GL_RENDERBUFFER_ALPHA_SIZE_EXT = constant.Constant( 'GL_RENDERBUFFER_ALPHA_SIZE_EXT', 0x8D53 )
  147. GL_RENDERBUFFER_DEPTH_SIZE_EXT = constant.Constant( 'GL_RENDERBUFFER_DEPTH_SIZE_EXT', 0x8D54 )
  148. GL_RENDERBUFFER_STENCIL_SIZE_EXT = constant.Constant( 'GL_RENDERBUFFER_STENCIL_SIZE_EXT', 0x8D55 )
  149. glIsRenderbufferEXT = platform.createExtensionFunction( 
  150.     'glIsRenderbufferEXT', dll=platform.GL,
  151.     extension=EXTENSION_NAME,
  152.     resultType=constants.GLboolean, 
  153.     argTypes=(constants.GLuint,),
  154.     doc = 'glIsRenderbufferEXT( GLuint(renderbuffer) ) -> constants.GLboolean',
  155.     argNames = ('renderbuffer',),
  156. )
  157.  
  158. glBindRenderbufferEXT = platform.createExtensionFunction( 
  159.     'glBindRenderbufferEXT', dll=platform.GL,
  160.     extension=EXTENSION_NAME,
  161.     resultType=None, 
  162.     argTypes=(constants.GLenum, constants.GLuint,),
  163.     doc = 'glBindRenderbufferEXT( GLenum(target), GLuint(renderbuffer) ) -> None',
  164.     argNames = ('target', 'renderbuffer',),
  165. )
  166.  
  167. glDeleteRenderbuffersEXT = platform.createExtensionFunction( 
  168.     'glDeleteRenderbuffersEXT', dll=platform.GL,
  169.     extension=EXTENSION_NAME,
  170.     resultType=None, 
  171.     argTypes=(constants.GLsizei, arrays.GLuintArray,),
  172.     doc = 'glDeleteRenderbuffersEXT( GLsizei(n), GLuintArray(renderbuffers) ) -> None',
  173.     argNames = ('n', 'renderbuffers',),
  174. )
  175.  
  176. glGenRenderbuffersEXT = platform.createExtensionFunction( 
  177.     'glGenRenderbuffersEXT', dll=platform.GL,
  178.     extension=EXTENSION_NAME,
  179.     resultType=None, 
  180.     argTypes=(constants.GLsizei, arrays.GLuintArray,),
  181.     doc = 'glGenRenderbuffersEXT( GLsizei(n), GLuintArray(renderbuffers) ) -> None',
  182.     argNames = ('n', 'renderbuffers',),
  183. )
  184.  
  185. glRenderbufferStorageEXT = platform.createExtensionFunction( 
  186.     'glRenderbufferStorageEXT', dll=platform.GL,
  187.     extension=EXTENSION_NAME,
  188.     resultType=None, 
  189.     argTypes=(constants.GLenum, constants.GLenum, constants.GLsizei, constants.GLsizei,),
  190.     doc = 'glRenderbufferStorageEXT( GLenum(target), GLenum(internalformat), GLsizei(width), GLsizei(height) ) -> None',
  191.     argNames = ('target', 'internalformat', 'width', 'height',),
  192. )
  193.  
  194. glGetRenderbufferParameterivEXT = platform.createExtensionFunction( 
  195.     'glGetRenderbufferParameterivEXT', dll=platform.GL,
  196.     extension=EXTENSION_NAME,
  197.     resultType=None, 
  198.     argTypes=(constants.GLenum, constants.GLenum, arrays.GLintArray,),
  199.     doc = 'glGetRenderbufferParameterivEXT( GLenum(target), GLenum(pname), GLintArray(params) ) -> None',
  200.     argNames = ('target', 'pname', 'params',),
  201. )
  202.  
  203. glIsFramebufferEXT = platform.createExtensionFunction( 
  204.     'glIsFramebufferEXT', dll=platform.GL,
  205.     extension=EXTENSION_NAME,
  206.     resultType=constants.GLboolean, 
  207.     argTypes=(constants.GLuint,),
  208.     doc = 'glIsFramebufferEXT( GLuint(framebuffer) ) -> constants.GLboolean',
  209.     argNames = ('framebuffer',),
  210. )
  211.  
  212. glBindFramebufferEXT = platform.createExtensionFunction( 
  213.     'glBindFramebufferEXT', dll=platform.GL,
  214.     extension=EXTENSION_NAME,
  215.     resultType=None, 
  216.     argTypes=(constants.GLenum, constants.GLuint,),
  217.     doc = 'glBindFramebufferEXT( GLenum(target), GLuint(framebuffer) ) -> None',
  218.     argNames = ('target', 'framebuffer',),
  219. )
  220.  
  221. glDeleteFramebuffersEXT = platform.createExtensionFunction( 
  222.     'glDeleteFramebuffersEXT', dll=platform.GL,
  223.     extension=EXTENSION_NAME,
  224.     resultType=None, 
  225.     argTypes=(constants.GLsizei, arrays.GLuintArray,),
  226.     doc = 'glDeleteFramebuffersEXT( GLsizei(n), GLuintArray(framebuffers) ) -> None',
  227.     argNames = ('n', 'framebuffers',),
  228. )
  229.  
  230. glGenFramebuffersEXT = platform.createExtensionFunction( 
  231.     'glGenFramebuffersEXT', dll=platform.GL,
  232.     extension=EXTENSION_NAME,
  233.     resultType=None, 
  234.     argTypes=(constants.GLsizei, arrays.GLuintArray,),
  235.     doc = 'glGenFramebuffersEXT( GLsizei(n), GLuintArray(framebuffers) ) -> None',
  236.     argNames = ('n', 'framebuffers',),
  237. )
  238.  
  239. glCheckFramebufferStatusEXT = platform.createExtensionFunction( 
  240.     'glCheckFramebufferStatusEXT', dll=platform.GL,
  241.     extension=EXTENSION_NAME,
  242.     resultType=constants.GLenum, 
  243.     argTypes=(constants.GLenum,),
  244.     doc = 'glCheckFramebufferStatusEXT( GLenum(target) ) -> constants.GLenum',
  245.     argNames = ('target',),
  246. )
  247.  
  248. glFramebufferTexture1DEXT = platform.createExtensionFunction( 
  249.     'glFramebufferTexture1DEXT', dll=platform.GL,
  250.     extension=EXTENSION_NAME,
  251.     resultType=None, 
  252.     argTypes=(constants.GLenum, constants.GLenum, constants.GLenum, constants.GLuint, constants.GLint,),
  253.     doc = 'glFramebufferTexture1DEXT( GLenum(target), GLenum(attachment), GLenum(textarget), GLuint(texture), GLint(level) ) -> None',
  254.     argNames = ('target', 'attachment', 'textarget', 'texture', 'level',),
  255. )
  256.  
  257. glFramebufferTexture2DEXT = platform.createExtensionFunction( 
  258.     'glFramebufferTexture2DEXT', dll=platform.GL,
  259.     extension=EXTENSION_NAME,
  260.     resultType=None, 
  261.     argTypes=(constants.GLenum, constants.GLenum, constants.GLenum, constants.GLuint, constants.GLint,),
  262.     doc = 'glFramebufferTexture2DEXT( GLenum(target), GLenum(attachment), GLenum(textarget), GLuint(texture), GLint(level) ) -> None',
  263.     argNames = ('target', 'attachment', 'textarget', 'texture', 'level',),
  264. )
  265.  
  266. glFramebufferTexture3DEXT = platform.createExtensionFunction( 
  267.     'glFramebufferTexture3DEXT', dll=platform.GL,
  268.     extension=EXTENSION_NAME,
  269.     resultType=None, 
  270.     argTypes=(constants.GLenum, constants.GLenum, constants.GLenum, constants.GLuint, constants.GLint, constants.GLint,),
  271.     doc = 'glFramebufferTexture3DEXT( GLenum(target), GLenum(attachment), GLenum(textarget), GLuint(texture), GLint(level), GLint(zoffset) ) -> None',
  272.     argNames = ('target', 'attachment', 'textarget', 'texture', 'level', 'zoffset',),
  273. )
  274.  
  275. glFramebufferRenderbufferEXT = platform.createExtensionFunction( 
  276.     'glFramebufferRenderbufferEXT', dll=platform.GL,
  277.     extension=EXTENSION_NAME,
  278.     resultType=None, 
  279.     argTypes=(constants.GLenum, constants.GLenum, constants.GLenum, constants.GLuint,),
  280.     doc = 'glFramebufferRenderbufferEXT( GLenum(target), GLenum(attachment), GLenum(renderbuffertarget), GLuint(renderbuffer) ) -> None',
  281.     argNames = ('target', 'attachment', 'renderbuffertarget', 'renderbuffer',),
  282. )
  283.  
  284. glGetFramebufferAttachmentParameterivEXT = platform.createExtensionFunction( 
  285.     'glGetFramebufferAttachmentParameterivEXT', dll=platform.GL,
  286.     extension=EXTENSION_NAME,
  287.     resultType=None, 
  288.     argTypes=(constants.GLenum, constants.GLenum, constants.GLenum, arrays.GLintArray,),
  289.     doc = 'glGetFramebufferAttachmentParameterivEXT( GLenum(target), GLenum(attachment), GLenum(pname), GLintArray(params) ) -> None',
  290.     argNames = ('target', 'attachment', 'pname', 'params',),
  291. )
  292.  
  293. glGenerateMipmapEXT = platform.createExtensionFunction( 
  294.     'glGenerateMipmapEXT', dll=platform.GL,
  295.     extension=EXTENSION_NAME,
  296.     resultType=None, 
  297.     argTypes=(constants.GLenum,),
  298.     doc = 'glGenerateMipmapEXT( GLenum(target) ) -> None',
  299.     argNames = ('target',),
  300. )
  301.  
  302.  
  303. def glInitFramebufferObjectEXT():
  304.     '''Return boolean indicating whether this extension is available'''
  305.     return extensions.hasGLExtension( EXTENSION_NAME )
  306.