{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}

module Haskengl.IO.Shaders.Shaders (fragShader, vertShader) where

-- IMPORTS --

import Relude

import Language.GLSL

fragShader :: Program
fragShader =
  [ VersionDeclaration 450 Core
  , VariableDeclaration Nothing In fragColorOut
  , VariableDeclaration Nothing In uv
  , VariableDeclaration Nothing Out fragColor
  , DangerousExpression "uniform sampler2D tex;"
  , MainStart
  , DangerousExpression "fragColor = texture(tex, uv);"
  ]

vertShader :: Program
vertShader =
  [ VersionDeclaration 450 Core
  , VariableDeclaration (Just $ Location 0) In vertexPosition
  , VariableDeclaration (Just $ Location 1) In vertexColor
  , VariableDeclaration (Just $ Location 2) In uvCoords
  , VariableDeclaration Nothing Out fragColorOut
  , VariableDeclaration Nothing Out uv
  , VariableDeclaration Nothing Uniform projection
  , MainStart
  , DangerousExpression "gl_Position = projection * vec4(vertexPosition, 1.0);"
  , VariableAssignment fragColorOut vertexColor
  , VariableAssignment uv uvCoords
  ]

fragColor = Variable "fragColor" $ GLSLVec4 GLSLFloat
fragColorOut = Variable "fragColorOut" $ GLSLVec4 GLSLFloat
vertexPosition = Variable "vertexPosition" $ GLSLVec3 GLSLFloat
vertexColor = Variable "vertexColor" $ GLSLVec4 GLSLFloat
projection = Variable "projection" $ GLSLMat4 GLSLFloat
uvCoords = Variable "uvCoords" $ GLSLVec2 GLSLFloat
uv = Variable "uv" $ GLSLVec2 GLSLFloat
