python+opengl显示三维模型小程序
来源:互联网 发布:配音阁软件 编辑:程序博客网 时间:2024/05/19 13:18
在win7+python3.5环境下配置opengl,并显示三维模型
首先安装opengl:
已经安装python的系统会自动安装pip,所以只需要一句pip命令就可以安装opengl了,命令如下:
pip install PyOpenGL PyOpenGL_accelerate
然后在python 中import相关功能,运行后会出现错误
OpenGL.error.NullFunctionError: Attempt to call an undefined function glutInit, check for bool(glutInit) before calling
或者:
SyntaxError: multiple statements found while compiling a single statement
可能是缺少相关dll文件,可以在这里下载到 http://pan.baidu.com/s/1dFhC8G5
拷到你建立的工程目录下,就是你写的程序的目录下就可以了。
然后运行下面的程序,就应该能够显示茶壶模型了。
from OpenGL.GL import *
from OpenGL.GLU import *from OpenGL.GLUT import *
def drawFunc():
#清楚之前画面
glClear(GL_COLOR_BUFFER_BIT)
glRotatef(0.1, 0,5,0) #(角度,x,y,z)
glutWireTeapot(0.5)
#刷新显示
glFlush()
#使用glut初始化OpenGL
glutInit()
#显示模式:GLUT_SINGLE无缓冲直接显示|GLUT_RGBA采用RGB(A非alpha)
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA)
#窗口位置及大小-生成
glutInitWindowPosition(0,0)
glutInitWindowSize(400,400)
glutCreateWindow(b"first")
#调用函数绘制图像
glutDisplayFunc(drawFunc)
glutIdleFunc(drawFunc)
#主循环
glutMainLoop()
阅读全文
5 0
- python+opengl显示三维模型小程序
- OpenGL导入三维模型
- 使用OpenGL和OpenCV分别显示三维模型和图像
- Qt环境下利用OpenGL显示三维模型
- Qt环境下利用OpenGL显示三维模型
- OpenGL显示三维汉字
- OpenGL三维坐标显示
- 一个用OpenGL显示图像色彩三维分布的程序
- OpenGL 三维模型的导入
- IOS显示三维模型
- OpenGL: 点阵显示生日快乐小程序
- Opengl读取及渲染Obj三维模型
- tao.opengl+C#绘制三维模型
- python三维模型批量导入
- OpenGL MD2模型显示
- OpenGL MDL模型显示
- OpenGL MD2模型显示
- OpenGL MDL模型显示
- C++输入输出流对象基本操作
- BPM之工作流
- 虚拟机VM管理
- 类型信息之Class对象
- Android开发人员不得不收集的工具类集合
- python+opengl显示三维模型小程序
- 资源收藏夹
- 电脑无线不能用(驱动正常)
- Vector与ArrayList区别
- MySQL memory 引擎 table is full 处理
- [leetcode]106. Construct Binary Tree from Inorder and Postorder Traversal
- no module named pydot
- 【VS开发】Visual C++内存泄露检测—VLD工具使用说明
- 生成iOS下的dylib