
try:
	from OpenGL.GL import *
	from OpenGL.GLU import *
	from bgl import Buffer
	USING_BGL = False
except ImportError:
	from bgl import *
	USING_BGL = True

if USING_BGL:
	_glGenTextures = glGenTextures
	def glGenTextures(n, textures=None):
		id_buf = Buffer(GL_INT, n)
		_glGenTextures(n, id_buf)

		if textures:
			textures.extend(id_buf.to_list())

		return id_buf.to_list()[0] if n == 1 else id_buf.to_list()


	_glDeleteTextures = glDeleteTextures
	def glDeleteTextures(textures):
		n = len(textures)
		id_buf = Buffer(GL_INT, n, textures)
		_glDeleteTextures(n, id_buf)


	_glGetIntegerv = glGetIntegerv
	def glGetIntegerv(pname):
		# Only used for GL_VIEWPORT right now, so assume we want a size 4 Buffer
		buf = Buffer(GL_INT, 4)
		_glGetIntegerv(pname, buf)
		return buf.to_list()

else:
	_glTexImage2D = glTexImage2D
	def glTexImage2D(target, level, internalFormat, width, height, border, format, type, data):
		_glTexImage2D(target, level, internalFormat, width, height,
			border, format, type, data.to_list())


try:
	from bgl import *
	USING_BGL = True
except ImportError:
	from OpenGL.GL import *
	from OpenGL.GLU import *
	from bgl import Buffer

if USING_BGL:
	_glGenTextures = glGenTextures
	def glGenTextures(n, textures=None):
		id_buf = Buffer(GL_INT, n)
		_glGenTextures(n, id_buf)

		if textures:
			textures.extend(id_buf.to_list())

		return id_buf.to_list()[0] if n == 1 else id_buf.to_list()


	_glDeleteTextures = glDeleteTextures
	def glDeleteTextures(textures):
		n = len(textures)
		id_buf = Buffer(GL_INT, n, textures)
		_glDeleteTextures(n, id_buf)


	_glGetIntegerv = glGetIntegerv
	def glGetIntegerv(pname):
		# Only used for GL_VIEWPORT right now, so assume we want a size 4 Buffer
		buf = Buffer(GL_INT, 4)
		_glGetIntegerv(pname, buf)
		return buf.to_list()

else:
	_glTexImage2D = glTexImage2D
	def glTexImage2D(target, level, internalFormat, width, height, border, format, type, data):
		_glTexImage2D(target, level, internalFormat, width, height,
			border, format, type, data.to_list())

Make bgl the default OpenGL implementation snice it is currently faster than PyOpenGL.
Make bgl the default OpenGL implementation snice it is currently faster than PyOpenGL.

  
  try:
+ 	from bgl import *
+ 	USING_BGL = True
+ except ImportError:
  	from OpenGL.GL import *
  	from OpenGL.GLU import *
  	from bgl import Buffer
- 	USING_BGL = False
- except ImportError:
- 	from bgl import *
- 	USING_BGL = True
  
  if USING_BGL:
  	_glGenTextures = glGenTextures
  	def glGenTextures(n, textures=None):
  		id_buf = Buffer(GL_INT, n)
  		_glGenTextures(n, id_buf)
  
  		if textures:
  			textures.extend(id_buf.to_list())
  
  		return id_buf.to_list()[0] if n == 1 else id_buf.to_list()
  
  
  	_glDeleteTextures = glDeleteTextures
  	def glDeleteTextures(textures):
  		n = len(textures)
  		id_buf = Buffer(GL_INT, n, textures)
  		_glDeleteTextures(n, id_buf)
  
  
  	_glGetIntegerv = glGetIntegerv
  	def glGetIntegerv(pname):
  		# Only used for GL_VIEWPORT right now, so assume we want a size 4 Buffer
  		buf = Buffer(GL_INT, 4)
  		_glGetIntegerv(pname, buf)
  		return buf.to_list()
  
  else:
  	_glTexImage2D = glTexImage2D
  	def glTexImage2D(target, level, internalFormat, width, height, border, format, type, data):
  		_glTexImage2D(target, level, internalFormat, width, height,
  			border, format, type, data.to_list())
  
Make bgl the default OpenGL implementation snice it is currently faster than PyOpenGL.
## Code Before:

try:
	from OpenGL.GL import *
	from OpenGL.GLU import *
	from bgl import Buffer
	USING_BGL = False
except ImportError:
	from bgl import *
	USING_BGL = True

if USING_BGL:
	_glGenTextures = glGenTextures
	def glGenTextures(n, textures=None):
		id_buf = Buffer(GL_INT, n)
		_glGenTextures(n, id_buf)

		if textures:
			textures.extend(id_buf.to_list())

		return id_buf.to_list()[0] if n == 1 else id_buf.to_list()


	_glDeleteTextures = glDeleteTextures
	def glDeleteTextures(textures):
		n = len(textures)
		id_buf = Buffer(GL_INT, n, textures)
		_glDeleteTextures(n, id_buf)


	_glGetIntegerv = glGetIntegerv
	def glGetIntegerv(pname):
		# Only used for GL_VIEWPORT right now, so assume we want a size 4 Buffer
		buf = Buffer(GL_INT, 4)
		_glGetIntegerv(pname, buf)
		return buf.to_list()

else:
	_glTexImage2D = glTexImage2D
	def glTexImage2D(target, level, internalFormat, width, height, border, format, type, data):
		_glTexImage2D(target, level, internalFormat, width, height,
			border, format, type, data.to_list())

## Instruction:
Make bgl the default OpenGL implementation snice it is currently faster than PyOpenGL.
## Code After:

try:
	from bgl import *
	USING_BGL = True
except ImportError:
	from OpenGL.GL import *
	from OpenGL.GLU import *
	from bgl import Buffer

if USING_BGL:
	_glGenTextures = glGenTextures
	def glGenTextures(n, textures=None):
		id_buf = Buffer(GL_INT, n)
		_glGenTextures(n, id_buf)

		if textures:
			textures.extend(id_buf.to_list())

		return id_buf.to_list()[0] if n == 1 else id_buf.to_list()


	_glDeleteTextures = glDeleteTextures
	def glDeleteTextures(textures):
		n = len(textures)
		id_buf = Buffer(GL_INT, n, textures)
		_glDeleteTextures(n, id_buf)


	_glGetIntegerv = glGetIntegerv
	def glGetIntegerv(pname):
		# Only used for GL_VIEWPORT right now, so assume we want a size 4 Buffer
		buf = Buffer(GL_INT, 4)
		_glGetIntegerv(pname, buf)
		return buf.to_list()

else:
	_glTexImage2D = glTexImage2D
	def glTexImage2D(target, level, internalFormat, width, height, border, format, type, data):
		_glTexImage2D(target, level, internalFormat, width, height,
			border, format, type, data.to_list())
