Download Image Using Pyglet

I play with pyglet 1.2alpha-1 and Python 3.3. I have the following (extremely simple) application and cannot figure out what the problem 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 until image.blit (0, 0) is noticed. However, if I try to display the image, the program will exit 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 file and py are in the same directory).

Does anyone know how I can fix this problem?

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

+4
source share
2 answers

Code including image.blit works great for me. I am using python 2.7.3, pyglet 1.1.4 There is nothing wrong with the code. You can try other versions of python and pyglet (until the piglet gets a new stable release)

+2
source

This is not a β€œfix”, but it can at least determine if it is fixed or not (I didn’t). (From the Pyglet distribution group .)

You can check if the system even supports 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) 

This is the maximum texture size supported by your system. If it's 1024, then any larger snapshots will throw an exception. (And the only fix is ​​to get a better system).

0
source

Source: https://habr.com/ru/post/1490090/


All Articles