summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2019-05-18 22:43:06 -0400
committerJoe Crayne <joe@jerkface.net>2019-05-18 22:43:06 -0400
commitb00e114facc43d94aebefa103caa7df61b39d246 (patch)
tree6f2bfee3669101e31ad08b60c00b07e8ed63995b
parentfbb54c463cfd5171a582bb3d9668321d9d450f87 (diff)
Some notes.
-rw-r--r--MaskableStream.hs21
1 files changed, 16 insertions, 5 deletions
diff --git a/MaskableStream.hs b/MaskableStream.hs
index c023998..e6628e6 100644
--- a/MaskableStream.hs
+++ b/MaskableStream.hs
@@ -57,6 +57,12 @@ bindTextureCommand tlookup ulookup n = GLBindTexture (inputTypeToTextureTarget $
57 uniInputType (GLTypedUniform ty _) = unwitnessType ty 57 uniInputType (GLTypedUniform ty _) = unwitnessType ty
58 uniInputType (GLUniform r) = objectType r 58 uniInputType (GLUniform r) = objectType r
59 59
60-- One of these:
61-- VertexAttribPointer -- Array
62-- VertexAttribIPointer -- streams.
63-- VertexAttribI{1,2,3,4}[u]iv -- constant integer attribute.
64-- Or some number of these in sequence:
65-- VertexAttrib{1,2,3,4}fv -- constant vector or matrix of floats.
60setVertexAttribCommmand :: (t -> Stream Buffer) -> (GLuint, t) -> GLObjectCommand 66setVertexAttribCommmand :: (t -> Stream Buffer) -> (GLuint, t) -> GLObjectCommand
61setVertexAttribCommmand alookup (i,name) = case alookup name of 67setVertexAttribCommmand alookup (i,name) = case alookup name of
62 Stream ty (Buffer arrs bo) arrIdx start len -> mkAttrCmd i bo n (arrayTypeToGLType arrType) (intPtrToPtr $! offset) 68 Stream ty (Buffer arrs bo) arrIdx start len -> mkAttrCmd i bo n (arrayTypeToGLType arrType) (intPtrToPtr $! offset)
@@ -107,6 +113,10 @@ drawElementsCommand prim (IndexStream (Buffer arrs bo) arrIdx start idxCount)
107 idxType = arrayTypeToGLType arrType 113 idxType = arrayTypeToGLType arrType
108 ptr = intPtrToPtr $! fromIntegral (arrOffs + start * sizeOfArrayType arrType) 114 ptr = intPtrToPtr $! fromIntegral (arrOffs + start * sizeOfArrayType arrType)
109 115
116-- Note: all enabled attribute arrays should have the same count.
117-- So an object should select similarly sized streams from 'dStreams' of GPUData.
118-- So the 'mAttributes' map of a Mesh should contain equally sized arrays.
119-- uploadMeshToGPU uses a single Buffer for all of a Mesh's attributes.
110objectDrawStyle :: (GLsizei -> [(GLint,GLsizei)]) -- ^ mask, normally \x -> [(0,x)] 120objectDrawStyle :: (GLsizei -> [(GLint,GLsizei)]) -- ^ mask, normally \x -> [(0,x)]
111 -> Object 121 -> Object
112 -> Either [(GLint,GLsizei)] (IndexStream Buffer) 122 -> Either [(GLint,GLsizei)] (IndexStream Buffer)
@@ -121,11 +131,12 @@ createObjectCommands texUnitMap topUnis obj prg =
121 createObjectCommands_ (objectEnvironment texUnitMap topUnis obj (pure . ((,) 0))) prg 131 createObjectCommands_ (objectEnvironment texUnitMap topUnis obj (pure . ((,) 0))) prg
122 132
123data ObjectEnvironment = ObjectEnvironment 133data ObjectEnvironment = ObjectEnvironment
124 { envPrim :: GLenum 134 { envPrim :: GLenum -- GL version of LambdaCube.GL.Primitive
125 , envDrawStyle :: Either [(GLint,GLsizei)] (IndexStream Buffer) 135 , envDrawStyle :: Either [(GLint,GLsizei)] -- Mask of array attributes (one draw command for pair).
126 , tlookup :: String -> IORef GLint 136 (IndexStream Buffer) -- Indirect P_TriangleStripI or P_TrianglesI indices.
127 , ulookup :: String -> GLUniform 137 , tlookup :: String -> IORef GLint -- lookup texture unit
128 , alookup :: String -> Stream Buffer 138 , ulookup :: String -> GLUniform -- lookup uniform
139 , alookup :: String -> Stream Buffer -- lookup vertex attribute
129 } 140 }
130 141
131objectEnvironment :: Map.Map String (IORef GLint) 142objectEnvironment :: Map.Map String (IORef GLint)