-
-
Save zeffii/c210322b4b5f489b2886 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
| from enum import Enum | |
| import bgl as GL | |
| Triangles = 0 | |
| NumVAOs = 1 | |
| ArrayBuffer = 0 | |
| NumBuffers = 1 | |
| vPosition = 0 | |
| VAOs = GL.Buffer(GL.GL_INT, [NumVAOs]) | |
| Buffers = GL.Buffer(GL.GL_INT, [NumBuffers]) | |
| NumVertices = 6 | |
| def init(): | |
| GL.glGenVertexArrays(NumVAOs, VAOs) | |
| GL.glBindVertexArray(VAOs[Triangles]) | |
| vertices = GL.Buffer(GL.GL_FLOAT, [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.GL_INT(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() | |
| display() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment