Skip to content

Commit 4cc6666

Browse files
committed
Added patchDefaultOuterLevel and patchDefaultInnerLevel.
1 parent 97b18f5 commit 4cc6666

File tree

3 files changed

+42
-11
lines changed

3 files changed

+42
-11
lines changed

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

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@ module Graphics.Rendering.OpenGL.GL.PrimitiveMode (
1717
-- * Primitive Modes
1818
PrimitiveMode(..),
1919
-- * Patches (Tessellation)
20-
patchVertices, maxPatchVertices
20+
patchVertices, maxPatchVertices,
21+
patchDefaultOuterLevel, patchDefaultInnerLevel, maxTessGenLevel
2122
) where
2223

2324
import Data.StateVar
25+
import Foreign.Marshal.Array
26+
import Graphics.Rendering.OpenGL.GL.PeekPoke
2427
import Graphics.Rendering.OpenGL.GL.QueryUtils.PName
2528
import Graphics.Rendering.OpenGL.Raw
2629

@@ -91,3 +94,30 @@ patchVertices =
9194

9295
maxPatchVertices :: GettableStateVar GLsizei
9396
maxPatchVertices = makeGettableStateVar $ getSizei1 id GetMaxPatchVertices
97+
98+
-- | Contains the four default outer tessellation levels to be used when no
99+
-- tessellation control shader is present.
100+
101+
patchDefaultOuterLevel :: StateVar (GLfloat, GLfloat, GLfloat, GLfloat)
102+
patchDefaultOuterLevel =
103+
makeStateVar
104+
(getFloat4 (,,,) GetPatchDefaultOuterLevel)
105+
(\(l0, l1, l2, l3) -> allocaArray 4 $ \ptr -> do
106+
poke4 ptr l0 l1 l2 l3
107+
glPatchParameterfv gl_PATCH_DEFAULT_OUTER_LEVEL ptr)
108+
109+
-- | Contains the two default inner tessellation levels to be used when no
110+
-- tessellation control shader is present.
111+
112+
patchDefaultInnerLevel :: StateVar (GLfloat, GLfloat)
113+
patchDefaultInnerLevel =
114+
makeStateVar
115+
(getFloat2 (,) GetPatchDefaultInnerLevel)
116+
(\(l0, l1) -> allocaArray 2 $ \ptr -> do
117+
poke2 ptr l0 l1
118+
glPatchParameterfv gl_PATCH_DEFAULT_INNER_LEVEL ptr)
119+
120+
-- | Contains the maximum allowed tessellation level.
121+
122+
maxTessGenLevel :: GettableStateVar GLsizei
123+
maxTessGenLevel = makeGettableStateVar $ getSizei1 id GetMaxTessGenLevel

src/Graphics/Rendering/OpenGL/GL/QueryUtils/PName.hs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,6 +1046,8 @@ data PName2F
10461046
| GetSmoothLineWidthRange -- ^ float
10471047
-- PerFragment
10481048
| GetDepthBounds -- ^ clampd
1049+
-- Tessellation
1050+
| GetPatchDefaultInnerLevel -- ^ float
10491051

10501052
instance GetPName2F PName2F where
10511053

@@ -1063,6 +1065,8 @@ instance GetPName PName2F where
10631065
GetSmoothLineWidthRange -> Just gl_SMOOTH_LINE_WIDTH_RANGE
10641066
-- PerFragment
10651067
GetDepthBounds -> Just gl_DEPTH_BOUNDS_EXT
1068+
-- Tessellation
1069+
GetPatchDefaultInnerLevel -> Just gl_PATCH_DEFAULT_INNER_LEVEL
10661070

10671071
-----------------------------------------------------------------------------
10681072

@@ -1134,7 +1138,10 @@ data PName4F
11341138
| GetCurrentRasterSecondaryColor -- ^ float
11351139
| GetCurrentRasterTextureCoords -- ^ float
11361140
| GetCurrentRasterPosition -- ^ float
1141+
-- PerFragment
11371142
| GetBlendColor -- ^ clampf
1143+
-- Tessellation
1144+
| GetPatchDefaultOuterLevel -- ^ float
11381145

11391146
instance GetPName4F PName4F where
11401147

@@ -1152,15 +1159,15 @@ instance GetPName PName4F where
11521159
-- Framebuffer
11531160
GetColorClearValue -> Just gl_COLOR_CLEAR_VALUE
11541161
GetAccumClearValue -> Just gl_ACCUM_CLEAR_VALUE
1155-
-- Rasterpos
1162+
-- RasterPos
11561163
GetCurrentRasterColor -> Just gl_CURRENT_RASTER_COLOR
11571164
GetCurrentRasterSecondaryColor -> Just gl_CURRENT_RASTER_SECONDARY_COLOR
11581165
GetCurrentRasterTextureCoords -> Just gl_CURRENT_RASTER_TEXTURE_COORDS
11591166
GetCurrentRasterPosition -> Just gl_CURRENT_RASTER_POSITION
11601167
-- PerFragment
11611168
GetBlendColor -> Just gl_BLEND_COLOR
1162-
1163-
1169+
-- Tessellation
1170+
GetPatchDefaultOuterLevel -> Just gl_PATCH_DEFAULT_OUTER_LEVEL
11641171

11651172
-- 0x3000 through 0x3FFF are reserved for clip planes
11661173
clipPlaneIndexToEnum :: GLsizei -> Maybe GLenum

src/Graphics/Rendering/OpenGL/GL/Shaders/Limits.hs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
module Graphics.Rendering.OpenGL.GL.Shaders.Limits (
1616
maxVertexTextureImageUnits, maxTextureImageUnits,
1717
maxCombinedTextureImageUnits, maxTextureCoords, maxVertexUniformComponents,
18-
maxFragmentUniformComponents, maxVertexAttribs, maxVaryingFloats,
19-
maxTessGenLevel
18+
maxFragmentUniformComponents, maxVertexAttribs, maxVaryingFloats
2019
) where
2120

2221
import Data.StateVar
@@ -77,10 +76,5 @@ maxVertexAttribs = getLimit GetMaxVertexAttribs
7776
maxVaryingFloats :: GettableStateVar GLsizei
7877
maxVaryingFloats = getLimit GetMaxVaryingFloats
7978

80-
-- | Contains the maximum allowed tessellation level.
81-
82-
maxTessGenLevel :: GettableStateVar GLsizei
83-
maxTessGenLevel = getLimit GetMaxTessGenLevel
84-
8579
getLimit :: PName1I -> GettableStateVar GLsizei
8680
getLimit = makeGettableStateVar . getSizei1 id

0 commit comments

Comments
 (0)