pyglet

basic openGL, vertex buffers and pyglet

心不动则不痛 提交于 2019-12-18 12:35:20
问题 Edit: rotoglup found the problems in my code, adding the shaders I had removed completed the solution. See my answer below for the correct code (with shaders). Hi all ! I'm trying to learn some basics of modern OpenGL from this tutorial. I'd like to do it with python/pyglet instead of C++ though. I know pyglet can abstract much of the low level OpenGL away; I want to understand some of the basics before moving on to hiding them behind layers of abstraction though. My problem is extremely

Rotate 3D image batches to make them 2D

你。 提交于 2019-12-13 17:21:34
问题 My on_draw function is: def on_draw(self): self.clear() self.set3d() glPushMatrix() glRotatef(-rot[0], 1, 0, 0) glRotatef(-rot[1], 0, 1, 0) glTranslatef(-pos[0],-pos[1],-pos[2],) self.model.draw() glPopMatrix() pos (position) and rot (rotation) are lists of camera information used to transform the graphics. What I want to achieve is a doom-like effect where the images (certain parts of the scenery, players, enemy images) are kept so that they are parallel to the screen; they stay 2D,

How do I assign values to a variable with a schedule function in pyglet?

耗尽温柔 提交于 2019-12-13 05:10:01
问题 With the following code x=1.0 def update(dt): space.step(dt) def xprinter(self, x): print (x) return x+1 if __name__ == "__main__": x=pyglet.clock.schedule(xprinter,x) pyglet.clock.schedule_interval(update, 1.0/60) pyglet.app.run() My return is simply 1.0 over and over. I would like for the value to be updated with each call. What am I missing? 回答1: The design here is based on that your function rely on returning a result. Which causes a problem because Pyglet's internal functions are in

Pyglet: Sprite.draw() and Batch.draw() don't work, but Image.blit does

点点圈 提交于 2019-12-13 04:58:28
问题 In pyglet, which I'm learning, Image.blit() works, but Sprite.draw() doesn't, nor Batch.draw(), even in this simple code: import pyglet win = pyglet.window.Window() img = pyglet.resource.image('test.png') spr = pyglet.sprite.Sprite(img) @win.event def on_draw(): win.clear() spr.draw() if __name__ == '__main__': pyglet.app.run() The window remains black. However, I can draw labels, for example. THe only explaination I found was about graphic cards and "v2i" bugs with some of them, but I'm

Check if square is contained in another square

拟墨画扇 提交于 2019-12-13 04:03:51
问题 So I'm doing a little project in python using pyglet(opengl). When I click on a point in the screen a Square is generated that expands equally from the coordinate. So for example if I click on (100,100) a square would be drawn from (99,99) with side length of 3. The bottom left point would decrease by (-1,-1) each generation and the side length increases by 2. What I want to do is have a way to detect if the square is outside the boundaries of the window so I can delete it from my collection

Get Data from OpenGL glReadPixels(using Pyglet)

…衆ロ難τιáo~ 提交于 2019-12-12 05:36:40
问题 I'm using Pyglet(and OpenGL) in Python on an application, I'm trying to use glReadPixels to get the RGBA values for a set of pixels. It's my understanding that OpenGL returns the data as packed integers, since that's how they are stored on the hardware. However for obvious reasons I'd like to get it into a normal format for working with. Based on some reading I've come up with this: http://dpaste.com/99206/ , however it fails with an IndexError. How would I go about doing this? 回答1: You must

Pyglet won't quit after playing mp3

守給你的承諾、 提交于 2019-12-12 02:12:01
问题 I was looking for a solution to play mp3 files in python and many stackoverflow answers (to other questions) seemed to recommend pyglet. I am writing a program that takes a piece of text, breaks it into individual words and then downloads mp3s of those words (if they aren't already downloaded) using gTTs and plays them. from pyglet import media, app, clock from gtts import gTTS import os import time from num2words import num2words cwd = os.getcwd() beep = media.load('beep.mp3', streaming =

Pyglet not running properly on AMD HD4250

走远了吗. 提交于 2019-12-11 18:57:39
问题 I am building an python program using pyglet. The source code runs just fine on any computer exept for my laptop. My Laptop is also the only one with a AMD graphics card: the HD4250. Its Xubuntu 13.04 AMD64, and the graphics drivers are the X11 Open Source ones. This is how it looks: When adding a clear statement in the constructor the screen gets build properly, but then is incredebly slow. It will refresh at max 2 times per 30 seconds and barely respond to any input. How can I fix this? It

Pyglet GL_QUADS and GL_POLYGON not working properly

99封情书 提交于 2019-12-11 18:20:23
问题 I'm trying to write a simple game and for some reason the graphics primitives aren't working properly on my machine (Win7/NVIDIA Quadro K2100M). I'm trying to draw a rectangle but whenever I use GL_QUADS or GL_POLYGON it comes with a weird bend in it. It works with GL_QUAD_STRIP, oddly, but that's really not ideal since I don't want the ones I"m drawing to be connected. I really have no idea what the problem could be... Example code: import pyglet window = pyglet.window.Window(width=400,

Update and On_Draw Pyglet in Thread

时光总嘲笑我的痴心妄想 提交于 2019-12-11 17:29:28
问题 I wanted to ask, is it possible to put the Update and On_Draw functions of a Pyglet class created by the user in a thread? Let me explain. I have the class of my app of Pyglet, in which I need some functions (always of the same class) that work simultaneously with the Update and On_Draw functions. Now, I've been looking around and the only things I've found is inserting the entire Pyglet app into a main thread, but doing so would give problems to the Pyglet itself. I just need to have those