Raymond Liu | 19 Aug 21:26 2014
Picon

Memory-efficient way of getting a single pixel colour value from an image?

Suppose I have an image, obtained by

img = pyglet.image.load("dog.jpg")

I know I can access the image data by using, for example,

data = img.get_image_data().get_data("RGB", img.width*3)

But the problems is that the object `data` obtained as above is very very big, since it contains the RBG value of each pixel a potentially large image. For a 1024 by 768 image, the size of `data` is well over 2GB. That feels like it's a lot to keep in memory, even if temporarily. All I need for my program is to access the RGB value of one particular pixel of my choosing. Is there a memory-efficient way of doing that in Pyglet? In PyGame for example, there is `pygame.Surface.get_at()`. Is there a similar thing in Pyglet?

--
You received this message because you are subscribed to the Google Groups "pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.
Eduard Nicodei | 19 Aug 16:09 2014
Picon

pyglet.window.Window(800,600) hangs with X11 error: BadWindow

Hello everybody,

I have a very basic python script:
import pyglet
window = pyglet.window.Window(800, 600)
pyglet.app.run()
When I run it, however, nothing happens and pressing ctrl+c on the terminal does nothing.
I used pdb to investigate the problem and it seems the script hangs on the "window = pyglet.window.Window(800, 600)" line.
I dug deeper and I rerun the script with PYGLET_DEBUG_X11 set to 1.
This gave me the following stacktrace: http://pastebin.com/GMex4dkd

I should note that no more text appeared on the terminal and pressing ctrl+c didn't close python (I had to pkill it)

python version 2.7.8
pyglet version 1.1.4 (installed from vanilla source)
X.org version 1.15.0

I know X.org version 1.15 had some ABI changes, but I don't know if those might be the cause of this.

Any ideas on what might cause the BadWindow errors?

--
You received this message because you are subscribed to the Google Groups "pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.
Raymond Liu | 19 Aug 00:42 2014
Picon

PyCharm can't fine pyglet.window.mouse but can find pyglet window.key???

If you use PyCharm, the attached screenshot explains it all.

Any idea why? I'm chronically confused as to how PyCharm sometimes finds packages and sometimes doesn't.

I'm using Python 3.4.1, Pyglet 1.2 Alpha, and PyCharm 3.4.1.

--
You received this message because you are subscribed to the Google Groups "pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.
Raymond Liu | 13 Aug 13:51 2014
Picon

vertex_list doesn't work, GL version mismatch?

Hi! I typed the following example code, found in the Graphics section of the programming guide.


vertex_list = pyglet.graphics.vertex_list(2, ('v2i', (10, 15, 30, 35)), ('c3B', (0, 0, 255, 0, 255, 0)) )


But it gives me the following error.


Traceback (most recent call last):
File "C:\Python34\lib\site-packages\pyglet\graphics\__init__.py", line 445, in _get_domain
domain = domain_map[key]
KeyError: (('v2i', 'c3B'), 0, False)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
vl = pyglet.graphics.vertex_list(2, ("v2i", (10, 15, 30, 35)), ("c3B", (0, 0, 255, 0, 255, 0)))
File "C:\Python34\lib\site-packages\pyglet\graphics\__init__.py", line 289, in vertex_list
return _get_default_batch().add(count, 0, None, *data)
File "C:\Python34\lib\site-packages\pyglet\graphics\__init__.py", line 364, in add
domain = self._get_domain(False, mode, group, formats)
File "C:\Python34\lib\site-packages\pyglet\graphics\__init__.py", line 451, in _get_domain
domain = vertexdomain.create_domain(*formats)
File "C:\Python34\lib\site-packages\pyglet\graphics\vertexdomain.py", line 135, in create_domain
return VertexDomain(attribute_usages)
File "C:\Python34\lib\site-packages\pyglet\graphics\vertexdomain.py", line 186, in __init__
usage=usage, vbo=vbo)
File "C:\Python34\lib\site-packages\pyglet\graphics\vertexbuffer.py", line 116, in create_mappable_buffer
return MappableVertexBufferObject(size, target, usage)
File "C:\Python34\lib\site-packages\pyglet\graphics\vertexbuffer.py", line 382, in __init__
super(MappableVertexBufferObject, self).__init__(size, target, usage)
File "C:\Python34\lib\site-packages\pyglet\graphics\vertexbuffer.py", line 300, in __init__
glGenBuffers(1, id)
File "C:\Python34\lib\site-packages\pyglet\gl\lib_wgl.py", line 82, in __call__
return self.func(*args, **kwargs)
File "C:\Python34\lib\site-packages\pyglet\gl\lib.py", line 62, in MissingFunction
raise MissingFunctionException(name, requires, suggestions)
pyglet.gl.lib.MissingFunctionException: glGenBuffers is not exported by the available OpenGL driver. VERSION_1_5 is required for this functionality.


What does this error mean? Does it mean that I don't have the right version of OpenGL? How do I update OpenGL in a way that pyglet will support it properly?

--
You received this message because you are subscribed to the Google Groups "pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.
Henry Harrison | 2 Aug 19:17 2014
Picon

2D shape primitives for Pyglet

Hello,

I wanted to share this with the pyglet community. I created a library called "pygelt2d" that offers shape primitives for pyglet, so you can easily draw rectangles, circles, and other polygons. It's on PyPi as pyglet2d or check out the repo at github.com/hsharrison/pyglet2d.

Right now it's only tested with Python >= 3.3 and pyglet 1.2alpha1. Also required is a geometry library Polygon3 (will be automatically installed as a dependency).

--
You received this message because you are subscribed to the Google Groups "pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.
BigD | 2 Aug 03:48 2014
Picon

batch.migrate does not work for indexed vertexlist?


Hi Everyone,

   I am working creating a 3d graphics engine and using the concepts behind sprite.Sprite and the graphics.py demo to create a 3d set of primitive objects (using pyglet 1.1.4 btw).  Now to implement picking I want to be able to change the group the primitive belongs to.  Based on sprite.Sprite, changing groups basically calls self._batch.migrate(self._vertex_list, GL_QUADS, self._group, self._batch).  Note that self._vertexlist in sprite.Sprite is not an indexed list (see Sprite._create_vertex_list).  When I try to do the same thing with an indexed vertexlist in my 3d engine I am getting some strange behavior. Looking at Batch.migrate in pyglet\graphics\__init__.py it seems that the batch._get_domain function is always called with False as the first argument, indicating that it's a regular vertexlist.  Does this mean indexed vertexlists cannot be migrated?  Has anyone tried to do something similar.

Denis

--
You received this message because you are subscribed to the Google Groups "pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.
ew | 1 Aug 06:03 2014
Picon

rotation

Hi,

I've only started recently to use the pyglet module.

I have drawn a line on the window.

What I'd like to do are the following:

1) Be able to rotate the line 360 degrees in any direction
2) the line rotates accordingly.

I know I need to add an event (on_mouse_drag ?), but what
I'd like to know is do I need to do the mathematical calculations
to update the line (to make it rotate), or does it automatically
do it when I call some function like rotateScene(xDegrees, yDegrees, zDegrees)?
I'm still reading up on the docs though, so I could've missed
some details.

Thanks

ew

--
You received this message because you are subscribed to the Google Groups "pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.
01AutoMonkey | 28 Jul 23:31 2014
Picon

GLM (OpenGL Mathematics) equivalent for Pyglet?

I'm halfway through the http://open.gl/ tutorials (http://open.gl/transformations) and am being introduced to "Matrices" to do transformations (rotation, scaling, etc). So far I've been able to translate the C++ in the tutorials to Python, more specifically:

  • C++ to Python
  • SFML to Pyglet
  • GLEW to pyglet.gl
  • SOIL to pyglet.image

But to do matrice transformations I'm being asked to use GLM (OpenGL Mathematics http://glm.g-truc.net/0.9.5/index.html), and I haven't been able to wrap my head around an appropriate equivalent for that in Pyglet, so I'm wondering, has anyone here had any experience with or know of a way for doing things in Pyglet which in C++ would require GLM?

A simple example would be to use GLM to create a mat4 value which is then used in the vertex shader through a uniform variable:

glm::mat4 trans; trans = glm::rotate(trans, 180.0f, glm::vec3(0.0f, 0.0f, 1.0f));
...
GLint uniTrans = glGetUniformLocation(shaderProgram, "trans");
...
glUniformMatrix4fv
(uniTrans, 1, GL_FALSE, glm::value_ptr(trans));


I'm using:
- Pyglet 1.2
- OpenGL 3.2+

--
You received this message because you are subscribed to the Google Groups "pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.
Raymond Liu | 26 Jul 22:47 2014
Picon

Scrollable window?

How do you create a scrollable window? Say I want to create a window that displays an image much bigger than the window, and I want to be able to scroll up and down and left and right to see the image, how do I do that?

--
You received this message because you are subscribed to the Google Groups "pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.
Raymond Liu | 23 Jul 21:17 2014
Picon

One window handling another window's events.

Hi! I have two subclasses of pyglet, InfoWindow and MainWindow. I have one instance of each, info_window and main_window. This is just a toy example. I want info_window to display the mouse coordinates when it's in main_window, not when it's in itself. I thought obviously I need to use the on_mouse_motion event. But when I use this event in info_window, it only catches mouse motion in itself, not main_window. So the question is, how do I make info_window handle the on_mouse_motion event that occurs in main_window?

I realise that there are other ways of achieving my desired behaviour, but I thought it would be quite nice to be able to achieve it the way I described above, that is, handling another window's event. Is it possible?

--
You received this message because you are subscribed to the Google Groups "pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.
Jose Luis Da | 15 Jul 17:31 2014

How to listen for a specific event?

Hi all, 

I want to, within a loop, check at a certain point if the left button of the mouse, for example, has been pressed. I know that you have to use the method "on_mouse_press", but I do not know how to assign the return of the function to a variable, because I do not know how to call this function at a certain point.

Is there a way to bypass "on_mouse_press" and call directly a method that only listens to the mouse?


Thank you,
jl

--
You received this message because you are subscribed to the Google Groups "pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.

Gmane