From b9cba33b81c880c8f7aed92817ddd1acaca9c331 Mon Sep 17 00:00:00 2001 From: jgk Date: Tue, 23 Feb 2021 21:06:12 +0100 Subject: [PATCH] Cleanup, remove files --- app/Main.hs | 1 - src/Render.hs | 108 --------------------------------- src/Rendering/Picture/Color.hs | 21 ------- 3 files changed, 130 deletions(-) delete mode 100644 src/Render.hs delete mode 100644 src/Rendering/Picture/Color.hs diff --git a/app/Main.hs b/app/Main.hs index c116d9b2e..2fb1fb07c 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -3,7 +3,6 @@ module Main where import Loop import EventHelper import Shaders -import Render import Shapes import Dodge.Prototypes diff --git a/src/Render.hs b/src/Render.hs deleted file mode 100644 index 5372b97bb..000000000 --- a/src/Render.hs +++ /dev/null @@ -1,108 +0,0 @@ -module Render where -import Shapes -import Graphics.Rendering.OpenGL hiding (imageHeight,imageWidth) -import Foreign -import Loop -import Codec.Picture -import qualified Data.Vector.Storable as V - - -render :: [Program] -> b -> Shape -> IO () -render progs _ (Shape primitiveMode vs) = do - currentProgram $= Just (progs !! 0) - let vertices = flattenVertices vs - numVertices = length vertices - vertexSize = sizeOf (head vertices) - - -- setup VBO - shape <- genObjectName - bindVertexArrayObject $= Just shape - - -- setup VBA - arrayBuffer <- genObjectName - bindBuffer ArrayBuffer $= Just arrayBuffer - withArray vertices $ \ptr -> do - bufferData ArrayBuffer $= (fromIntegral (numVertices * vertexSize), ptr, StaticDraw) - - let firstIndex = 0 - vPosition = AttribLocation 0 - vColor = AttribLocation 1 - vertexAttribPointer vPosition $= - ( ToFloat - , VertexArrayDescriptor 3 Float (fromIntegral $ vertexSize * 7) - (bufferOffset (firstIndex * vertexSize)) - ) - vertexAttribArray vPosition $= Enabled - - vertexAttribPointer vColor $= - ( ToFloat - , VertexArrayDescriptor 4 Float (fromIntegral $ vertexSize * 7) - (bufferOffset ((firstIndex + 3) * vertexSize) ) - ) - vertexAttribArray vColor $= Enabled - --- clear [ColorBuffer,DepthBuffer] - - bindVertexArrayObject $= Just shape - drawArrays primitiveMode (fromIntegral firstIndex) (fromIntegral $ div numVertices 2) - - -render (_:prog:_) _ (Fade ps) = do - currentProgram $= Just prog - let vertices = flatten2 ps - numVertices = length vertices - vertexSize = sizeOf (head vertices) - --- -- setup uniform --- location <- get $ uniformLocation prog "winSize" --- uniform location $= winSizeVec - - -- setup VBO - arrayBuffer <- genObjectName - bindBuffer ArrayBuffer $= Just arrayBuffer - withArray vertices $ \ptr -> do - bufferData ArrayBuffer $= (fromIntegral (numVertices * vertexSize), ptr, StreamDraw) - - -- setup VAO - shape <- genObjectName - bindVertexArrayObject $= Just shape - - let firstIndex = 0 - inPosition = AttribLocation 0 - inColor = AttribLocation 1 - inRad = AttribLocation 2 - vertexAttribPointer inPosition $= - ( ToFloat - , VertexArrayDescriptor 3 Float (fromIntegral $ vertexSize * 8) - (bufferOffset (firstIndex * vertexSize)) - ) - vertexAttribArray inPosition $= Enabled - - vertexAttribPointer inColor $= - ( ToFloat - , VertexArrayDescriptor 4 Float (fromIntegral $ vertexSize * 8) - (bufferOffset ((firstIndex + 3) * vertexSize) ) - ) - vertexAttribArray inColor $= Enabled - - vertexAttribPointer inRad $= - ( ToFloat - , VertexArrayDescriptor 1 Float (fromIntegral $ vertexSize * 8) - (bufferOffset ((firstIndex + 7) * vertexSize) ) - ) - vertexAttribArray inRad $= Enabled - --- bindVertexArrayObject $= Just shape - drawArrays Points (fromIntegral firstIndex) (2) - - -flattenVertices :: [CPoint] -> [GLfloat] -flattenVertices = map realToFrac . concatMap (\(CPoint (x,y,z) (r,b,g,a)) -> [x,y,z,r,b,g,a]) - -flatten2 :: [((Float,Float,Float),(Float,Float,Float,Float),Float)] -> [GLfloat] -flatten2 = map realToFrac . concatMap f - where f ((x,y,z),(r,g,b,a),rad) = [x,y,z,r,g,b,a,rad] - -bufferOffset :: Integral a => a -> Ptr b -bufferOffset = plusPtr nullPtr . fromIntegral - diff --git a/src/Rendering/Picture/Color.hs b/src/Rendering/Picture/Color.hs deleted file mode 100644 index 8fc354554..000000000 --- a/src/Rendering/Picture/Color.hs +++ /dev/null @@ -1,21 +0,0 @@ -module Rendering.Picture.Color - where -import Geometry.Data - -type RGBA = (Float,Float,Float,Float) - -black,red,green,blue,yellow,cyan,magenta,rose,violet,azure,aquamarine,chartreuse,orange,white::RGBA -black = (0,0,0,1) -red = (1,0,0,1) -green = (0,1,0,1) -blue = (0,0,1,1) -yellow = (1,1,0,1) -cyan = (0,1,1,1) -magenta = (1,0,1,1) -rose = (1,0,0.5,1) -violet = (0.5,0,1,1) -azure = (0,0.5,1,1) -aquamarine= (0,1,0.5,1) -chartreuse= (0.5,1,0,1) -orange = (1,0.5,0,1) -white = (1,1,1,1)