pyopengl

OpenGL shaders questions

天大地大妈咪最大 提交于 2019-12-12 03:59:58
问题 I have a running program that uses glVertexPointer, glNormalPointer etc to draw a large number of elements. This works around 30 FPS. Now I've reach a point where integrating shaders would be a viable option (each vertex need to have a color calculated based on a specific class). 1. Now my first question is how much would using shaders affect my FPS ? My current implementation (which I'm 99.99% is flawed in at least some way, will post code below) drops the FPS drastically to 3 FPS. If this

How to use FreeGLUT glutMouseWheelFunc in PyOpenGL program?

拟墨画扇 提交于 2019-12-12 01:31:43
问题 I have installed PyOpenGL from here for 64-bit Python 3.x and Windows 7. I am able to write and execute a PyOpenGL program that uses glutMouseFunc to listen to mouse button clicks: from OpenGL.GLUT import * from OpenGL.GL import * # Imagine the typical glut init functions here ... glutMouseFunc( mouse ) Now, I want to read the scroll wheel of the mouse too. I have done this before in C++ using FreeGLUT, which exposes a glutMouseWheelFunc . I checked and I can see freeglut32.vc9.dll and

Error in OBJFileLoader

ぐ巨炮叔叔 提交于 2019-12-11 17:32:03
问题 There's error in OBJFILELOADER.py file from the link - https://www.pygame.org/wiki/OBJFileLoader . I think there's python2 to python3 version error, however I tried changing the raise ValueError thing and used obj as obj=(filename) But still there's lots of errors. I took the .obj file from blender, I don't think that's the issue. Can anyone tell me the exact objfileloader for Python3 Error - Traceback (most recent call last): File "/home/warted/anaconda3/lib/python3.6/site-packages/OpenGL

Using offsets into the buffer in PyOpenGL calls

笑着哭i 提交于 2019-12-11 13:41:39
问题 In OpenGL the indices parameter for glDrawElements has two different meanings, depending on if you are using GL_ELEMENT_ARRAY_BUFFER or not. If you have a VBO bound, then it is the offset to start in that buffer, rather than the buffer itself. When using PyOpenGL, how can you specify the offset to start at in a glDrawElements call? How can you specify multiple start offsets in a glMultiDrawElements call? 回答1: In the following examples a list of 6 indices is used, which may form a quad which

How can I determine the max allowable WX_GL_DEPTH_SIZE for a wx GLCanvas?

ぃ、小莉子 提交于 2019-12-11 10:09:46
问题 I am creating a wx.Frame with a GLCanvas . On some platforms, setting the WX_GL_DEPTH_SIZE attribute of the canvas to 32 works fine. On another platform, I just get a blank frame (the GLCanvas doesn't render) unless I reduce the depth size to 16. Is there an easy way in the calling code to determine the allowable values for the depth size? 回答1: The only solution I found is to use GLCanvas method IsDiplaySupported, however it seems that this method is available in wxPython 2.9 and not older

Why is this tutorial example of a shader not displaying any geometry as it is supposed to?

二次信任 提交于 2019-12-11 08:54:52
问题 This is an example from: http://pyopengl.sourceforge.net/context/tutorials/shader_1.xhtml It is creating a vbo, binging it, and running it with a shader, but somewhere along the way, something is not working properly. :\ from OpenGLContext import testingcontext BaseContext = testingcontext.getInteractive() from OpenGL.GL import * from OpenGL.arrays import vbo from OpenGLContext.arrays import * from OpenGL.GL import shaders class TestContext( BaseContext ): def OnInit( self ): VERTEX_SHADER =

Texture wrapping an entire sphere in PyOpenGL

时光怂恿深爱的人放手 提交于 2019-12-11 06:46:09
问题 I copied the corrected code here to apply my own texture from a solar imaging dataset onto an OpenGL sphere. In doing so I noticed that the texture does not wrap entirely around the sphere - only the "front half" - and the lighting shadow is not applied (also evident in the answer to that question). How do you modify the code to wrap the texture around the entire sphere? Here is the texture image which is data in a 360-degree longitude x sine(latitude) format (which actually should be

Efficiency of display lists in OpenGL with Python?

南笙酒味 提交于 2019-12-11 06:39:45
问题 I have been teaching myself OpenGL programming using the Python wrapper PyOpenGL, and am now working on my first project with it. This project is a music visualizer (not dissimilar to whitecap) using many independently moving and independently colored cubes. My current method is to have a display list for one cube and call it repeatedly changing color and location with glColor and glTranslatef like so (pseudocode): glPushMatrix() glPushMatrix() #Why do I need to call this twice? for x in

How to rotate a certain object (Quad) in PyOpenGL?

僤鯓⒐⒋嵵緔 提交于 2019-12-11 06:24:17
问题 I am making a game in PyOpenGL where an object (e.g. cuboid) should face the camera. To do that, I have to rotate the specific object. How can I do that? glRotatef() rotates the whole world, but not a single object, so I can't use it. Also, the solution of glPushMatrix() How can I rotate multiple quads separately? (Pygame, PyOpengl) doesn't work. A solution that changes the vertex will be good. #!/usr/local/bin/python3 import pygame from pygame.locals import * from OpenGL.GL import * from

Visualizing a 3D NumPy array with PyOpenGL

折月煮酒 提交于 2019-12-11 04:38:18
问题 I want to create a PyOpenGL/QtOpenGL widget that will allow me to visualize an arbitrary NumPy 3D matrix, not unlike the following Hinton diagram envisioned as a "cube of cubes" instead of a "square of squares": I'm having a bit of a rough time with OpenGL though. Here is my code thus far: from OpenGL.GL import * from OpenGL.GLUT import * from PyQt4 import QtGui, QtOpenGL import numpy as np action_keymap = { # 'a': lambda: glTranslate(-1, 0, 0), # 'd': lambda: glTranslate( 1, 0, 0), # 'w':