Mike Caputo
Mike Caputo

Reputation: 1156

Loading an image using Pyglet

I am playing around with pyglet 1.2alpha-1 and Python 3.3. I have the following (extremely simple) application and cannot figure out what my issue is:

import pyglet

window = pyglet.window.Window()
#image = pyglet.resource.image('img1.jpg')
image = pyglet.image.load('img1.jpg')
label = pyglet.text.Label('Hello, World!!',
                      font_name='Times New Roman',
                      font_size=36,
                      x=window.width//2, y=window.height//2,
                      anchor_x='center', anchor_y='center')

@window.event
def on_draw():
    window.clear()
    label.draw()
    #    image.blit(0,0)

pyglet.app.run()

With the above code, my text label will appear as long as image.blit(0, 0) is commented out. However, if I try to display the image, the program crashes with the following error:

  File "C:\Python33\lib\site-packages\pyglet\gl\lib.py", line 105, in errcheck
raise GLException(msg)
pyglet.gl.lib.GLException: b'invalid value'

I also get the above error if I try to use pyglet.resource.image instead of pyglet.image.load (the image and py file are in the same directory).

Any one know how I can fix this issue?

I am using Python 3.3, pyglet 1.2alpha-1, and Windows 8.

Upvotes: 5

Views: 3425

Answers (2)

John C
John C

Reputation: 6525

This isn't a "fix", but might at least determine if it's fixable or not (mine was not). (From the Pyglet mailing group.)

You can verify whether the system does not even support Textures greater than 1024, by running this code (Python 3+):

from ctypes import c_long
from pyglet.gl import glGetIntegerv, GL_MAX_TEXTURE_SIZE

i = c_long()
glGetIntegerv(GL_MAX_TEXTURE_SIZE, i)
print (i)  # output: c_long(1024) (or higher)

That is the maximum texture size your system supports. If it's 1024, then any larger pictures will raise an Exception. (And the only fix is, get a better system).

Upvotes: 1

Rolf Schorpion
Rolf Schorpion

Reputation: 543

The code -including the image.blit- runs fine for me. I'm using python 2.7.3, pyglet 1.1.4 There's nothing wrong with the code. You might consider trying other python and pyglet versions for the time being (until pyglet has a new stable release)

Upvotes: 3

Related Questions