Skip to content
Snippets Groups Projects
Commit 2746aa43 authored by Paul McCarthy's avatar Paul McCarthy
Browse files

Extra debug/cosmetic changes to GL code - trying to track down a texture issue

parent 167abebf
No related branches found
No related tags found
No related merge requests found
......@@ -39,13 +39,15 @@ Two super classes are provided for each of these cases:
OSMesa.
"""
import logging
log = logging.getLogger(__name__)
import logging
import os
import os.path as op
import OpenGL
log = logging.getLogger(__name__)
# Make PyOpenGL throw an error, instead of implicitly
# converting, if we pass incorrect types to OpenGL functions.
OpenGL.ERROR_ON_COPY = True
......
......@@ -119,6 +119,7 @@ class ColourBarCanvas(props.HasProperties):
if self._tex is None:
self._tex = gl.glGenTextures(1)
log.debug('Created GL texture: {}'.format(self._tex))
# Allow textures of any size
gl.glPixelStorei(gl.GL_PACK_ALIGNMENT, 1)
......
......@@ -244,6 +244,9 @@ def postDraw(glimg):
gl.glDisableVertexAttribArray(glimg.worldCoordPos)
gl.glBindTexture(gl.GL_TEXTURE_1D, 0)
gl.glBindTexture(gl.GL_TEXTURE_3D, 0)
glimg.indices .unbind()
glimg.worldCoords.unbind()
......
......@@ -113,7 +113,10 @@ class GLImage(object):
# The colour map, used for converting
# image data to a RGBA colour.
self.colourTexture = gl.glGenTextures(1)
self.colourTexture = gl.glGenTextures(1)
log.debug('Created GL texture: {}'.format(self.colourTexture))
self.colourResolution = 256
self.genColourTexture(self.colourResolution)
......@@ -170,12 +173,14 @@ class GLImage(object):
longer needed. It performs any needed clean up of OpenGL data (e.g.
deleting texture handles).
"""
log.debug('Deleting GL texture: {}'.format(self.colourTexture))
gl.glDeleteTextures(1, self.colourTexture)
# Another GLImage object may have
# already deleted the image texture
try:
imageTexture = self.image.delAttribute('GLImageTexture')
log.debug('Deleting GL texture: {}'.format(imageTexture))
gl.glDeleteTextures(1, imageTexture)
except KeyError:
......@@ -362,6 +367,7 @@ class GLImage(object):
# otherwise, create a new one
if imageTexture is None:
imageTexture = gl.glGenTextures(1)
log.debug('Created GL texture: {}'.format(imageTexture))
# The image buffer already exists, and is valid
elif not image.getAttribute('GLImageDirty'):
......@@ -371,9 +377,10 @@ class GLImage(object):
self.imageTexture = imageTexture
self.imageTextureShape = shape
log.debug('Creating 3D texture for '
log.debug('Configuring 3D texture (id {}) for '
'image {} (data shape: {})'.format(
imageTexture,
image.name,
imageData.shape))
......@@ -429,6 +436,8 @@ class GLImage(object):
texExtFmt,
imageData)
gl.glBindTexture(gl.GL_TEXTURE_3D, 0)
# Add a reference to the texture as an attribute
# of the image, and mark it as up to date, so other
# things which want to render the same image data
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment