zoukankan      html  css  js  c++  java
  • (Python OpenGL)【1】你好顶点 PyOpenGL

    原文链接(C语言环境)(Python OpenGL)

    我用python实现的代码:

     1 __author__ = "WSX"
     2 from OpenGL.GLUT.freeglut import *   #新版本的glut
     3 import ctypes
     4 from OpenGL.GLUT import *
     5 from OpenGL.GL import *
     6 from OpenGL.GLU import *
     7 from OpenGL.GL import shaders
     8 import numpy as np
     9 
    10 def Draw():
    11     glClear(GL_COLOR_BUFFER_BIT)
    12     glEnableVertexAttribArray(0)
    13     glBindBuffer(GL_ARRAY_BUFFER, VBO)
    14     glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0)
    15     glDrawArrays(GL_POINTS, 0, 1)
    16     glDisableVertexAttribArray(0)
    17     glutSwapBuffers()
    18 
    19 def buffer():
    20     global VBO
    21     vertices = np.array([0.0 , 0.0 , 0.0],dtype="float32")
    22     VBO = glGenBuffers(1)    #创建对象
    23     glBindBuffer(GL_ARRAY_BUFFER , VBO)  #绑定
    24     glBufferData(GL_ARRAY_BUFFER , vertices.nbytes , vertices , GL_STATIC_DRAW)  #输入数据
    25 
    26 def main():
    27     glutInit([])
    28     glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA)  # 显示模式 双缓存
    29     glutInitWindowPosition(100, 100)  # 窗口位置
    30     glutInitWindowSize(500, 500)  # 窗口大小
    31     glutCreateWindow("point")  # 创建窗口
    32     glutInitContextVersion(4,3)   #为了兼容
    33     glutInitContextProfile(GLUT_CORE_PROFILE)   #为了兼容
    34     glutDisplayFunc(Draw)  # 回调函数
    35     glClearColor(0.0, 0.0, 0.0, 0.0)
    36     buffer()
    37     glutMainLoop()
    38 
    39 
    40 main()
  • 相关阅读:
    SQL Server创建表
    SQL Server创建数据库
    SQL Server创建索引
    SQL Server创建视图
    SQL Server创建存储过程
    SQL Server创建触发器
    Unity3D与VS2008结合,加快Unity3D C#开发!
    c#哈希表的用法
    长沙做网站公司解密如何编写高效率的SQL语句
    高效SQL语句必杀技
  • 原文地址:https://www.cnblogs.com/WSX1994/p/9077394.html
Copyright © 2011-2022 走看看