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 / NV / occlusion_query.py < prev    next >
Encoding:
Python Source  |  2008-12-07  |  6.1 KB  |  142 lines

  1. '''OpenGL extension NV.occlusion_query
  2.  
  3. Overview (from the spec)
  4.     
  5.     The HP_occlusion_test extension defines a mechanism whereby an
  6.     application can query the visibility of an object, where "visible"
  7.     means that at least one pixel passes the depth and stencil tests.
  8.     
  9.     The HP extension has two major shortcomings.
  10.     
  11.     - It returns the result as a simple GL_TRUE/GL_FALSE result, when in
  12.       fact it is often useful to know exactly how many pixels passed.
  13.     - It provides only a simple "stop-and-wait" model for using multiple
  14.       queries.  The application begins an occlusion test and ends it;
  15.       then, at some later point, it asks for the result, at which point
  16.       the driver must stop and wait until the result from the previous
  17.       test is back before the application can even begin the next one.
  18.       This is a very simple model, but its performance is mediocre when
  19.       an application wishes to perform many queries, and it eliminates
  20.       most of the opportunites for parallelism between the CPU and GPU.
  21.     
  22.     This extension solves both of those problems.  It returns as its
  23.     result the number of pixels that pass, and it provides an interface
  24.     conceptually similar to that of NV_fence that allows applications to
  25.     issue many occlusion queries before asking for the result of any one.
  26.     As a result, they can overlap the time it takes for the occlusion
  27.     query results to be returned with other, more useful work, such as
  28.     rendering other parts of the scene or performing other computations
  29.     on the CPU.
  30.     
  31.     There are many situations where a pixel count, rather than a boolean
  32.     result, is useful.
  33.     
  34.     - If the visibility test is an object bounding box being used to
  35.       decide whether to skip the object, sometimes it can be acceptable,
  36.       and beneficial to performance, to skip an object if less than some
  37.       threshold number of pixels could be visible.
  38.     - Knowing the number of pixels visible in the bounding box may also
  39.       help decide what level of detail a model should be drawn with.  If
  40.       only a few pixels are visible, a low-detail model may be
  41.       acceptable.  In general, this allows level-of-detail mechanisms to
  42.       be slightly less ad hoc.
  43.     - "Depth peeling" techniques, such as order-independent transparency,
  44.       would typically like to know when to stop rendering more layers; it
  45.       is difficult to come up with a way to determine a priori how many
  46.       layers to use.  A boolean count allows applications to stop when
  47.       more layers will not affect the image at all, but this will likely
  48.       be unacceptable for performance, with minimal gains to image
  49.       quality.  Instead, it makes more sense to stop rendering when the
  50.       number of pixels goes below a threshold; this should provide better
  51.       results than any of these other algorithms.
  52.     - Occlusion queries can be used as a replacement for glReadPixels of
  53.       the depth buffer to determine whether, say, a light source is
  54.       visible for the purposes of a lens flare effect or a halo to
  55.       simulate glare.  Pixel counts allow you to compute the percentage
  56.       of the light source that is visible, and the brightness of these
  57.       effects can be modulated accordingly.
  58.  
  59. The official definition of this extension is available here:
  60.     http://oss.sgi.com/projects/ogl-sample/registry/NV/occlusion_query.txt
  61.  
  62. Automatically generated by the get_gl_extensions script, do not edit!
  63. '''
  64. from OpenGL import platform, constants, constant, arrays
  65. from OpenGL import extensions
  66. from OpenGL.GL import glget
  67. import ctypes
  68. EXTENSION_NAME = 'GL_NV_occlusion_query'
  69. GL_PIXEL_COUNTER_BITS_NV = constant.Constant( 'GL_PIXEL_COUNTER_BITS_NV', 0x8864 )
  70. glget.addGLGetConstant( GL_PIXEL_COUNTER_BITS_NV, (1,) )
  71. GL_CURRENT_OCCLUSION_QUERY_ID_NV = constant.Constant( 'GL_CURRENT_OCCLUSION_QUERY_ID_NV', 0x8865 )
  72. glget.addGLGetConstant( GL_CURRENT_OCCLUSION_QUERY_ID_NV, (1,) )
  73. GL_PIXEL_COUNT_NV = constant.Constant( 'GL_PIXEL_COUNT_NV', 0x8866 )
  74. GL_PIXEL_COUNT_AVAILABLE_NV = constant.Constant( 'GL_PIXEL_COUNT_AVAILABLE_NV', 0x8867 )
  75. glGenOcclusionQueriesNV = platform.createExtensionFunction( 
  76.     'glGenOcclusionQueriesNV', dll=platform.GL,
  77.     extension=EXTENSION_NAME,
  78.     resultType=None, 
  79.     argTypes=(constants.GLsizei, arrays.GLuintArray,),
  80.     doc = 'glGenOcclusionQueriesNV( GLsizei(n), GLuintArray(ids) ) -> None',
  81.     argNames = ('n', 'ids',),
  82. )
  83.  
  84. glDeleteOcclusionQueriesNV = platform.createExtensionFunction( 
  85.     'glDeleteOcclusionQueriesNV', dll=platform.GL,
  86.     extension=EXTENSION_NAME,
  87.     resultType=None, 
  88.     argTypes=(constants.GLsizei, arrays.GLuintArray,),
  89.     doc = 'glDeleteOcclusionQueriesNV( GLsizei(n), GLuintArray(ids) ) -> None',
  90.     argNames = ('n', 'ids',),
  91. )
  92.  
  93. glIsOcclusionQueryNV = platform.createExtensionFunction( 
  94.     'glIsOcclusionQueryNV', dll=platform.GL,
  95.     extension=EXTENSION_NAME,
  96.     resultType=constants.GLboolean, 
  97.     argTypes=(constants.GLuint,),
  98.     doc = 'glIsOcclusionQueryNV( GLuint(id) ) -> constants.GLboolean',
  99.     argNames = ('id',),
  100. )
  101.  
  102. glBeginOcclusionQueryNV = platform.createExtensionFunction( 
  103.     'glBeginOcclusionQueryNV', dll=platform.GL,
  104.     extension=EXTENSION_NAME,
  105.     resultType=None, 
  106.     argTypes=(constants.GLuint,),
  107.     doc = 'glBeginOcclusionQueryNV( GLuint(id) ) -> None',
  108.     argNames = ('id',),
  109. )
  110.  
  111. glEndOcclusionQueryNV = platform.createExtensionFunction( 
  112.     'glEndOcclusionQueryNV', dll=platform.GL,
  113.     extension=EXTENSION_NAME,
  114.     resultType=None, 
  115.     argTypes=(),
  116.     doc = 'glEndOcclusionQueryNV(  ) -> None',
  117.     argNames = (),
  118. )
  119.  
  120. glGetOcclusionQueryivNV = platform.createExtensionFunction( 
  121.     'glGetOcclusionQueryivNV', dll=platform.GL,
  122.     extension=EXTENSION_NAME,
  123.     resultType=None, 
  124.     argTypes=(constants.GLuint, constants.GLenum, arrays.GLintArray,),
  125.     doc = 'glGetOcclusionQueryivNV( GLuint(id), GLenum(pname), GLintArray(params) ) -> None',
  126.     argNames = ('id', 'pname', 'params',),
  127. )
  128.  
  129. glGetOcclusionQueryuivNV = platform.createExtensionFunction( 
  130.     'glGetOcclusionQueryuivNV', dll=platform.GL,
  131.     extension=EXTENSION_NAME,
  132.     resultType=None, 
  133.     argTypes=(constants.GLuint, constants.GLenum, arrays.GLuintArray,),
  134.     doc = 'glGetOcclusionQueryuivNV( GLuint(id), GLenum(pname), GLuintArray(params) ) -> None',
  135.     argNames = ('id', 'pname', 'params',),
  136. )
  137.  
  138.  
  139. def glInitOcclusionQueryNV():
  140.     '''Return boolean indicating whether this extension is available'''
  141.     return extensions.hasGLExtension( EXTENSION_NAME )
  142.