Last active
August 29, 2015 14:19
-
-
Save paniq/b880fce9d5be9d2975a2 to your computer and use it in GitHub Desktop.
render tetrahedron without vertex buffers
This file contains 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
; shader | |
(compile-program tet-pg | |
(glsl-string | |
(#version 150) | |
(#include "lib/ext.glsl") | |
(#include "lib/projection.glsl") | |
(#include "lib/hslhsv.glsl") | |
(#escape ubo_decls) | |
(const (vec3 (: data 4)) ((: vec3) | |
(vec3 -1 -1 -1) | |
(vec3 1 -1 1) | |
(vec3 1 1 -1) | |
(vec3 -1 1 1) | |
)) | |
(out (vec3 col)) | |
(define-proc nil (main) | |
(var ( | |
((vec3 p) (: data (% gl_VertexID (#n 4)))) | |
) | |
(= p (* (- p camera_origin) camera_aim)) | |
(= gl_Position (projection_transform mtx_proj.xy mtx_proj.z | |
(vec4 p 1) | |
)) | |
(= col (hue2rgb (/ (float gl_VertexID) 4))) | |
) | |
) | |
) | |
(glsl-string | |
(#version 150) | |
(in (vec3 col)) | |
(out (vec4 color)) | |
(define-proc nil (main) | |
(= color (vec4 col 1)) | |
) | |
) | |
) | |
; render | |
(glUseProgram tet-pg) | |
; bogus vao that contains nothing | |
(glBindVertexArray null-vao) | |
; presto | |
(glDrawArrays GL_TRIANGLE_STRIP 0 6) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment