Skip to content

Commit

Permalink
Support for dynamically loading shaders
Browse files Browse the repository at this point in the history
  • Loading branch information
rafraser committed Nov 7, 2019
1 parent 4b82a77 commit f3f1016
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions opengl/src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,22 @@ display = do
flush
swapBuffers

getShaderName :: [String] -> String
getShaderName [] = "test"
getShaderName args = do head args

main :: IO()
main = do
_ <- getArgsAndInitialize
(name, args) <- getArgsAndInitialize
initialDisplayMode $= [RGBMode, WithDepthBuffer, DoubleBuffered]
initialWindowSize $= Size 500 500
_ <- createWindow "Shader Test"

let shaderName = getShaderName args

-- Shaders?
vs <- readCompileShader VertexShader "test.vert"
fs <- readCompileShader FragmentShader "test.frag"
vs <- readCompileShader VertexShader ("shaders/" ++ shaderName ++ ".vert")
fs <- readCompileShader FragmentShader ("shaders/" ++ shaderName ++ ".frag")
loadShaders [vs, fs]

displayCallback $= display
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit f3f1016

Please sign in to comment.