Created
November 29, 2015 16:35
-
-
Save anonymous/e3a4b04460111ad73ee9 to your computer and use it in GitHub Desktop.
test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bgl as GL | |
Triangles = 0 | |
NumVAOs = 1 | |
ArrayBuffer = 0 | |
NumBuffers = 1 | |
vPosition = 0 | |
VAOs = GL.GLuint(NumVAOs) | |
Buffers = GL.GLuint(NumBuffers) | |
NumVertices = GL.GLuint(6) | |
def init(): | |
GL.glGenVertexArrays(NumVAOs, VAOs) | |
GL.glBindVertexArray(VAOs[Triangles]) | |
vertices = GL.GLfloat(NumVertices, 2) = [ | |
[-0.90, -0.90], [0.85, -0.90], [-0.90, 0.85], | |
[0.90, -0.85], [0.90, 0.90], [-0.85, 0.90] | |
] | |
GL.glGenBuffers(NumBuffers, Buffers) | |
GL.glBindBuffer(GL.GL_ARRAY_BUFFER, Buffers[ArrayBuffer]) | |
GL.glBufferData(GL.GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL.GL_STATIC_DRAW) | |
shaders = GL.ShaderInfo([ | |
[GL.GL_VERTEX_SHADER, "triangles.vert"], | |
[GL.GL_FRAGMENT_SHADER, "triangles.frag"], | |
[GL.GL_NONE, None] | |
]) | |
program = GL.GLuint(GL.LoadShaders(shaders)) | |
GL.glUseProgram(program) | |
GL.glVertexAttribPointer(vPosition, 2, GL.GL_FLOAT, GL.GL_FALSE, 0, GL.BUFFER_OFFSET(0)) | |
GL.glEnableVertexAttribArray(vPosition) | |
def display(): | |
GL.glClear(GL.GL_COLOR_BUFFER_BIT) | |
GL.glBindVertexArray(VAOs[Triangles]) | |
GL.glDrawArrays(GL.GL_TRIANGLES, 0, NumVertices) | |
GL.glFlush() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment