pyopengl

How to rotate 2 objects independently in pygame and pyopengl

不想你离开。 提交于 2019-12-22 13:11:30
问题 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

Using OpenGL with Python [closed]

雨燕双飞 提交于 2019-12-20 08:39:45
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 5 years ago . So, I only know how to use Python, but I also know how to model in 3d. I've heard of OpenGL and I really want to learn how to use, because it seems very useful (I want to create simple games with it...). I found PyOpenGL, Python bindings for OpenGL, but I couldn't find any "real"

Reading depth buffer with PyOpenGL

久未见 提交于 2019-12-19 04:55:14
问题 Basically, I'm trying to extract a depth map (by this I mean a matrix with z corresponding to z-coordinates for vertices in GL.glVertex3dv(vertex) call - obviously, interpolated for plane pixels) after rendering a model (script is loading the model from file with path specified as the first command line argument). There are several questions which come to mind: why glReadPixels call returns a numpy array with shape (width, shape) , instead of (height, width) ? why it returns some trash, not

PyOpenGL glutInit NullFunctionError

人走茶凉 提交于 2019-12-17 09:32:20
问题 I am running Anaconda Python 2.7 on a Win7 x64 machine and used pip install PyOpenGL PyOpenGL_accelerate at the Anaconda command line to install PyOpenGL. I have some code (not my own I must confess) that makes use of glutInit import sys import math import numpy import OpenGL from OpenGL.GL import * from OpenGL.GLUT import * import Image import linkage # ... a whole load of definitions etc ... glutInit(sys.argv) glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB) glutInitWindowSize(600, 600)

PyOpenGL numpy texture appears as solid color

大兔子大兔子 提交于 2019-12-13 07:26:04
问题 I'm trying to set numpy arrays as OpenGl textures in pygame. The problem is that only the first pixel is taken as texture data and instead of a random pattern (for example) I only get a random color every time. import pygame from pygame.locals import * from OpenGL.GL import * from OpenGL.GLU import * import numpy as np #Settings width = 200 height = 300 resolution = (800,600) texture_data = np.random.randint(256,size=(height, width, 3)) #pygame init pygame.init() gameDisplay = pygame.display

how to combine wxPython, matplotlib and Pyopengl

╄→尐↘猪︶ㄣ 提交于 2019-12-13 05:08:31
问题 Hi so I currently have an application whereby I have a window displaying a matplotlib graph. i.e. such as this: from numpy import arange, sin, pi import matplotlib matplotlib.use('WXAgg') from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas from matplotlib.backends.backend_wx import NavigationToolbar2Wx from matplotlib.figure import Figure import wx class CanvasPanel(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent) self.figure = Figure() self

PyOpenGL sphere with texture

时光怂恿深爱的人放手 提交于 2019-12-12 21:27:49
问题 I want to use Python PyOpenGL for generating a scene of three spheres. Two on the side with color (red and green). Middle one with any texture on it (bricks texture which is actually square jpg file in the same directory as code is). There is what I have done so far: From some reason texture in the middle sphere generated by gluSphere() has strange behaviour. There are some small green triangles instead of my texture file. This is my texture file: I have tried to map this file as surface, e.g

Geometry shader doesn't do anything when fed GL_POINTS

时光怂恿深爱的人放手 提交于 2019-12-12 19:32:07
问题 I'm trying to use geometry shaders to turn points into line segments (GL_POINTS to GL_LINE_STRIP), but no line segments appear. If I change the input to GL_LINES, and just repeat the vertex, then I get the behavior I'm expecting. What's going on? Here's a complete program that demonstrates the behavior. As-is, I get nothing but a black window. Setting USE_POINTS to False gets me the rotating psychedelic flashing lines I'm expecting. #!/usr/bin/python from OpenGL.GL import * from OpenGL.GLU

How to resize a GLUT window?

血红的双手。 提交于 2019-12-12 16:25:03
问题 from OpenGL.extensions import alternate from OpenGL.GL import * from OpenGL.GL.ARB.multitexture import * from OpenGL.GLU import * from OpenGL.GLUT import * class TestTexture(): def __init__(self): self.window_width = 800 self.window_height = 800 def init(self): glClearColor(0.0, 0.0, 0.0, 0.0) glMatrixMode(GL_PROJECTION) glLoadIdentity() glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0) glMatrixMode(GL_MODELVIEW) glLoadIdentity() glEnable(GL_TEXTURE_2D) def display(self): glClear(GL_COLOR_BUFFER_BIT |

PyOpenGL. x = glGetDoublev(GL_MODELVIEW_MATRIX) Returns Memory Address

一个人想着一个人 提交于 2019-12-12 11:33:32
问题 I'm trying to store the location of a cube in the value x and when I try and print(x) instead of printing the location, it prints <OpenGL.arrays.ctypesarrays.c_double_Array_4_Array_4 object at 0x043E63A0> Extra Info: Windows 8.1 64-Bit Python 3.4.3 32-Bit PyOpenGL 3.1.1 32-Bit PyGame 32-Bit (Can't find the version) I have admin perms on my PC and the install of PyOpenGL and PyGame seemed to go ok. Thanks. If there's anythin else you would like to see e.g. the full code for my script, just ask