pyopengl faults in glGenTextures
i have this problem:
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from OpenGL.GL import *
>>> glGenTextures
<OpenGL.lazywrapper.glGenTextures object at 0x9d3b18c>
>>> glGenTextures(1)
Segmentation fault
i'm on Ubuntu 10.04 LTS
what can it b开发者_如何学JAVAe? where can i find some other info?
You're supposed to make a context active before calling any OpenGL functions. Also, glGenTextures
needs two parameters, so pyopengl isn't calling it directly. You'd have to look at the pyopengl source code to see exactly what's going wrong, but creating a context first is sure to be part of the solution.
An OpenGL context needs to be created before gl.glGenTextures can be called.
Example code:
import OpenGL.GLUT as glut
import OpenGL.GL as gl
# Init glut
glut.glutInit(())
glut.glutInitDisplayMode(
glut.GLUT_RGBA | glut.GLUT_DOUBLE | glut.GLUT_ALPHA | glut.GLUT_DEPTH | glut.GLUT_MULTISAMPLE
)
glut.glutInitWindowSize(40, 40)
glut.glutInitWindowPosition(0, 0)
window = glut.glutCreateWindow("title_of_the_window")
# Generate Texture Names
gl.glGenTextures(1)
精彩评论