pyopengl

How can I rotate multiple quads separately? (Pygame, PyOpengl)

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 04:37:46
问题 I'd like to rotate my quads roughly around they own axis. My first thought was to use glPushMatrix() and glPophMatrix(), but doesn't work. Regardless of that I believe this is the good way. Code: import time, pygame from pygame.locals import * from OpenGL.GL import * from OpenGL.GLU import * def makeQuad(): glBegin(GL_QUADS) glVertex2f(0, 0) glVertex2f(0, 50) glVertex2f(50, 50) glVertex2f(50, 0) glEnd() def main(): pygame.init() display = (800,800) pygame.display.set_mode(display, DOUBLEBUF

Proper way to handle camera rotations

纵饮孤独 提交于 2019-12-11 03:08:01
问题 Let's start by considering 2 type of camera rotations: Camera rotating around a point (Orbit): def rotate_around_target(self, target, delta): right = (self.target - self.eye).cross(self.up).normalize() amount = (right * delta.y + self.up * delta.x) self.target = target self.up = self.original_up self.eye = ( mat4.rotatez(amount.z) * mat4.rotatey(amount.y) * mat4.rotatex(amount.x) * vec3(self.eye) ) Camera rotating the target (FPS) def rotate_target(self, delta): right = (self.target - self

Why does this wxPython/PyOpenGL code raise an error on glPushMatrix?

扶醉桌前 提交于 2019-12-11 02:43:17
问题 I was dusting off some wxPython/PyOpenGL code that used to run but does not any more -- apparently it stopped working after some update in one module or another, I have no idea when. Here is a teeny sample app that reproduces the error. import wx from wx import glcanvas from OpenGL.GLUT import * from OpenGL.GL import * class WxMyTestApp(wx.App): def __init__(self): wx.App.__init__(self) def OnInit(self): self.viewFrame = wx.Frame(None, -1, 'viewFrame', wx.DefaultPosition, (400,400)) self

Count image similarity on GPU [OpenGL/OcclusionQuery]

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 02:30:13
问题 OpenGL. Let's say I've drawn one image and then the second one using XOR. Now I've got black buffer with non-black pixels somewhere, I've read that I can use shaders to count black [ rgb(0,0,0) ] pixels ON GPU? I've also read that it has to do something with OcclusionQuery. http://oss.sgi.com/projects/ogl-sample/registry/ARB/occlusion_query.txt Is it possible and how? [any programming language] If you've got other idea on how to find similarity via OpenGL/GPU - that would be great too. 回答1: I

get 3d point in space using 2d point in image in python opengl

浪子不回头ぞ 提交于 2019-12-10 22:54:55
问题 Im trying to simulate a depth camera in a room, my camera is able to move and rotate in the world and the room is simulated as a 3d cube around the (0,0,0) At the click of a button I want to sample N random points in the image and get the distance of these points from the camera (distance in the "real world"). So far I've managed to create the scene of the moving camera and the cube (Example) I tried gluUnProject to get the 3d point model_view = np.array(glGetDoublev(GL_MODELVIEW_MATRIX))

Trying to Graph a Simple Square in pyOpenGL

a 夏天 提交于 2019-12-10 20:49:02
问题 I'm trying to teach myself OpenGL using pyopengl and I'm struck on trying to render a simple 2D square centered at the origin. Whenever I set an array value greater than or equal to 1, the shape takes up the entire screen as if I am only viewing a small section of the axis. I have tried to base it off the NeHe tutorials rewritten in pyopengl but I can't find what I'm doing wrong. from OpenGL.GL import * from OpenGL.GLU import * from OpenGL.GLUT import * def display(): glClear(GL_COLOR_BUFFER

MODERN OPENGL can't change uniform value beetween glDrawArrays calls

喜欢而已 提交于 2019-12-10 15:16:33
问题 EDIT: I just managed to fix the issue by reinstalling PyOpenGL with pip. The same program now works as expected. Thanks for your efforts. The entire question was rewritten and clarificated. The issue does not lie in the (although weird) Texture creation and binding approaches, as explained in the comments. My actual problem is the fact that uniform variables in the shaders are not updating their values when changed (yes, changed from outside the shader) between calls to glDrawArrays(). I

OpenGL says “from_param received a non-contiguous array”

╄→尐↘猪︶ㄣ 提交于 2019-12-10 15:04:20
问题 After installing Yosemite, I had to upgrade numpy, PyOpenGL, etc. Now, a previously-working program is giving me the following stack trace: file "latebind.pyx", line 44, in OpenGL_accelerate.latebind.Curry.__call__ (src/latebind.c:1201) File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/OpenGL/GL/VERSION/GL_1_5.py", line 89, in glBufferData return baseOperation( target, size, data, usage ) File "latebind.pyx", line 32, in OpenGL_accelerate.latebind

OpenGL render view without a visible window in python

↘锁芯ラ 提交于 2019-12-10 12:55:57
问题 I need to render some scene. I managed to do it in python using pyopengl and pygame. The problem is that it creates a window for a short period of time. I want to render the same image and save it, without creating a visible window (Or possibly without creating a window at all, and even without pygame). import cv2 import numpy as np import pygame from pygame.locals import * from OpenGL.GL import * from OpenGL.GLU import * def main(): DISPLAY_WIDTH = 900 DISPLAY_HEIGHT = 900 pygame.init()

Just installed QtOpenGL but cannot import it (from Python)

巧了我就是萌 提交于 2019-12-09 02:46:39
问题 I just installed it with apt-get on debian linux with apt-get install libqt4-opengl the rest of PyQt4 is available, but I cant get to this new module. from PyQt4 import QtOpenGL raises ImportError. any idea what to do? 回答1: Did you forget to install the Python bindings? apt-get install python-qt4-gl 回答2: For Python3, I had to do sudo apt-get install python3-pyqt4.qtopengl 来源: https://stackoverflow.com/questions/1419650/just-installed-qtopengl-but-cannot-import-it-from-python