Skip to content

Commit

Permalink
Fixed signatures of patchVertices, maxPatchVertices and maxTessellati…
Browse files Browse the repository at this point in the history
…onLevel. Renamed maxTessellationLevel to maxTessGenLevel.
  • Loading branch information
svenpanne committed Mar 6, 2015
1 parent e59f1fd commit df5dc42
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
10 changes: 6 additions & 4 deletions src/Graphics/Rendering/OpenGL/GL/PrimitiveMode.hs
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,12 @@ data PrimitiveMode =
-- 'patchVertices' is set to a value less than or equal to zero or greater
-- than the implementation-dependent maximum value 'maxPatchVertices'.

patchVertices :: SettableStateVar GLint
patchVertices = makeSettableStateVar $ glPatchParameteri gl_PATCH_VERTICES
patchVertices :: StateVar GLsizei
patchVertices =
makeStateVar (getSizei1 id GetMaxPatchVertices)
(glPatchParameteri gl_PATCH_VERTICES . fromIntegral)

-- | Contains the maximumum number of vertices in a single patch.

maxPatchVertices :: GettableStateVar GLint
maxPatchVertices = makeGettableStateVar $ getInteger1 id GetMaxPatchVertices
maxPatchVertices :: GettableStateVar GLsizei
maxPatchVertices = makeGettableStateVar $ getSizei1 id GetMaxPatchVertices
8 changes: 5 additions & 3 deletions src/Graphics/Rendering/OpenGL/GL/QueryUtils/PName.hs
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,9 @@ data PName1I
| GetMaxVertexAttribs -- ^ sizei
| GetMaxVaryingFloats -- ^ sizei
-- tessellation
| GetMaxPatchVertices -- ^ int
| GetMaxTessellationLevel -- ^ int
| GetPatchVertices -- ^ sizei
| GetMaxPatchVertices -- ^ sizei
| GetMaxTessGenLevel -- ^ sizei
-- coordtrans
| GetMatrixMode -- ^ enum
| GetModelviewStackDepth -- ^ sizei
Expand Down Expand Up @@ -639,8 +640,9 @@ instance GetPName PName1I where
GetMaxVaryingFloats -> Just gl_MAX_VARYING_COMPONENTS
GetMaxVertexAttribs -> Just gl_MAX_VERTEX_ATTRIBS
-- tessellation
GetPatchVertices -> Just gl_PATCH_VERTICES
GetMaxPatchVertices -> Just gl_MAX_PATCH_VERTICES
GetMaxTessellationLevel -> Just gl_MAX_TESS_GEN_LEVEL
GetMaxTessGenLevel -> Just gl_MAX_TESS_GEN_LEVEL
-- coordtrans
GetMatrixMode -> Just gl_MATRIX_MODE
GetModelviewStackDepth -> Just gl_MODELVIEW_STACK_DEPTH
Expand Down
6 changes: 3 additions & 3 deletions src/Graphics/Rendering/OpenGL/GL/Shaders/Limits.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module Graphics.Rendering.OpenGL.GL.Shaders.Limits (
maxVertexTextureImageUnits, maxTextureImageUnits,
maxCombinedTextureImageUnits, maxTextureCoords, maxVertexUniformComponents,
maxFragmentUniformComponents, maxVertexAttribs, maxVaryingFloats,
maxTessellationLevel
maxTessGenLevel
) where

import Graphics.Rendering.OpenGL.GL.StateVar
Expand Down Expand Up @@ -79,8 +79,8 @@ maxVaryingFloats = getLimit GetMaxVaryingFloats

-- | Contains the maximum allowed tessellation level.

maxTessellationLevel :: GettableStateVar GLint
maxTessellationLevel = makeGettableStateVar $ getInteger1 id GetMaxTessellationLevel
maxTessGenLevel :: GettableStateVar GLsizei
maxTessGenLevel = makeGettableStateVar $ getSizei1 id GetMaxTessGenLevel

getLimit :: PName1I -> GettableStateVar GLsizei
getLimit = makeGettableStateVar . getSizei1 id

3 comments on commit df5dc42

@hesiod
Copy link
Contributor

@hesiod hesiod commented on df5dc42 Mar 8, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not an expert on OpenGL specifications, but aren't all these GLints since the tessellation ARB says GetIntegerv for PATCH_VERTICES and MAX_TESS_GEN_LEVEL/MAX_PATCH_VERTICES? (In the Section "New State"/"New Implementation Dependent State")

@svenpanne
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no way to directly retrieve a GLsizei in the OpenGL API, i.e. no glGetSizeiv, only glGetIntegerv. Nevertheless, the state tables (e.g. in the tessellation extension and in chapter 23 "State Tables" of the OpenGL spec itself) distinguish between "Z" (= integer) and "Z+" (= non-negative integer or enumerated value). Put another way: What you retrieve via glGetSizeiv can be a GLint, a, GLsizei, a GLenum, ... The OpenGL API is quite sloppy about typing in general, you have to read the fine print, which means the state table most of the time.

@hesiod
Copy link
Contributor

@hesiod hesiod commented on df5dc42 Mar 8, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the clarification!

Please sign in to comment.