/usr/lib/hugs/packages/OpenGL/Graphics/Rendering/OpenGL/GL/Capability.hs is in libhugs-opengl-bundled 98.200609.21-5.3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | -- #hide
--------------------------------------------------------------------------------
-- |
-- Module : Graphics.Rendering.OpenGL.GL.Capability
-- Copyright : (c) Sven Panne 2002-2005
-- License : BSD-style (see the file libraries/OpenGL/LICENSE)
--
-- Maintainer : sven.panne@aedion.de
-- Stability : provisional
-- Portability : portable
--
-- This is a purely internal module for handling OpenGL capabilities, i.e.
-- boolean state variables.
--
--------------------------------------------------------------------------------
module Graphics.Rendering.OpenGL.GL.Capability (
marshalCapability, unmarshalCapability,
EnableCap(..), makeCapability, makeStateVarMaybe
) where
import Graphics.Rendering.OpenGL.GL.BasicTypes (
GLboolean, GLenum, GLsizei, Capability(..) )
import Graphics.Rendering.OpenGL.GL.GLboolean (
marshalGLboolean, unmarshalGLboolean )
import Graphics.Rendering.OpenGL.GL.QueryUtils (
clipPlaneIndexToEnum, lightIndexToEnum )
import Graphics.Rendering.OpenGL.GL.StateVar (
HasGetter(get), HasSetter(($=)), StateVar, makeStateVar )
import Graphics.Rendering.OpenGL.GLU.ErrorsInternal ( recordInvalidEnum )
--------------------------------------------------------------------------------
marshalCapability :: Capability -> GLboolean
marshalCapability = marshalGLboolean . (Enabled ==)
unmarshalCapability :: GLboolean -> Capability
unmarshalCapability x = if unmarshalGLboolean x then Enabled else Disabled
--------------------------------------------------------------------------------
data EnableCap =
CapFog
| CapLighting
| CapTexture1D
| CapTexture2D
| CapLineStipple
| CapPolygonStipple
| CapCullFace
| CapAlphaTest
| CapBlend
| CapIndexLogicOp
| CapColorLogicOp
| CapDither
| CapStencilTest
| CapDepthTest
| CapClipPlane GLsizei
| CapLight GLsizei
| CapTextureGenS
| CapTextureGenT
| CapTextureGenR
| CapTextureGenQ
| CapMap1Vertex3
| CapMap1Vertex4
| CapMap1Color4
| CapMap1Index
| CapMap1Normal
| CapMap1TextureCoord1
| CapMap1TextureCoord2
| CapMap1TextureCoord3
| CapMap1TextureCoord4
| CapMap2Vertex3
| CapMap2Vertex4
| CapMap2Color4
| CapMap2Index
| CapMap2Normal
| CapMap2TextureCoord1
| CapMap2TextureCoord2
| CapMap2TextureCoord3
| CapMap2TextureCoord4
| CapPointSmooth
| CapLineSmooth
| CapPolygonSmooth
| CapScissorTest
| CapColorMaterial
| CapNormalize
| CapAutoNormal
| CapPolygonOffsetPoint
| CapPolygonOffsetLine
| CapPolygonOffsetFill
| CapVertexArray
| CapNormalArray
| CapColorArray
| CapIndexArray
| CapTextureCoordArray
| CapEdgeFlagArray
| CapFogCoordArray
| CapSecondaryColorArray
| CapMatrixIndexArray
| CapConvolution1D
| CapConvolution2D
| CapSeparable2D
| CapHistogram
| CapMinmax
| CapRescaleNormal
| CapSharedTexturePalette
| CapTexture3D
| CapMultisample
| CapSampleAlphaToCoverage
| CapSampleAlphaToOne
| CapSampleCoverage
| CapColorTable
| CapPostConvolutionColorTable
| CapPostColorMatrixColorTable
| CapColorSum
| CapTextureCubeMap
| CapWeightSumUnity
| CapVertexBlend
| CapWeightArray
| CapMatrixPalette
| CapDepthClamp
| CapDepthBoundsTest
| CapPrimitiveRestart -- NOTE: client state!
| CapPointSprite
| CapStencilTestTwoSide
| CapRasterPositionUnclipped
| CapTextureColorTable
marshalEnableCap :: EnableCap -> Maybe GLenum
marshalEnableCap x = case x of
CapFog -> Just 0xb60
CapLighting -> Just 0xb50
CapTexture1D -> Just 0xde0
CapTexture2D -> Just 0xde1
CapLineStipple -> Just 0xb24
CapPolygonStipple -> Just 0xb42
CapCullFace -> Just 0xb44
CapAlphaTest -> Just 0xbc0
CapBlend -> Just 0xbe2
CapIndexLogicOp -> Just 0xbf1
CapColorLogicOp -> Just 0xbf2
CapDither -> Just 0xbd0
CapStencilTest -> Just 0xb90
CapDepthTest -> Just 0xb71
CapClipPlane i -> clipPlaneIndexToEnum i
CapLight i -> lightIndexToEnum i
CapTextureGenS -> Just 0xc60
CapTextureGenT -> Just 0xc61
CapTextureGenR -> Just 0xc62
CapTextureGenQ -> Just 0xc63
CapMap1Vertex3 -> Just 0xd97
CapMap1Vertex4 -> Just 0xd98
CapMap1Color4 -> Just 0xd90
CapMap1Index -> Just 0xd91
CapMap1Normal -> Just 0xd92
CapMap1TextureCoord1 -> Just 0xd93
CapMap1TextureCoord2 -> Just 0xd94
CapMap1TextureCoord3 -> Just 0xd95
CapMap1TextureCoord4 -> Just 0xd96
CapMap2Vertex3 -> Just 0xdb7
CapMap2Vertex4 -> Just 0xdb8
CapMap2Color4 -> Just 0xdb0
CapMap2Index -> Just 0xdb1
CapMap2Normal -> Just 0xdb2
CapMap2TextureCoord1 -> Just 0xdb3
CapMap2TextureCoord2 -> Just 0xdb4
CapMap2TextureCoord3 -> Just 0xdb5
CapMap2TextureCoord4 -> Just 0xdb6
CapPointSmooth -> Just 0xb10
CapLineSmooth -> Just 0xb20
CapPolygonSmooth -> Just 0xb41
CapScissorTest -> Just 0xc11
CapColorMaterial -> Just 0xb57
CapNormalize -> Just 0xba1
CapAutoNormal -> Just 0xd80
CapPolygonOffsetPoint -> Just 0x2a01
CapPolygonOffsetLine -> Just 0x2a02
CapPolygonOffsetFill -> Just 0x8037
CapVertexArray -> Just 0x8074
CapNormalArray -> Just 0x8075
CapColorArray -> Just 0x8076
CapIndexArray -> Just 0x8077
CapTextureCoordArray -> Just 0x8078
CapEdgeFlagArray -> Just 0x8079
CapFogCoordArray -> Just 0x8457
CapSecondaryColorArray -> Just 0x845e
CapMatrixIndexArray -> Just 0x8844
CapConvolution1D -> Just 0x8010
CapConvolution2D -> Just 0x8011
CapSeparable2D -> Just 0x8012
CapHistogram -> Just 0x8024
CapMinmax -> Just 0x802e
CapRescaleNormal -> Just 0x803a
CapSharedTexturePalette -> Just 0x81fb
CapTexture3D -> Just 0x806f
CapMultisample -> Just 0x809d
CapSampleAlphaToCoverage -> Just 0x809e
CapSampleAlphaToOne -> Just 0x809f
CapSampleCoverage -> Just 0x80a0
CapColorTable -> Just 0x80d0
CapPostConvolutionColorTable -> Just 0x80d1
CapPostColorMatrixColorTable -> Just 0x80d2
CapColorSum -> Just 0x8458
CapTextureCubeMap -> Just 0x8513
CapWeightSumUnity -> Just 0x86a6
CapVertexBlend -> Just 0x86a7
CapWeightArray -> Just 0x86ad
CapMatrixPalette -> Just 0x8840
CapDepthClamp -> Just 0x864f
CapDepthBoundsTest -> Just 0x8890
CapPrimitiveRestart -> Just 0x8558
CapPointSprite -> Just 0x8861
CapStencilTestTwoSide -> Just 0x8910
CapRasterPositionUnclipped -> Just 0x19262
CapTextureColorTable -> Just 0x80bc
--------------------------------------------------------------------------------
makeCapability :: EnableCap -> StateVar Capability
makeCapability cap = makeStateVar (isEnabled cap) (enable cap)
--------------------------------------------------------------------------------
isEnabled :: EnableCap -> IO Capability
isEnabled =
maybe (do recordInvalidEnum; return Disabled)
(fmap unmarshalCapability . glIsEnabled) .
marshalEnableCap
foreign import ccall unsafe "glIsEnabled" glIsEnabled ::
GLenum -> IO GLboolean
--------------------------------------------------------------------------------
enable :: EnableCap -> Capability -> IO ()
enable cap state = maybe recordInvalidEnum (f state) (marshalEnableCap cap)
where f Disabled = glDisable
f Enabled = glEnable
foreign import ccall unsafe "glDisable" glDisable :: GLenum -> IO ()
foreign import ccall unsafe "glEnable" glEnable :: GLenum -> IO ()
--------------------------------------------------------------------------------
makeStateVarMaybe :: IO EnableCap -> IO a -> (a -> IO ()) -> StateVar (Maybe a)
makeStateVarMaybe getCap getAct setAct =
makeStateVar
(getStateVarMaybe getCap getAct)
(setStateVarMaybe getCap setAct)
getStateVarMaybe :: IO EnableCap -> IO a -> IO (Maybe a)
getStateVarMaybe getCap act = do
capability <- fmap makeCapability getCap
state <- get capability
if state == Enabled
then fmap Just act
else return Nothing
setStateVarMaybe :: IO EnableCap -> (a -> IO ()) -> Maybe a -> IO ()
setStateVarMaybe getCap act val = do
capability <- fmap makeCapability getCap
maybe (capability $= Disabled) (\x -> act x >> capability $= Enabled) val
|