Skip to content

Commit 4c5f286

Browse files
committed
Improved types for drawing commands. Ranges are still weird...
1 parent 4cc6666 commit 4c5f286

File tree

1 file changed

+26
-24
lines changed

1 file changed

+26
-24
lines changed

src/Graphics/Rendering/OpenGL/GL/VertexArrays.hs

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ module Graphics.Rendering.OpenGL.GL.VertexArrays (
2626
clientState, clientActiveTexture,
2727

2828
-- * Dereferencing and Rendering
29-
ArrayIndex, NumArrayIndices, NumIndexBlocks,
29+
ArrayIndex, NumArrayIndices, NumIndexBlocks, NumInstances,
30+
BaseInstance, BaseVertex,
3031
arrayElement,
3132

3233
drawArrays, drawArraysInstancedBaseInstance, drawArraysInstanced,
@@ -333,6 +334,16 @@ type NumArrayIndices = GLsizei
333334

334335
type NumIndexBlocks = GLsizei
335336

337+
type NumInstances = GLsizei
338+
339+
type BaseInstance = GLuint
340+
341+
type BaseVertex = GLint
342+
343+
-- TODO: The ranges (ArrayIndex, ArrayIndex) below should actually use GLuint:
344+
-- type RangeStart = GLuint
345+
-- type RangeEnd = GLuint
346+
336347
--------------------------------------------------------------------------------
337348

338349
arrayElement :: ArrayIndex -> IO ()
@@ -341,52 +352,43 @@ arrayElement = glArrayElement
341352
drawArrays :: PrimitiveMode -> ArrayIndex -> NumArrayIndices -> IO ()
342353
drawArrays = glDrawArrays . marshalPrimitiveMode
343354

344-
drawArraysInstancedBaseInstance :: PrimitiveMode -> ArrayIndex -> NumArrayIndices -> GLsizei -> GLuint -> IO () -- TODO: type
355+
drawArraysInstancedBaseInstance :: PrimitiveMode -> ArrayIndex -> NumArrayIndices -> NumInstances -> BaseInstance -> IO ()
345356
drawArraysInstancedBaseInstance = glDrawArraysInstancedBaseInstance . marshalPrimitiveMode
346357

347-
drawArraysInstanced :: PrimitiveMode -> ArrayIndex -> NumArrayIndices -> GLsizei -> IO () -- TODO: type
358+
drawArraysInstanced :: PrimitiveMode -> ArrayIndex -> NumArrayIndices -> NumInstances -> IO ()
348359
drawArraysInstanced = glDrawArraysInstanced . marshalPrimitiveMode
349360

350-
multiDrawArrays ::
351-
PrimitiveMode -> Ptr ArrayIndex -> Ptr NumArrayIndices -> NumIndexBlocks
352-
-> IO ()
361+
multiDrawArrays :: PrimitiveMode -> Ptr ArrayIndex -> Ptr NumArrayIndices -> NumIndexBlocks -> IO ()
353362
multiDrawArrays = glMultiDrawArrays . marshalPrimitiveMode
354363

355364
drawElements :: PrimitiveMode -> NumArrayIndices -> DataType -> Ptr a -> IO ()
356365
drawElements m c = glDrawElements (marshalPrimitiveMode m) c . marshalDataType
357366

358-
drawElementsInstancedBaseInstance :: PrimitiveMode -> NumArrayIndices -> DataType -> Ptr a -> GLsizei -> GLuint -> IO () -- TODO: type
367+
drawElementsInstancedBaseInstance :: PrimitiveMode -> NumArrayIndices -> DataType -> Ptr a -> NumInstances -> BaseInstance -> IO ()
359368
drawElementsInstancedBaseInstance m c = glDrawElementsInstancedBaseInstance (marshalPrimitiveMode m) c . marshalDataType
360369

361-
drawElementsInstanced :: PrimitiveMode -> NumArrayIndices -> DataType -> Ptr a -> GLsizei -> IO () -- TODO: type
370+
drawElementsInstanced :: PrimitiveMode -> NumArrayIndices -> DataType -> Ptr a -> NumInstances -> IO ()
362371
drawElementsInstanced m c = glDrawElementsInstanced (marshalPrimitiveMode m) c . marshalDataType
363372

364-
multiDrawElements ::
365-
PrimitiveMode -> Ptr NumArrayIndices -> DataType -> Ptr (Ptr a)
366-
-> NumIndexBlocks -> IO ()
367-
multiDrawElements m c =
368-
glMultiDrawElements (marshalPrimitiveMode m) c . marshalDataType
373+
multiDrawElements :: PrimitiveMode -> Ptr NumArrayIndices -> DataType -> Ptr (Ptr a) -> NumIndexBlocks -> IO ()
374+
multiDrawElements m c = glMultiDrawElements (marshalPrimitiveMode m) c . marshalDataType
369375

370-
drawRangeElements ::
371-
PrimitiveMode -> (ArrayIndex, ArrayIndex) -> NumArrayIndices -> DataType
372-
-> Ptr a -> IO ()
373-
drawRangeElements m (s, e) c =
374-
glDrawRangeElements (marshalPrimitiveMode m) (fromIntegral s)
375-
(fromIntegral e) c . marshalDataType
376+
drawRangeElements :: PrimitiveMode -> (ArrayIndex, ArrayIndex) -> NumArrayIndices -> DataType -> Ptr a -> IO ()
377+
drawRangeElements m (s, e) c = glDrawRangeElements (marshalPrimitiveMode m) (fromIntegral s) (fromIntegral e) c . marshalDataType
376378

377-
drawElementsBaseVertex :: PrimitiveMode -> NumArrayIndices -> DataType -> Ptr a -> GLint -> IO () -- TODO: type
379+
drawElementsBaseVertex :: PrimitiveMode -> NumArrayIndices -> DataType -> Ptr a -> BaseVertex -> IO ()
378380
drawElementsBaseVertex m c = glDrawElementsBaseVertex (marshalPrimitiveMode m) c . marshalDataType
379381

380-
drawRangeElementsBaseVertex :: PrimitiveMode -> (ArrayIndex, ArrayIndex) -> NumArrayIndices -> DataType -> Ptr a -> GLint -> IO () -- TODO: type
382+
drawRangeElementsBaseVertex :: PrimitiveMode -> (ArrayIndex, ArrayIndex) -> NumArrayIndices -> DataType -> Ptr a -> BaseVertex -> IO ()
381383
drawRangeElementsBaseVertex m (s, e) c = glDrawRangeElementsBaseVertex (marshalPrimitiveMode m) (fromIntegral s) (fromIntegral e) c . marshalDataType
382384

383-
drawElementsInstancedBaseVertex :: PrimitiveMode -> NumArrayIndices -> DataType -> Ptr a -> GLsizei -> GLint -> IO () -- TODO: type
385+
drawElementsInstancedBaseVertex :: PrimitiveMode -> NumArrayIndices -> DataType -> Ptr a -> NumInstances -> BaseVertex -> IO ()
384386
drawElementsInstancedBaseVertex m c = glDrawElementsInstancedBaseVertex (marshalPrimitiveMode m) c . marshalDataType
385387

386-
drawElementsInstancedBaseVertexBaseInstance :: PrimitiveMode -> NumArrayIndices -> DataType -> Ptr a -> GLsizei -> GLint -> GLuint -> IO () -- TODO: type
388+
drawElementsInstancedBaseVertexBaseInstance :: PrimitiveMode -> NumArrayIndices -> DataType -> Ptr a -> NumInstances -> BaseVertex -> BaseInstance -> IO ()
387389
drawElementsInstancedBaseVertexBaseInstance m c = glDrawElementsInstancedBaseVertexBaseInstance (marshalPrimitiveMode m) c . marshalDataType
388390

389-
multiDrawElementsBaseVertex :: PrimitiveMode -> Ptr NumArrayIndices -> DataType -> Ptr (Ptr a) -> GLsizei -> Ptr GLint -> IO () -- TODO: type
391+
multiDrawElementsBaseVertex :: PrimitiveMode -> Ptr NumArrayIndices -> DataType -> Ptr (Ptr a) -> NumIndexBlocks -> Ptr BaseVertex -> IO ()
390392
multiDrawElementsBaseVertex m c = glMultiDrawElementsBaseVertex (marshalPrimitiveMode m) c . marshalDataType
391393

392394
maxElementsVertices :: GettableStateVar NumArrayIndices

0 commit comments

Comments
 (0)