Skip to content

Instantly share code, notes, and snippets.

@SimonDanisch
Created April 3, 2014 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SimonDanisch/9956363 to your computer and use it in GitHub Desktop.
Save SimonDanisch/9956363 to your computer and use it in GitHub Desktop.
function position_transformation(mvp::Matrix{Float32}, vertices::Vector3)
return mvp * Vector4(vertices, 1f0)
end
cam = PerspectiveCamera(....)
color = Vector4(0, 1, 0, 1)
vertShader = [
"vertices" => GLBuffer([Vector3(0, 1, 0), Vector3(0, 1, 0), Vector3(0, 0, 0)], primitiveMode = GL_TRIANGLES, drawMode = GL_STATIC_DRAW),
"mvp" => cam,
"gl_Position" => (position_transformation, (mvp::Matrix{Float32}, vertices::Vector3))
]
fragShader = [
"color" => color
"gl_FragColor" => (color::Vector4 -> color, (color::Vector4))
]
#Make the render object
renderTest = GLRenderObject(vertShader, fragShader)
#Define how you want to render the vertex array
push!(renderTest.postRenderFunctions, (x -> glDrawArrays(x.vertArray.primitiveMode, 0, x.vertArray.size), (renderTest,)))
#register some action that manipulates the camera
registerEventAction(EventAction{MouseClicked}(x -> x.key == MOUSE_MIDDLE_DOWN || x.key == MOUSE_MIDDLE_UP, (), zoom, (cam,)))
#I don't have any code for this, but this should be fairly easy to implement
registerSlider(color)
#and then finally inside the glDrawLoop
render(renderTest)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment