5

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.

Mike Caputo
  • 1,156
  • 17
  • 33
  • I'm running into the same error, although I found out what conditions generate it (but not a fix). I'm running Windows 7, Python 2.7.11, Pyglet 1.2.4. I had code that was running on Linux, which broke on Windows. Debugging it, I finally found that when a picture was larger then 1024x1024 (in either direction), it bombed. (My screen is 1920x1080). When I shrank a picture down to 1024x1024, it worked fine. Still trying to find out what's breaking in Pyglet, though. (Switching to version 1.1.4 did not work). – John C Dec 10 '16 at 20:41

2 Answers2

3

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)

Rolf Schorpion
  • 523
  • 1
  • 4
  • 12
1

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).

John C
  • 6,285
  • 12
  • 45
  • 69