diff options
author | Joe Crayne <joe@jerkface.net> | 2019-05-18 22:43:06 -0400 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2019-05-18 22:43:06 -0400 |
commit | b00e114facc43d94aebefa103caa7df61b39d246 (patch) | |
tree | 6f2bfee3669101e31ad08b60c00b07e8ed63995b | |
parent | fbb54c463cfd5171a582bb3d9668321d9d450f87 (diff) |
Some notes.
-rw-r--r-- | MaskableStream.hs | 21 |
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. | ||
60 | setVertexAttribCommmand :: (t -> Stream Buffer) -> (GLuint, t) -> GLObjectCommand | 66 | setVertexAttribCommmand :: (t -> Stream Buffer) -> (GLuint, t) -> GLObjectCommand |
61 | setVertexAttribCommmand alookup (i,name) = case alookup name of | 67 | setVertexAttribCommmand 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. | ||
110 | objectDrawStyle :: (GLsizei -> [(GLint,GLsizei)]) -- ^ mask, normally \x -> [(0,x)] | 120 | objectDrawStyle :: (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 | ||
123 | data ObjectEnvironment = ObjectEnvironment | 133 | data 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 | ||
131 | objectEnvironment :: Map.Map String (IORef GLint) | 142 | objectEnvironment :: Map.Map String (IORef GLint) |