File: GL_1_3_images.py

package info (click to toggle)
pyopengl 3.0.0~b6-3
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 5,696 kB
  • ctags: 26,182
  • sloc: python: 34,233; ansic: 70; sh: 26; makefile: 15
file content (24 lines) | stat: -rw-r--r-- 845 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""OpenGL version 1.3 imaging-handling routines"""
from OpenGL import wrapper, constants, arrays
from OpenGL.raw.GL.VERSION import GL_1_3 as simple
from OpenGL.GL import images, glget

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

if simple.glGetCompressedTexImage:
	def glGetCompressedTexImage( target, level, img=None ):
		"""Retrieve a compressed texture image"""
		if img is None:
			length = glget.glGetTexLevelParameteriv(
				target, 0, 
				simple.GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB, 
			)
			img = arrays.ArrayDataType.zeros( (length,), constants.GL_UNSIGNED_BYTE )
		return simple.glGetCompressedTexImage(target, 0, img);