texture_compression.py :  » Game-2D-3D » PyOpenGL » PyOpenGL-3.0.1 » OpenGL » GL » ARB » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Game 2D 3D » PyOpenGL 
PyOpenGL » PyOpenGL 3.0.1 » OpenGL » GL » ARB » texture_compression.py
'''OpenGL extension ARB.texture_compression

This module customises the behaviour of the 
OpenGL.raw.GL.ARB.texture_compression to provide a more 
Python-friendly API

Overview (from thespec import 
  
  Compressing texture images can reduce texture memory utilization and
  improve performance when rendering textured primitives.  This extension
  allows OpenGL applications to use compressed texture images by providing:
  
      (1) A framework upon which extensions providing specific compressed
          image formats can be built.
  
      (2) A set of generic compressed internal formats that allow
          applications to specify that texture images should be stored in
          compressed form without needing to code for specific compression
          formats.
  
  An application can define compressed texture images by providing a texture
  image stored in a specific compressed image format.  This extension does
  not define any specific compressed image formats, but it does provide the
  mechanisms necessary to enable other extensions that do.
  
  An application can also define compressed texture images by providing an
  uncompressed texture image but specifying a compressed internal format.
  In this case, the GL will automatically compress the texture image using
  the appropriate image format.  Compressed internal formats can either be
  specific (as above) or generic.  Generic compressed internal formats are
  not actual image formats, but are instead mapped into one of the specific
  compressed formats provided by the GL (or to an uncompressed base internal
  format if no appropriate compressed format is available).  Generic
  compressed internal formats allow applications to use texture compression
  without needing to code to any particular compression algorithm.  Generic
  compressed formats allow the use of texture compression across a wide
  range of platforms with differing compression algorithms and also allow
  future GL implementations to substitute improved compression methods
  transparently.
  
  Compressed texture images can be obtained from theGLuncompressedform import 
  by calling GetTexImage and in compressed form by calling
  GetCompressedTexImageARB.  Queried compressed images can be saved and
  later reused by calling CompressedTexImage[123]DARB.  Pre-compressed
  texture images do not need to be processed by the GL and should
  significantly improve texture loading performance relative to uncompressed
  images.
  
  This extension does not define specific compressed image formats (e.g.,
  S3TC, FXT1), nor does it provide means to encode or decode such images.
  To support images in a specific compressed format, a hardware vendor
  would:
  
    (1) Provide a new extension defininig specific compressed
        <internalformat> and <format> tokens for TexImage[123]D,
        TexSubImage[123]D, CopyTexImage[12]D, CompressedTexImage[123]DARB,
        CompressedTexSubImage[123]DARB, and GetCompressedTexImageARB calls.
  
    (2) Specify the encoding of compressed images of that specific format.
  
    (3) Specify a method for deriving the size of compressed images of that
        specific format, using the <internalformat>, <width>, <height>,
        <depth> parameters, and (if necessary) the compressed image itself.

The official definition of this extension is available here:
http://www.opengl.org/registry/specs/ARB/texture_compression.txt
'''
from OpenGL import platform,constants,constant,arrays
from OpenGL import extensions,wrapper
from OpenGL.GL import glget
import ctypes
from OpenGL.raw.GL.ARB.texture_compression import *
### END AUTOGENERATED SECTION
from OpenGL.GL import images

for dimensions in (1,2,3):
    for function in ('glCompressedTexImage%sDARB','glCompressedTexSubImage%sDARB'):
        name = function%(dimensions,)
        globals()[ name ] = images.compressedImageFunction(
            globals()[ name ]
        )
        del name, function
    del dimensions

if glGetCompressedTexImageARB:
    def glGetCompressedTexImageARB( target, level, img=None ):
        """Retrieve a compressed texture image"""
        if img is None:
            length = glget.glGetTexLevelParameteriv(
                target, 0, 
                GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB, 
            )
            img = arrays.ArrayDataType.zeros( (length,), constants.GL_UNSIGNED_BYTE )
        return glGetCompressedTexImageARB(target, 0, img);
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.