add hs-glsl library, remove shader files
This commit is contained in:
10
frag.glsl
10
frag.glsl
@@ -1,10 +0,0 @@
|
|||||||
#version 450 core
|
|
||||||
|
|
||||||
in vec4 fragColor_in;
|
|
||||||
|
|
||||||
out vec4 fragColor_out;
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
fragColor_out = fragColor_in;
|
|
||||||
}
|
|
||||||
Submodule lib/hs-glsl updated: 2bc1cab2af...fa90055518
@@ -20,7 +20,7 @@
|
|||||||
"-rtsopts"
|
"-rtsopts"
|
||||||
"-with-rtsopts=-N"
|
"-with-rtsopts=-N"
|
||||||
# hs-glsl
|
# hs-glsl
|
||||||
"-i./lib/hs-glsl/src/Language/GLSL.hs"
|
"-i./lib/hs-glsl/src"
|
||||||
# src
|
# src
|
||||||
"-i./src"
|
"-i./src"
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -8,15 +8,18 @@ module IO (openWindow, shutdownWindow, view) where
|
|||||||
import qualified Graphics.Rendering.OpenGL as GL
|
import qualified Graphics.Rendering.OpenGL as GL
|
||||||
import Graphics.Rendering.OpenGL (($=))
|
import Graphics.Rendering.OpenGL (($=))
|
||||||
import qualified Graphics.UI.GLFW as GLFW
|
import qualified Graphics.UI.GLFW as GLFW
|
||||||
|
import qualified Language.GLSL as GLSL
|
||||||
|
|
||||||
import Control.Exception
|
import Control.Exception
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
|
import Data.Text (unpack)
|
||||||
import Foreign.Ptr
|
import Foreign.Ptr
|
||||||
import Foreign.Marshal.Array
|
import Foreign.Marshal.Array
|
||||||
import Foreign.Storable
|
import Foreign.Storable
|
||||||
|
|
||||||
import LoadShaders
|
import LoadShaders
|
||||||
import Relude
|
import Relude
|
||||||
|
import Shaders
|
||||||
import Types
|
import Types
|
||||||
|
|
||||||
-- VIEW --
|
-- VIEW --
|
||||||
@@ -100,8 +103,8 @@ initResources = do
|
|||||||
|
|
||||||
-- load shaders
|
-- load shaders
|
||||||
program <- loadShaders
|
program <- loadShaders
|
||||||
[ ShaderInfo GL.VertexShader (FileSource "vert.glsl")
|
[ ShaderInfo GL.VertexShader (StringSource $ unpack $ GLSL.generateGLSL vertShader)
|
||||||
, ShaderInfo GL.FragmentShader (FileSource "frag.glsl")
|
, ShaderInfo GL.FragmentShader (StringSource $ unpack $ GLSL.generateGLSL fragShader)
|
||||||
]
|
]
|
||||||
GL.currentProgram $= Just program
|
GL.currentProgram $= Just program
|
||||||
|
|
||||||
|
|||||||
35
src/Shaders.hs
Normal file
35
src/Shaders.hs
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
{-# LANGUAGE NoImplicitPrelude #-}
|
||||||
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
|
||||||
|
module Shaders (fragShader, vertShader) where
|
||||||
|
|
||||||
|
-- IMPORTS --
|
||||||
|
|
||||||
|
import Relude
|
||||||
|
|
||||||
|
import Language.GLSL
|
||||||
|
|
||||||
|
fragShader :: Program
|
||||||
|
fragShader =
|
||||||
|
[ VersionDeclaration 450 Core
|
||||||
|
, VariableDeclaration Nothing In fragColorOut
|
||||||
|
, VariableDeclaration Nothing Out fragColor
|
||||||
|
, MainStart
|
||||||
|
, VariableAssignment fragColor fragColorOut
|
||||||
|
]
|
||||||
|
|
||||||
|
vertShader :: Program
|
||||||
|
vertShader =
|
||||||
|
[ VersionDeclaration 450 Core
|
||||||
|
, VariableDeclaration (Just $ Location 0) In vertexPosition
|
||||||
|
, VariableDeclaration (Just $ Location 1) In vertexColor
|
||||||
|
, VariableDeclaration Nothing Out fragColorOut
|
||||||
|
, MainStart
|
||||||
|
, VariableAssignment GL_POSITION vertexPosition
|
||||||
|
, VariableAssignment fragColorOut vertexColor
|
||||||
|
]
|
||||||
|
|
||||||
|
fragColor = Variable "fragColor" $ GLSLVec4 GLSLFloat
|
||||||
|
fragColorOut = Variable "fragColorOut" $ GLSLVec4 GLSLFloat
|
||||||
|
vertexPosition = Variable "vertexPosition" $ GLSLVec4 GLSLFloat
|
||||||
|
vertexColor = Variable "vertexColor" $ GLSLVec4 GLSLFloat
|
||||||
Reference in New Issue
Block a user