You are not logged in.
Pages: 1
Hello!
Not 100% sure this is the right place for this question, but I am a newbie:
I am trying to get the PyOpenGL and PyOpenGL_accelerate modules working with my (very simple) pygame test program. All I am trying to do here is draw a 3d image using PyOpenGL.
I have spent several hours searching for solutions on this site and others without success.
I am running this program on arch linux in a python virtualenv and inside this virtual environment I have done the following prior to running my program:
$ pip install PyOpenGL PyOpenGL_accelerate
These two modules install successfully, and the: 'from OpenGL...' lines by themselves work fine.
The problem arises when I attempt to use the 'gluPerspective' function. If I run the program I get this error:
'OpenGL.error.NullFunctionError: Attempt to call an undefined function gluPerspective, check for bool(gluPerspective) before calling'
My code:
import pygame
from pygame.locals import *
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *
vertices = (
(1,-1,-1),
(1,1,-1),
(-1,1,-1),
(-1,-1,-1),
(1,-1,1),
(1,1,1),
(-1,-1,1),
(-1,1,1),
)
edges = (
(0,1),
(0,3),
(0,4),
(2,1),
(2,3),
(2,7),
(6,3),
(6,4),
(6,7),
(5,1),
(5,4),
(5,7),
)
def Draw_Cube():
glBegin(GL_LINES)
for edge in edges:
for vertex in edge:
glVertex3fv(vertices[vertex])
glEnd()
def main():
pygame.init()
display = (800,600)
pygame.display.set_mode(display,DOUBLEBUF|OPENGL)
gluPerspective(45.0,(display[0]/display[1]),1,50.0)
glTranslatef(0.0,0.0,-5.0)
glRotatef(20,0,0,0)
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
quit()
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
Draw_Cube()
pygame.display.flip()
pygame.time.wait(10)
main()I have noticed that if I comment out the gluPerspective line, the program doesn't crash, so at least the OpenGL.GL imports appear to be working.
From reading about others who have had this issue, I got the idea that perhaps code belonging to the 'freeglut' module was missing. There does not seem to be any way to install freeglut via pip inside the virtual environment so I installed:
sudo pacman -S python-opengl
Which installs opengl with freeglut as a dependency. But I get the same error.
I have also tried cloning the git repository instead of using pip, but with the same result (although I am not 100% sure I understand the cloning part correctly)
I have tried installing and running things outside the virtual environment, but this makes no difference.
Would appreciate some help!
Thanks
Last edited by mrconfused (2023-11-29 01:38:54)
Offline
Please edit your post to use [ code ] [ /code ] tags so it cecomes a lot more readable . see https://bbs.archlinux.org/help.php#bbcode
gluPerspective seems to be deprecated, https://www.khronos.org/opengl/wiki/GluPerspective_code should be helpful .
Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
clean chroot building not flexible enough ?
Try clean chroot manager by graysky
Online
Pages: 1