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 / texture_shader.py < prev    next >
Encoding:
Python Source  |  2008-12-07  |  14.3 KB  |  273 lines

  1. '''OpenGL extension NV.texture_shader
  2.  
  3. Overview (from the spec)
  4.     
  5.     Standard OpenGL and the ARB_multitexture extension define a
  6.     straightforward direct mechanism for mapping sets of texture
  7.     coordinates to filtered colors.  This extension provides a more
  8.     functional mechanism.
  9.     
  10.     OpenGL's standard texturing mechanism defines a set of texture
  11.     targets.  Each texture target defines how the texture image
  12.     is specified and accessed via a set of texture coordinates.
  13.     OpenGL 1.0 defines the 1D and 2D texture targets.  OpenGL 1.2
  14.     (and/or the EXT_texture3D extension) defines the 3D texture target.
  15.     The ARB_texture_cube_map extension defines the cube map texture
  16.     target.  Each texture unit's texture coordinate set is mapped to a
  17.     color using the unit's highest priority enabled texture target.
  18.     
  19.     This extension introduces texture shader stages.  A sequence of
  20.     texture shader stages provides a more flexible mechanism for mapping
  21.     sets of texture coordinates to texture unit RGBA results than standard
  22.     OpenGL.
  23.     
  24.     When the texture shader enable is on, the extension replaces the
  25.     conventional OpenGL mechanism for mapping sets of texture coordinates
  26.     to filtered colors with this extension's sequence of texture shader
  27.     stages.  
  28.     
  29.     Each texture shader stage runs one of 21 canned texture shader
  30.     programs.  These programs support conventional OpenGL texture
  31.     mapping but also support dependent texture accesses, dot product
  32.     texture programs, and special modes.  (3D texture mapping
  33.     texture shader operations are NOT provided by this extension;
  34.     3D texture mapping texture shader operations are added by the
  35.     NV_texture_shader2 extension that is layered on this extension.
  36.     See the NV_texture_shader2 specification.)
  37.     
  38.     To facilitate the new texture shader programs, this extension
  39.     introduces several new texture formats and variations on existing
  40.     formats.  Existing color texture formats are extended by introducing
  41.     new signed variants.  Two new types of texture formats (beyond colors)
  42.     are also introduced.  Texture offset groups encode two signed offsets,
  43.     and optionally a magnitude or a magnitude and an intensity.  The new
  44.     HILO (pronounced high-low) formats provide possibly signed, high
  45.     precision (16-bit) two-component textures.
  46.     
  47.     Each program takes as input the stage's interpolated texture
  48.     coordinate set (s,t,r,q).  Each program generates two results:
  49.     a shader stage result that may be used as an input to subsequent
  50.     shader stage programs, and a texture unit RGBA result that becomes the
  51.     texture color used by the texture unit's texture environment function
  52.     or becomes the initial value for the corresponding texture register
  53.     for register combiners. The texture unit RGBA result is always
  54.     an RGBA color, but the shader stage result may be one of an RGBA
  55.     color, a HILO value, a texture offset group, a floating-point value,
  56.     or an invalid result.  When both results are RGBA colors, the shader
  57.     stage result and the texture unit RGBA result are usually identical
  58.     (though not in all cases).
  59.     
  60.     Additionally, certain programs have a side-effect such as culling
  61.     the fragment or replacing the fragment's depth value.
  62.     
  63.     The twenty-one programs are briefly described:
  64.     
  65.     <none>
  66.     
  67.     1.   NONE - Always generates a (0,0,0,0) texture unit RGBA result.
  68.          Equivalent to disabling all texture targets in conventional
  69.          OpenGL.
  70.     
  71.     <conventional textures>
  72.     
  73.     2.   TEXTURE_1D - Accesses a 1D texture via (s/q).
  74.     
  75.     3.   TEXTURE_2D - Accesses a 2D texture via (s/q,t/q).
  76.     
  77.     4.   TEXTURE_RECTANGLE_NV - Accesses a rectangular texture via (s/q,t/q).
  78.     
  79.     5.   TEXTURE_CUBE_MAP_ARB - Accesses a cube map texture via (s,t,r).
  80.     
  81.     <special modes>
  82.     
  83.     6.   PASS_THROUGH_NV - Converts a texture coordinate (s,t,r,q)
  84.          directly to a [0,1] clamped (r,g,b,a) texture unit RGBA result.
  85.     
  86.     7.   CULL_FRAGMENT_NV - Culls the fragment based on the whether each
  87.          (s,t,r,q) is "greater than or equal to zero" or "less than zero".
  88.     
  89.     <offset textures>
  90.     
  91.     8.   OFFSET_TEXTURE_2D_NV - Transforms the signed (ds,dt) components
  92.          of a previous texture unit by a 2x2 floating-point matrix and
  93.          then uses the result to offset the stage's texture coordinates
  94.          for a 2D non-projective texture.
  95.     
  96.     9.   OFFSET_TEXTURE_2D_SCALE_NV - Same as above except the magnitude
  97.          component of the previous texture unit result scales the red,
  98.          green, and blue components of the unsigned RGBA texture 2D
  99.          access.
  100.     
  101.     10.  OFFSET_TEXTURE_RECTANGLE_NV - Similar to OFFSET_TEXTURE_2D_NV
  102.          except that the texture access is into a rectangular
  103.          non-projective texture.
  104.     
  105.     11.  OFFSET_TEXTURE_RECTANGLE_SCALE_NV - Similar to
  106.          OFFSET_TEXTURE_2D_SCALE_NV except that the texture access is
  107.          into a rectangular non-projective texture.
  108.     
  109.     <dependent textures>
  110.     
  111.     12.  DEPENDENT_AR_TEXTURE_2D_NV - Converts the alpha and red
  112.          components of a previous shader result into an (s,t) texture
  113.          coordinate set to access a 2D non-projective texture.
  114.     
  115.     13.  DEPENDENT_GB_TEXTURE_2D_NV - Converts the green and blue
  116.          components of a previous shader result into an (s,t) texture
  117.          coordinate set to access a 2D non-projective texture.
  118.     
  119.     <dot product textures>
  120.     
  121.     14.  DOT_PRODUCT_NV - Computes the dot product of the texture
  122.          shader's texture coordinate set (s,t,r) with some mapping of the
  123.          components of a previous texture shader result.  The component
  124.          mapping depends on the type (RGBA or HILO) and signedness of
  125.          the stage's previous texture input.  Other dot product texture
  126.          programs use the result of this program to compose a texture
  127.          coordinate set for a dependent texture access.  The color result
  128.          is undefined.
  129.     
  130.     15.  DOT_PRODUCT_TEXTURE_2D_NV - When preceded by a DOT_PRODUCT_NV
  131.          program in the previous texture shader stage, computes a second
  132.          similar dot product and composes the two dot products into (s,t)
  133.          texture coordinate set to access a 2D non-projective texture.
  134.     
  135.     16.  DOT_PRODUCT_TEXTURE_RECTANGLE_NV - Similar to
  136.          DOT_PRODUCT_TEXTURE_2D_NV except that the texture acces is into
  137.          a rectangular non-projective texture.  
  138.     
  139.     17.  DOT_PRODUCT_TEXTURE_CUBE_MAP_NV - When preceded by two
  140.          DOT_PRODUCT_NV programs in the previous two texture shader
  141.          stages, computes a third similar dot product and composes the
  142.          three dot products into (s,t,r) texture coordinate set to access
  143.          a cube map texture.
  144.     
  145.     18.  DOT_PRODUCT_REFLECT_CUBE_MAP_NV - When preceded by two
  146.          DOT_PRODUCT_NV programs in the previous two texture shader
  147.          stages, computes a third similar dot product and composes the
  148.          three dot products into a normal vector (Nx,Ny,Nz).  An eye
  149.          vector (Ex,Ey,Ez) is composed from the q texture coordinates of
  150.          the three stages.  A reflection vector (Rx,Ry,Rz) is computed
  151.          based on the normal and eye vectors.  The reflection vector
  152.          forms an (s,t,r) texture coordinate set to access a cube map
  153.          texture.
  154.     
  155.     19.  DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV - Operates like
  156.          DOT_PRODUCT_REFLECT_CUBE_MAP_NV except that the eye vector
  157.          (Ex,Ey,Ez) is a user-defined constant rather than composed from
  158.          the q coordinates of the three stages.
  159.     
  160.     20.  DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV - When used instead of the second
  161.          DOT_PRODUCT_NV program preceding
  162.          a DOT_PRODUCT_REFLECT_CUBE_MAP_NV or
  163.          DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV stage, the normal
  164.          vector forms an (s,t,r) texture  coordinate set to access a
  165.          cube map texture.
  166.     
  167.     <dot product depth replace>
  168.     
  169.     21.  DOT_PRODUCT_DEPTH_REPLACE_NV - When preceded by a DOT_PRODUCT_NV
  170.          program in the previous texture shader stage, computes a second
  171.          similar dot product and replaces the fragment's window-space
  172.          depth value with the first dot product results divided by
  173.          the second.  The texture unit RGBA result is (0,0,0,0).
  174.  
  175. The official definition of this extension is available here:
  176.     http://oss.sgi.com/projects/ogl-sample/registry/NV/texture_shader.txt
  177.  
  178. Automatically generated by the get_gl_extensions script, do not edit!
  179. '''
  180. from OpenGL import platform, constants, constant, arrays
  181. from OpenGL import extensions
  182. from OpenGL.GL import glget
  183. import ctypes
  184. EXTENSION_NAME = 'GL_NV_texture_shader'
  185. GL_OFFSET_TEXTURE_RECTANGLE_NV = constant.Constant( 'GL_OFFSET_TEXTURE_RECTANGLE_NV', 0x864C )
  186. GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV = constant.Constant( 'GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV', 0x864D )
  187. GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV = constant.Constant( 'GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV', 0x864E )
  188. GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV = constant.Constant( 'GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV', 0x86D9 )
  189. GL_UNSIGNED_INT_S8_S8_8_8_NV = constant.Constant( 'GL_UNSIGNED_INT_S8_S8_8_8_NV', 0x86DA )
  190. GL_UNSIGNED_INT_8_8_S8_S8_REV_NV = constant.Constant( 'GL_UNSIGNED_INT_8_8_S8_S8_REV_NV', 0x86DB )
  191. GL_DSDT_MAG_INTENSITY_NV = constant.Constant( 'GL_DSDT_MAG_INTENSITY_NV', 0x86DC )
  192. GL_SHADER_CONSISTENT_NV = constant.Constant( 'GL_SHADER_CONSISTENT_NV', 0x86DD )
  193. GL_TEXTURE_SHADER_NV = constant.Constant( 'GL_TEXTURE_SHADER_NV', 0x86DE )
  194. glget.addGLGetConstant( GL_TEXTURE_SHADER_NV, (1,) )
  195. GL_SHADER_OPERATION_NV = constant.Constant( 'GL_SHADER_OPERATION_NV', 0x86DF )
  196. GL_CULL_MODES_NV = constant.Constant( 'GL_CULL_MODES_NV', 0x86E0 )
  197. GL_OFFSET_TEXTURE_MATRIX_NV = constant.Constant( 'GL_OFFSET_TEXTURE_MATRIX_NV', 0x86E1 )
  198. GL_OFFSET_TEXTURE_SCALE_NV = constant.Constant( 'GL_OFFSET_TEXTURE_SCALE_NV', 0x86E2 )
  199. GL_OFFSET_TEXTURE_BIAS_NV = constant.Constant( 'GL_OFFSET_TEXTURE_BIAS_NV', 0x86E3 )
  200. GL_PREVIOUS_TEXTURE_INPUT_NV = constant.Constant( 'GL_PREVIOUS_TEXTURE_INPUT_NV', 0x86E4 )
  201. GL_CONST_EYE_NV = constant.Constant( 'GL_CONST_EYE_NV', 0x86E5 )
  202. GL_PASS_THROUGH_NV = constant.Constant( 'GL_PASS_THROUGH_NV', 0x86E6 )
  203. GL_CULL_FRAGMENT_NV = constant.Constant( 'GL_CULL_FRAGMENT_NV', 0x86E7 )
  204. GL_OFFSET_TEXTURE_2D_NV = constant.Constant( 'GL_OFFSET_TEXTURE_2D_NV', 0x86E8 )
  205. GL_DEPENDENT_AR_TEXTURE_2D_NV = constant.Constant( 'GL_DEPENDENT_AR_TEXTURE_2D_NV', 0x86E9 )
  206. GL_DEPENDENT_GB_TEXTURE_2D_NV = constant.Constant( 'GL_DEPENDENT_GB_TEXTURE_2D_NV', 0x86EA )
  207. GL_DOT_PRODUCT_NV = constant.Constant( 'GL_DOT_PRODUCT_NV', 0x86EC )
  208. GL_DOT_PRODUCT_DEPTH_REPLACE_NV = constant.Constant( 'GL_DOT_PRODUCT_DEPTH_REPLACE_NV', 0x86ED )
  209. GL_DOT_PRODUCT_TEXTURE_2D_NV = constant.Constant( 'GL_DOT_PRODUCT_TEXTURE_2D_NV', 0x86EE )
  210. GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV = constant.Constant( 'GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV', 0x86F0 )
  211. GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV = constant.Constant( 'GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV', 0x86F1 )
  212. GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV = constant.Constant( 'GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV', 0x86F2 )
  213. GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV = constant.Constant( 'GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV', 0x86F3 )
  214. GL_HILO_NV = constant.Constant( 'GL_HILO_NV', 0x86F4 )
  215. GL_DSDT_NV = constant.Constant( 'GL_DSDT_NV', 0x86F5 )
  216. GL_DSDT_MAG_NV = constant.Constant( 'GL_DSDT_MAG_NV', 0x86F6 )
  217. GL_DSDT_MAG_VIB_NV = constant.Constant( 'GL_DSDT_MAG_VIB_NV', 0x86F7 )
  218. GL_HILO16_NV = constant.Constant( 'GL_HILO16_NV', 0x86F8 )
  219. GL_SIGNED_HILO_NV = constant.Constant( 'GL_SIGNED_HILO_NV', 0x86F9 )
  220. GL_SIGNED_HILO16_NV = constant.Constant( 'GL_SIGNED_HILO16_NV', 0x86FA )
  221. GL_SIGNED_RGBA_NV = constant.Constant( 'GL_SIGNED_RGBA_NV', 0x86FB )
  222. GL_SIGNED_RGBA8_NV = constant.Constant( 'GL_SIGNED_RGBA8_NV', 0x86FC )
  223. GL_SIGNED_RGB_NV = constant.Constant( 'GL_SIGNED_RGB_NV', 0x86FE )
  224. GL_SIGNED_RGB8_NV = constant.Constant( 'GL_SIGNED_RGB8_NV', 0x86FF )
  225. GL_SIGNED_LUMINANCE_NV = constant.Constant( 'GL_SIGNED_LUMINANCE_NV', 0x8701 )
  226. GL_SIGNED_LUMINANCE8_NV = constant.Constant( 'GL_SIGNED_LUMINANCE8_NV', 0x8702 )
  227. GL_SIGNED_LUMINANCE_ALPHA_NV = constant.Constant( 'GL_SIGNED_LUMINANCE_ALPHA_NV', 0x8703 )
  228. GL_SIGNED_LUMINANCE8_ALPHA8_NV = constant.Constant( 'GL_SIGNED_LUMINANCE8_ALPHA8_NV', 0x8704 )
  229. GL_SIGNED_ALPHA_NV = constant.Constant( 'GL_SIGNED_ALPHA_NV', 0x8705 )
  230. GL_SIGNED_ALPHA8_NV = constant.Constant( 'GL_SIGNED_ALPHA8_NV', 0x8706 )
  231. GL_SIGNED_INTENSITY_NV = constant.Constant( 'GL_SIGNED_INTENSITY_NV', 0x8707 )
  232. GL_SIGNED_INTENSITY8_NV = constant.Constant( 'GL_SIGNED_INTENSITY8_NV', 0x8708 )
  233. GL_DSDT8_NV = constant.Constant( 'GL_DSDT8_NV', 0x8709 )
  234. GL_DSDT8_MAG8_NV = constant.Constant( 'GL_DSDT8_MAG8_NV', 0x870A )
  235. GL_DSDT8_MAG8_INTENSITY8_NV = constant.Constant( 'GL_DSDT8_MAG8_INTENSITY8_NV', 0x870B )
  236. GL_SIGNED_RGB_UNSIGNED_ALPHA_NV = constant.Constant( 'GL_SIGNED_RGB_UNSIGNED_ALPHA_NV', 0x870C )
  237. GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV = constant.Constant( 'GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV', 0x870D )
  238. GL_HI_SCALE_NV = constant.Constant( 'GL_HI_SCALE_NV', 0x870E )
  239. glget.addGLGetConstant( GL_HI_SCALE_NV, (1,) )
  240. GL_LO_SCALE_NV = constant.Constant( 'GL_LO_SCALE_NV', 0x870F )
  241. glget.addGLGetConstant( GL_LO_SCALE_NV, (1,) )
  242. GL_DS_SCALE_NV = constant.Constant( 'GL_DS_SCALE_NV', 0x8710 )
  243. glget.addGLGetConstant( GL_DS_SCALE_NV, (1,) )
  244. GL_DT_SCALE_NV = constant.Constant( 'GL_DT_SCALE_NV', 0x8711 )
  245. glget.addGLGetConstant( GL_DT_SCALE_NV, (1,) )
  246. GL_MAGNITUDE_SCALE_NV = constant.Constant( 'GL_MAGNITUDE_SCALE_NV', 0x8712 )
  247. glget.addGLGetConstant( GL_MAGNITUDE_SCALE_NV, (1,) )
  248. GL_VIBRANCE_SCALE_NV = constant.Constant( 'GL_VIBRANCE_SCALE_NV', 0x8713 )
  249. glget.addGLGetConstant( GL_VIBRANCE_SCALE_NV, (1,) )
  250. GL_HI_BIAS_NV = constant.Constant( 'GL_HI_BIAS_NV', 0x8714 )
  251. glget.addGLGetConstant( GL_HI_BIAS_NV, (1,) )
  252. GL_LO_BIAS_NV = constant.Constant( 'GL_LO_BIAS_NV', 0x8715 )
  253. glget.addGLGetConstant( GL_LO_BIAS_NV, (1,) )
  254. GL_DS_BIAS_NV = constant.Constant( 'GL_DS_BIAS_NV', 0x8716 )
  255. glget.addGLGetConstant( GL_DS_BIAS_NV, (1,) )
  256. GL_DT_BIAS_NV = constant.Constant( 'GL_DT_BIAS_NV', 0x8717 )
  257. glget.addGLGetConstant( GL_DT_BIAS_NV, (1,) )
  258. GL_MAGNITUDE_BIAS_NV = constant.Constant( 'GL_MAGNITUDE_BIAS_NV', 0x8718 )
  259. glget.addGLGetConstant( GL_MAGNITUDE_BIAS_NV, (1,) )
  260. GL_VIBRANCE_BIAS_NV = constant.Constant( 'GL_VIBRANCE_BIAS_NV', 0x8719 )
  261. glget.addGLGetConstant( GL_VIBRANCE_BIAS_NV, (1,) )
  262. GL_TEXTURE_BORDER_VALUES_NV = constant.Constant( 'GL_TEXTURE_BORDER_VALUES_NV', 0x871A )
  263. GL_TEXTURE_HI_SIZE_NV = constant.Constant( 'GL_TEXTURE_HI_SIZE_NV', 0x871B )
  264. GL_TEXTURE_LO_SIZE_NV = constant.Constant( 'GL_TEXTURE_LO_SIZE_NV', 0x871C )
  265. GL_TEXTURE_DS_SIZE_NV = constant.Constant( 'GL_TEXTURE_DS_SIZE_NV', 0x871D )
  266. GL_TEXTURE_DT_SIZE_NV = constant.Constant( 'GL_TEXTURE_DT_SIZE_NV', 0x871E )
  267. GL_TEXTURE_MAG_SIZE_NV = constant.Constant( 'GL_TEXTURE_MAG_SIZE_NV', 0x871F )
  268.  
  269.  
  270. def glInitTextureShaderNV():
  271.     '''Return boolean indicating whether this extension is available'''
  272.     return extensions.hasGLExtension( EXTENSION_NAME )
  273.