correct example, add TODO in GLSL.hs, add export generateGLSL

This commit is contained in:
mtgmonkey
2025-11-30 19:09:48 +01:00
parent 2bc1cab2af
commit fa90055518
2 changed files with 12 additions and 6 deletions

View File

@@ -13,10 +13,16 @@ module Language.GLSL
, VariableName , VariableName
, Variable(..) , Variable(..)
, GLSLType(..) , GLSLType(..)
, generateGLSL
, generateCheckedGLSL , generateCheckedGLSL
) )
where where
-- TODO
--
-- -[ ] Add support for multiple shaders in sequence
-- -[ ] Add check if the previous shader output the next shader's inputs
-- IMPORTS -- -- IMPORTS --
import Relude import Relude
@@ -29,7 +35,7 @@ class GLSLExpression a where
instance GLSLExpression Program where instance GLSLExpression Program where
toGLSLText expressions = toGLSLText expressions =
foldr ((<>)) "}" $ map (toGLSLText) expressions foldr ((<>)) "}\n" $ map (toGLSLText) expressions
instance GLSLExpression Expression where instance GLSLExpression Expression where
toGLSLText toGLSLText
@@ -87,7 +93,7 @@ instance GLSLExpression ParameterQualifier where
toGLSLText Out = "out" toGLSLText Out = "out"
instance GLSLExpression Variable where instance GLSLExpression Variable where
toGLSLText GL_POSITION = "gl_position" toGLSLText GL_POSITION = "gl_Position"
toGLSLText (Variable name _) = name toGLSLText (Variable name _) = name
instance GLSLExpression GLSLType where instance GLSLExpression GLSLType where

View File

@@ -24,10 +24,10 @@ main = do
fragShader :: Program fragShader :: Program
fragShader = fragShader =
[ VersionDeclaration 450 Core [ VersionDeclaration 450 Core
, VariableDeclaration Nothing In fragColorIn , VariableDeclaration Nothing In fragColorOut
, VariableDeclaration Nothing Out fragColorOut , VariableDeclaration Nothing Out fragColor
, MainStart , MainStart
, VariableAssignment fragColorOut fragColorIn , VariableAssignment fragColor fragColorOut
] ]
vertShader :: Program vertShader :: Program
@@ -41,7 +41,7 @@ vertShader =
, VariableAssignment fragColorOut vertexColor , VariableAssignment fragColorOut vertexColor
] ]
fragColorIn = Variable "fragColorIn" $ GLSLVec4 GLSLFloat fragColor = Variable "fragColor" $ GLSLVec4 GLSLFloat
fragColorOut = Variable "fragColorOut" $ GLSLVec4 GLSLFloat fragColorOut = Variable "fragColorOut" $ GLSLVec4 GLSLFloat
vertexPosition = Variable "vertexPosition" $ GLSLVec4 GLSLFloat vertexPosition = Variable "vertexPosition" $ GLSLVec4 GLSLFloat
vertexColor = Variable "vertexColor" $ GLSLVec4 GLSLFloat vertexColor = Variable "vertexColor" $ GLSLVec4 GLSLFloat