pyopengl

Using SwapBuffers() with multiple OpenGL canvases and vertical sync?

狂风中的少年 提交于 2019-12-08 20:02:59
I have a GUI written using wxPython that contains two GLCanvas es, a 'display' canvas and a 'preview' canvas onto which I am drawing some very simple geometry using PyOpenGL. The 'preview' and 'display' canvases display the contents of the same framebuffer: I need both of these canvases to be updated synchronously at a consistent framerate with no tearing. So far I have just been calling self.SetCurrent() # draw stuff... self.SwapBuffers() for both the preview and display canvases within my rendering loop. This works reasonably well provided that I disable vsync in my driver settings. However,

Using SwapBuffers() with multiple OpenGL canvases and vertical sync?

怎甘沉沦 提交于 2019-12-08 08:01:44
问题 I have a GUI written using wxPython that contains two GLCanvas es, a 'display' canvas and a 'preview' canvas onto which I am drawing some very simple geometry using PyOpenGL. The 'preview' and 'display' canvases display the contents of the same framebuffer: I need both of these canvases to be updated synchronously at a consistent framerate with no tearing. So far I have just been calling self.SetCurrent() # draw stuff... self.SwapBuffers() for both the preview and display canvases within my

How to implement zoom towards mouse like in 3dsMax?

吃可爱长大的小学妹 提交于 2019-12-08 02:29:33
问题 I'm trying to mimick the 3dsmax behaviour when you zoom in/out by moving the mouse wheel. In 3ds max this zooming will be towards the mouse position. So far I've come up with this little mcve: import math from ctypes import c_void_p import numpy as np from OpenGL.GL import * from OpenGL.GLU import * from OpenGL.GLUT import * from glm import * class Camera(): def __init__( self, eye=None, target=None, up=None, fov=None, near=0.1, far=100000, **kwargs ): self.eye = vec3(eye) or vec3(0, 0, 1)

How create a camera on PyOpenGL that can do “perspective rotations” on mouse movements?

旧街凉风 提交于 2019-12-07 17:56:47
问题 I am creating a first-person view RPG and I want to rotate the camera in PyOpenGL when I move the mouse (just like some other games like Minecraft). What function can I use to do this and how? I tried to use gluLookAt() but I don't understand how it works although I went through different sources. I don't even know if it can help. import sys,pygame from OpenGL.GL import * from OpenGL.GLU import * cmddown = False #... keypress = pygame.key.get_pressed()#Move using WASD if keypress[pygame.K_w]:

ray intersection misses the target

丶灬走出姿态 提交于 2019-12-07 17:45:49
问题 I'm trying to pick a 3d point. I read various sites but my code doesn't work. on right mouse click: glGetFloatv(GL_MODELVIEW_MATRIX,mv_mat) glGetFloatv(GL_PROJECTION_MATRIX,p_mat) ip_mat = np.linalg.inv(mat4(p_mat)) # clip = array[ # (2*x)/window_width-1 # 1-(y*2)/window.height # -1 # 1 camera_coord = np.dot(ip_mat,clip) camera_coord = np.array([camera_coord[0,0],camera_coord[0,1],-1,0]) imv_mat = np.linalg.inv(mat4(mv_mat)) ray_world = np.dot(imv_mat,camera_coord) ray_world = np.array([ray

Python PIL Image.tostring()

旧巷老猫 提交于 2019-12-07 09:47:15
问题 I'm new to Python and PIL. I am trying to follow code samples on how to load an image into to Python through PIL and then draw its pixels using openGL. Here are some line of the code: from Image import * im = open("gloves200.bmp") pBits = im.convert('RGBA').tostring() ..... glDrawPixels(200, 200, GL_RGBA, GL_UNSIGNED_BYTE, pBits) This will draw a 200 x 200 patch of pixels on the canvas. However, it is not the intended image-- it looks like it is drawing pixels from random memory. The random

Issues with PyQt5's OpenGL module and versioning (calls for incorrect _QOpenGLFunctions_(ver))

半世苍凉 提交于 2019-12-06 12:31:26
问题 I have been trying to get the PyQt5 helloGL example code to compile. When I try to build the solution, I get: Traceback (most recent call last): File "C:\Users\\-PATH-\trunk\view\test.py", line 142, in initializeGL self.gl = self.context().versionFunctions() ImportError: No module named 'PyQt5._QOpenGLFunctions_4_3_Compatibility' [Finished in 0.3s] In my PyQt5 folder, I've got: _QOpenGLFunctions_4_1_Core.pyd _QOpenGLFunctions_2_0.pyd _QOpenGLFunctions_2_1.pyd as my set of QOpenGLFunctions for

Implementing render-to-vertex-array, glReadPixels fails (invalid operation)

跟風遠走 提交于 2019-12-06 08:37:15
问题 I'm trying to copy vertex data from a texture to a vertex buffer, and then draw the vertex buffer. As far as I know the best way to do this is to bind the texture to a fbo, and use glReadPixels to copy it to a vbo. However, I can't seem to get this working: glReadPixels fails with the error "invalid operation". Corrections, examples and alternate methods welcome. :) Here's the relevant code: glEnable(GL_TEXTURE_2D) w, h = 32, 32 vbo = glGenBuffers(1) glBindBuffer(GL_ARRAY_BUFFER, vbo)

How to implement zoom towards mouse like in 3dsMax?

本秂侑毒 提交于 2019-12-06 07:31:21
I'm trying to mimick the 3dsmax behaviour when you zoom in/out by moving the mouse wheel. In 3ds max this zooming will be towards the mouse position. So far I've come up with this little mcve: import math from ctypes import c_void_p import numpy as np from OpenGL.GL import * from OpenGL.GLU import * from OpenGL.GLUT import * from glm import * class Camera(): def __init__( self, eye=None, target=None, up=None, fov=None, near=0.1, far=100000, **kwargs ): self.eye = vec3(eye) or vec3(0, 0, 1) self.target = vec3(target) or vec3(0, 0, 0) self.up = vec3(up) or vec3(0, 1, 0) self.original_up = vec3

How to rotate 2 objects independently in pygame and pyopengl

别来无恙 提交于 2019-12-06 05:21:00
I'm trying to rotate 2 objects independently but when I run the code both objects rotate in the same direction enter code here here i save the matrix and rotate a square under the cube def rotate_square(): glColor3f(1,1,1) glMatrixMode(GL_MODELVIEW) glPushMatrix() glRotatef(45,0,1,0) glBegin(GL_LINES) glVertex3fv(v1); glVertex3fv(v2); glVertex3fv(v1); glVertex3fv(v3); glVertex3fv(v3); glVertex3fv(v4); glVertex3fv(v2); glVertex3fv(v4); glEnd() glPopMatrix() main function def main(): pygame.init() screen = pygame.display.set_mode(SCREEN_SIZE, DOUBLEBUF|OPENGL) resize(*SCREEN_SIZE) print