Hello everyone,
I've been mucking around with this for a considerable deal of time and
neither the docs nor sources seem to be of much help. No one on
#[email protected] understood what was the problem and despite my
best effort, I can't seem to push my way through this one.
My re-garbled (but still legible, hopefully) code:
import pyglet
powers_of_2 = [2 ** n for n in xrange( 12 )]
def _newTextureId():
"""
Generate a new id used for textures
"""
textures = ( pyglet.gl.GLuint * 1 )()
pyglet.gl.glGenTextures( 1, textures )
return textures[0]
def _isPower( n ):
"""
Determine whether n is a power of 2
"""
global powers_of_2
while n > 1:
if n in powers_of_2:
return True
n >>= 1
return False
def _getType( p ):
"""
Determines if the type of texture to used based on whether the
image is NPOT
"""
if _isPower( p[0] ) and _isPower( p[1] ):
print "true"
return pyglet.gl.GL_TEXTURE_2D
else:
print "false"
return pyglet.gl.GL_TEXTURE_RECTANGLE_ARB
window = pyglet.window.Window()
p = pyglet.image.load( 'picture.jpg' )
size = ( p.width, p.height )
t = pyglet.image.Texture( p.width, p.height, _getType( size ),
_newTextureId() )
print p, t
p.blit_to_texture( t, 0, 0, 0, 0 )
@window.event
def on_draw():
window.clear()
t.blit( 0, 0 )
pyglet.app.run()
Yes, I know I can use pygame.resource.image to do that exact same
thing; this is just demonstrating what I am trying to do without
showing *what* I am doing.
Anyway, I'd really appreciate any help on this.
Thanks,
Zack Buhman
--
You received this message because you are subscribed to the Google Groups
"pyglet-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pyglet-users?hl=en.