Skip to content

Instantly share code, notes, and snippets.

@paniq
Last active August 29, 2015 14:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paniq/b880fce9d5be9d2975a2 to your computer and use it in GitHub Desktop.
Save paniq/b880fce9d5be9d2975a2 to your computer and use it in GitHub Desktop.
render tetrahedron without vertex buffers
; 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