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 / paletted_texture.py < prev    next >
Encoding:
Python Source  |  2008-12-07  |  4.9 KB  |  101 lines

  1. '''OpenGL extension EXT.paletted_texture
  2.  
  3. Overview (from the spec)
  4.     
  5.     EXT_paletted_texture defines new texture formats and new calls to
  6.     support the use of paletted textures in OpenGL.  A paletted texture is
  7.     defined by giving both a palette of colors and a set of image data which
  8.     is composed of indices into the palette.  The paletted texture cannot
  9.     function properly without both pieces of information so it increases the
  10.     work required to define a texture.  This is offset by the fact that the
  11.     overall amount of texture data can be reduced dramatically by factoring
  12.     redundant information out of the logical view of the texture and placing
  13.     it in the palette.
  14.     
  15.     Paletted textures provide several advantages over full-color textures:
  16.     
  17.     * As mentioned above, the amount of data required to define a
  18.     texture can be greatly reduced over what would be needed for full-color
  19.     specification.  For example, consider a source texture that has only 256
  20.     distinct colors in a 256 by 256 pixel grid.  Full-color representation
  21.     requires three bytes per pixel, taking 192K of texture data.  By putting
  22.     the distinct colors in a palette only eight bits are required per pixel,
  23.     reducing the 192K to 64K plus 768 bytes for the palette.  Now add an
  24.     alpha channel to the texture.  The full-color representation increases
  25.     by 64K while the paletted version would only increase by 256 bytes.
  26.     This reduction in space required is particularly important for hardware
  27.     accelerators where texture space is limited.
  28.     
  29.     * Paletted textures allow easy reuse of texture data for images
  30.     which require many similar but slightly different colored objects.
  31.     Consider a driving simulation with heavy traffic on the road.  Many of
  32.     the cars will be similar but with different color schemes.  If
  33.     full-color textures are used a separate texture would be needed for each
  34.     color scheme, while paletted textures allow the same basic index data to
  35.     be reused for each car, with a different palette to change the final
  36.     colors.
  37.     
  38.     * Paletted textures also allow use of all the palette tricks
  39.     developed for paletted displays.  Simple animation can be done, along
  40.     with strobing, glowing and other palette-cycling effects.  All of these
  41.     techniques can enhance the visual richness of a scene with very little
  42.     data.
  43.  
  44. The official definition of this extension is available here:
  45.     http://oss.sgi.com/projects/ogl-sample/registry/EXT/paletted_texture.txt
  46.  
  47. Automatically generated by the get_gl_extensions script, do not edit!
  48. '''
  49. from OpenGL import platform, constants, constant, arrays
  50. from OpenGL import extensions
  51. from OpenGL.GL import glget
  52. import ctypes
  53. EXTENSION_NAME = 'GL_EXT_paletted_texture'
  54. GL_COLOR_INDEX1_EXT = constant.Constant( 'GL_COLOR_INDEX1_EXT', 0x80E2 )
  55. GL_COLOR_INDEX2_EXT = constant.Constant( 'GL_COLOR_INDEX2_EXT', 0x80E3 )
  56. GL_COLOR_INDEX4_EXT = constant.Constant( 'GL_COLOR_INDEX4_EXT', 0x80E4 )
  57. GL_COLOR_INDEX8_EXT = constant.Constant( 'GL_COLOR_INDEX8_EXT', 0x80E5 )
  58. GL_COLOR_INDEX12_EXT = constant.Constant( 'GL_COLOR_INDEX12_EXT', 0x80E6 )
  59. GL_COLOR_INDEX16_EXT = constant.Constant( 'GL_COLOR_INDEX16_EXT', 0x80E7 )
  60. GL_TEXTURE_INDEX_SIZE_EXT = constant.Constant( 'GL_TEXTURE_INDEX_SIZE_EXT', 0x80ED )
  61. glColorTableEXT = platform.createExtensionFunction( 
  62.     'glColorTableEXT', dll=platform.GL,
  63.     extension=EXTENSION_NAME,
  64.     resultType=None, 
  65.     argTypes=(constants.GLenum, constants.GLenum, constants.GLsizei, constants.GLenum, constants.GLenum, ctypes.c_void_p,),
  66.     doc = 'glColorTableEXT( GLenum(target), GLenum(internalFormat), GLsizei(width), GLenum(format), GLenum(type), c_void_p(table) ) -> None',
  67.     argNames = ('target', 'internalFormat', 'width', 'format', 'type', 'table',),
  68. )
  69.  
  70. glGetColorTableEXT = platform.createExtensionFunction( 
  71.     'glGetColorTableEXT', dll=platform.GL,
  72.     extension=EXTENSION_NAME,
  73.     resultType=None, 
  74.     argTypes=(constants.GLenum, constants.GLenum, constants.GLenum, ctypes.c_void_p,),
  75.     doc = 'glGetColorTableEXT( GLenum(target), GLenum(format), GLenum(type), c_void_p(data) ) -> None',
  76.     argNames = ('target', 'format', 'type', 'data',),
  77. )
  78.  
  79. glGetColorTableParameterivEXT = platform.createExtensionFunction( 
  80.     'glGetColorTableParameterivEXT', dll=platform.GL,
  81.     extension=EXTENSION_NAME,
  82.     resultType=None, 
  83.     argTypes=(constants.GLenum, constants.GLenum, arrays.GLintArray,),
  84.     doc = 'glGetColorTableParameterivEXT( GLenum(target), GLenum(pname), GLintArray(params) ) -> None',
  85.     argNames = ('target', 'pname', 'params',),
  86. )
  87.  
  88. glGetColorTableParameterfvEXT = platform.createExtensionFunction( 
  89.     'glGetColorTableParameterfvEXT', dll=platform.GL,
  90.     extension=EXTENSION_NAME,
  91.     resultType=None, 
  92.     argTypes=(constants.GLenum, constants.GLenum, arrays.GLfloatArray,),
  93.     doc = 'glGetColorTableParameterfvEXT( GLenum(target), GLenum(pname), GLfloatArray(params) ) -> None',
  94.     argNames = ('target', 'pname', 'params',),
  95. )
  96.  
  97.  
  98. def glInitPalettedTextureEXT():
  99.     '''Return boolean indicating whether this extension is available'''
  100.     return extensions.hasGLExtension( EXTENSION_NAME )
  101.