finished episode 8
This commit is contained in:
parent
d7773af8b6
commit
4acc1dd84e
|
@ -7,7 +7,9 @@ OpenGL tutorial by The Cherno
|
||||||
There are some major deviations from the tutorial setup here as follows:
|
There are some major deviations from the tutorial setup here as follows:
|
||||||
|
|
||||||
* Code base is entirely written in Haskell, not C++
|
* Code base is entirely written in Haskell, not C++
|
||||||
* instead of GLFW with GLEW I use SDL2 out of familiarity
|
* Instead of GLFW with GLEW I use SDL2 out of familiarity
|
||||||
|
* Shaders are actually split into files per type, since IÄmnot willing to
|
||||||
|
unleash Haskell list magic
|
||||||
|
|
||||||
I leave as many helpful comments as possible throughout the code, so feel free
|
I leave as many helpful comments as possible throughout the code, so feel free
|
||||||
to peruse it.
|
to peruse it.
|
||||||
|
|
8
res/shaders/frag.shader
Normal file
8
res/shaders/frag.shader
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#version 330 core
|
||||||
|
|
||||||
|
out vec4 color;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
color = vec4(0.0, 1.0, 0.0, 0.5);
|
||||||
|
}
|
8
res/shaders/vert.shader
Normal file
8
res/shaders/vert.shader
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#version 330 core
|
||||||
|
|
||||||
|
layout(location = 0) in vec4 position;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = position;
|
||||||
|
}
|
29
src/Main.hs
29
src/Main.hs
|
@ -23,6 +23,9 @@ import Foreign.Storable
|
||||||
import Data.Word
|
import Data.Word
|
||||||
|
|
||||||
import qualified Data.ByteString as B
|
import qualified Data.ByteString as B
|
||||||
|
import qualified Data.ByteString.Char8 as B8
|
||||||
|
|
||||||
|
import qualified Data.List as L
|
||||||
|
|
||||||
import System.Random (randomRIO)
|
import System.Random (randomRIO)
|
||||||
|
|
||||||
|
@ -105,29 +108,11 @@ main = do
|
||||||
|
|
||||||
-- -- SHADERS
|
-- -- SHADERS
|
||||||
|
|
||||||
-- define shader source code (usually these are separate files)
|
-- read in shaders from source file
|
||||||
let vertexShader = mconcat
|
vertSrc <- B.readFile "./res/shaders/vert.shader"
|
||||||
[ "#version 330 core\n"
|
fragSrc <- B.readFile "./res/shaders/frag.shader"
|
||||||
, "\n"
|
|
||||||
, "layout(location = 0) in vec4 position;\n"
|
|
||||||
, "\n"
|
|
||||||
, "void main()\n"
|
|
||||||
, "{\n"
|
|
||||||
, " gl_Position = position;\n"
|
|
||||||
, "}\n"
|
|
||||||
] :: B.ByteString
|
|
||||||
fragmentShader = mconcat
|
|
||||||
[ "#version 330 core\n"
|
|
||||||
, "\n"
|
|
||||||
, "out vec4 color;\n"
|
|
||||||
, "\n"
|
|
||||||
, "void main()\n"
|
|
||||||
, "{\n"
|
|
||||||
, " color = vec4(0.0, 1.0, 0.0, 0.5);\n"
|
|
||||||
, "}\n"
|
|
||||||
] :: B.ByteString
|
|
||||||
|
|
||||||
sp <- createShaderProgram vertexShader fragmentShader
|
sp <- createShaderProgram vertSrc fragSrc
|
||||||
GL.currentProgram $= Just sp
|
GL.currentProgram $= Just sp
|
||||||
|
|
||||||
-- -- EVENTING AND DRAWING
|
-- -- EVENTING AND DRAWING
|
||||||
|
|
Loading…
Reference in a new issue