[ Python ] OpenGL
pyOpenGL Installation
Package Version
------------------- -------
numpy 1.14.2
PyOpenGL 3.1.0
PyOpenGL-accelerate 3.1.0
demo1
# -*- coding: utf-8 -*-
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import * def init():
glClearColor(1, 1, 1, 1)
gluOrtho2D(-1, 1, -1, 1) def triangle():
glClear(GL_COLOR_BUFFER_BIT)
glColor3f(1, 0, 0)
glBegin(GL_TRIANGLES) glColor3f(1, 0, 0)
glVertex2f(-1, -1) glColor3f(0, 1, 0)
glVertex2f(1, -1) glColor3f(0, 0, 1)
glVertex2f(0, 1) glEnd()
glFlush() def main():
glutInit(sys.argv)
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB)
glutInitWindowSize(800, 600)
glutInitWindowPosition(50, 50)
glutCreateWindow("Triangle")
glutDisplayFunc(triangle)
init()
glutMainLoop() if __name__ == '__main__':
main()
demo2
# -*- coding: utf-8 -*-
from OpenGL.GL import * from OpenGL.GLU import *
from OpenGL.GLUT import * def drawFunc():
# 清楚之前画面
glClear(GL_COLOR_BUFFER_BIT)
glRotatef(0.01, 3, 2, 1) # (角度,x,y,z)
glutWireTeapot(0.5)
glutWireCube(0.5)
# 刷新显示
glFlush() # 使用glut初始化OpenGL
glutInit()
# 显示模式:GLUT_SINGLE无缓冲直接显示|GLUT_RGBA采用RGB(A非alpha)
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA)
# 窗口位置及大小-生成
glutInitWindowPosition(0, 0)
glutInitWindowSize(400, 400)
wnd = glutCreateWindow(b"first")
# 调用函数绘制图像
glutDisplayFunc(drawFunc)
glutIdleFunc(drawFunc)
# 主循环
glutMainLoop()
[ Python ] OpenGL的更多相关文章
- 初试PyOpenGL四 (Python+OpenGL)GPU粒子系统与基本碰撞
这篇相当于是对前三篇的总结,基本效果如下: 在初试PyOpenGL一 (Python+OpenGL)讲解Pyopengl环境搭建,网格,球体,第一与第三人称摄像机的实现.在初试PyOpenGL二 (P ...
- (Python OpenGL)【5】平移 PyOpenGL
(Python OpenGL) 原文:http://ogldev.atspace.co.uk/www/tutorial06/tutorial06.html (英文) 下面是我翻译过来的: 背景 在本 ...
- (Python OpenGL)【4】Uniform变量 PyOpenGL
(Python OpenGL) 原文:http://ogldev.atspace.co.uk/www/tutorial05/tutorial05.html(英文) __author__ = " ...
- (Python OpenGL)【3】着色器 PyOpenGL
(Python OpenGL)现在开始我们使用着色器来进行渲染.着色器是目前做3D图形最流行的方式. OpenGL的渲染管线流程: 数据传输到OpenGL—>顶点处理器—>细分着色—> ...
- 【Python OpenGL】【2】第一个三角形(Pyopengl)
根据顶点缓存来生成图元(Python OpenGL) 原文(英文链接)http://ogldev.atspace.co.uk/www/tutorial03/tutorial03.html __auth ...
- (Python OpenGL)【 0】关于VAO和VBO以及OpenGL新特性
(Python OpenGL)关于新版OpenGL需要了解的: 随着OpenGL状态和固定管线模式的移除,我们不在用任何glEnable函数调用,而且也不会有glVertex.glColor等函数调用 ...
- (Python OpenGL)【1】你好顶点 PyOpenGL
原文链接(C语言环境)(Python OpenGL) 我用python实现的代码: __author__ = "WSX" from OpenGL.GLUT.freeglut imp ...
- 初试PyOpenGL一 (Python+OpenGL)
很早就一直想学Python,看到一些书都有介绍,不管是做为游戏的脚本语言,还是做为开发项目的主要语言都有提及(最主要的CUDA都开始支持Python,CUDA后面一定要学),做为先熟悉一下Python ...
- Python,OpenGL生命游戏
初学Python和OpenGL,练手的第一个小程序life.py,这个小程序在日后会不断调整,增加类.优化判断及操作 执行效果: 按正规生命游戏的规则: 1.周围生命等于3时产生生命 2.周围生命等于 ...
- Python OpenGL学习(1): 环境配置及错误篇
系统环境是:Ubuntu 14.04 个人首次接触OpenGL,学到哪就写到哪. 1.模块安装: sudo apt-get install python-openglpip install PyOpe ...
随机推荐
- Altium Designer学习---如何进行SI仿真
Altium designer 如何进行SI仿真. 1.仿真电路中需要至少一块集成电路: 2.器件的IBIS模型: 3.在规则中必须设定电源网络和地网络: 4.建立SI规则约束: 5.层堆栈必须设置正 ...
- python 字符编码判断 chardet评测
之前一直想找到一个模块,针对字符判断是什么字符集编码的库 网上有chardet的blog,发现自己的环境有这个库,于是就做了测试 >>> import chardet >> ...
- netty 的 Google protobuf 开发
根据上一篇博文 Google Protobuf 使用 Java 版 netty 集成 protobuf 的方法非常简单.代码如下: server package protobuf.server.imp ...
- ocelot配置
动态配置 { "ReRoutes": [], "Aggregates": [], "GlobalConfiguration": { &quo ...
- Windows 安装服务 的两种方式
第一种 - 安装服务时自定义服务名称:(注意 binpath= 和路径之间的那个空格)sc create 服务名称 binpath= "D:\Service.exe" di ...
- Centos7 php-fpm root 运行,执行 kill 等系统命令
Centos7 php-fpm root 运行,执行 kill 等系统命令 前提 当前系统安装的是宝塔环境,PHP的环境在如下的目录: /www/server/php/72/etc 1 修改 php- ...
- C# 服务端篇之实现RestFul Service开发(简单实用)
一.RestFul简介 REST(Representational State Transfer 通常被翻译为“表述性状态传输”或者“表述性状态转移”)是RoyFielding提出的一个描述互联系统架 ...
- gitlab服务器IP调整后修改domian或ip
背景 本地搭建的gitlab 服务器,在 /etc/gitlab/gitlab.rb 中 external_url 通常是局域网ip的形式.如下所示 external_url 'http://192. ...
- HTML <script> 标签的 defer 和 async 属性
HTMKL <script>标签中有defer和async属性,简单介绍一下两者的区别吧. 普通的script标签会让浏览器立即下载并执行完毕,执行也是按照先后顺序,再进行后面的解析. ...
- 2.node.js (二)服务器登录注册 与 包的发布
get: 不安全 小 2k 数据会在地址栏上显示 从服务器获取 快 post: 相对安全 https 大 1G 不会 向服务器发送 慢 get:直接解析url地址 借助 url模块 var urlOb ...