Skip to content

Commit 73c81ce

Browse files
committed
Use slightly different type synonyms for GL type (introducing on the way).
1 parent 24f6fc6 commit 73c81ce

File tree

5 files changed

+30
-20
lines changed

5 files changed

+30
-20
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@
33
* Make the `OpenGLRaw` package even more similar to the `gl` package:
44
* Use pattern synonyms for OpenGL enums.
55
* Changed module name prefix from `Graphics.Rendering.OpenGL.Raw` to `Graphics.GL`.
6+
* Use slightly different type synonyms for GL type (introducing `Fixed` on the way):
7+
* `CDouble` => `Double` (for `GLclampd`, `GLdouble`)
8+
* `CFloat` => `Float` (for `GLclampf`, `GLfloat`)
9+
* `CInt` => `Fixed` (for `GLclampx`, `GLfixed`)
10+
* `CInt` => `Int32` (for `GLint`, `GLsizei`)
11+
* `CSChar` => `Int8` (for `GLbyte`)
12+
* `CShort` => `Int16` (for `GLshort`)
13+
* `CUChar` => `Word8` (for `GLboolean`, `GLubyte`)
14+
* `CUInt` => `Word32` (for `GLbitfield`, `GLenum`, `GLhandleARB`, `GLuint`)
15+
* `CUShort` => `Word16` (for `GLushort`)
616

717
2.6.1.1
818
-------

OpenGLRaw.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,7 @@ library
605605
base >= 4 && < 5,
606606
bytestring >= 0.9 && < 0.11,
607607
containers >= 0.3 && < 0.6,
608+
fixed >= 0.2 && < 0.3,
608609
half >= 0.2.2.1 && < 0.3,
609610
text >= 0.1 && < 1.3,
610611
transformers >= 0.2 && < 0.6

src/Graphics/GL/Foreign.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ module Graphics.GL.Foreign where
1919
import Foreign.C.Types
2020
import Foreign.Ptr
2121
import Graphics.GL.Types
22+
import Numeric.Fixed
2223
import Numeric.Half
2324

2425
foreign import CALLCONV "dynamic" dyn201

src/Graphics/GL/GetProcAddress.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ import Data.Set ( Set, fromList )
4343
import Data.Text ( pack, unpack )
4444
import Data.Text.Encoding ( encodeUtf8, decodeUtf8 )
4545
import Foreign.C.String ( CString )
46-
import Foreign.C.Types
4746
import Foreign.Marshal.Alloc ( alloca )
4847
import Foreign.Marshal.Error ( throwIf )
4948
import Foreign.Ptr ( Ptr, nullPtr, castPtr, FunPtr, nullFunPtr )

src/Graphics/GL/Types.hs

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -63,37 +63,37 @@ import Data.Int
6363
import Data.Word
6464
import Foreign.C.Types
6565
import Foreign.Ptr
66+
import Numeric.Fixed
6667
import Numeric.Half
6768

6869
--------------------------------------------------------------------------------
6970

7071
-- | 8bit boolean.
71-
type GLboolean = CUChar
72+
type GLboolean = Word8
7273

7374
-- | 8bit signed two\'s complement binary integer.
74-
type GLbyte = CSChar
75+
type GLbyte = Int8
7576

7677
-- | 8bit unsigned binary integer.
77-
type GLubyte = CUChar
78+
type GLubyte = Word8
7879

7980
-- | 8bit characters making up strings.
8081
type GLchar = CChar
8182

8283
-- | 16bit signed two\'s complement binary integer.
83-
type GLshort = CShort
84+
type GLshort = Int16
8485

8586
-- | 16bit unsigned binary integer.
86-
type GLushort = CUShort
87+
type GLushort = Word16
8788

8889
-- | 32bit signed two\'s complement binary integer.
89-
type GLint = CInt
90+
type GLint = Int32
9091

9192
-- | 32bit unsigned binary integer.
92-
type GLuint = CUInt
93+
type GLuint = Word32
9394

9495
-- | 32bit signed two\'s complement 16.16 scaled integer.
95-
type GLfixed = CInt
96-
-- NOTE: OpenGL ES uses khronos_int32_t for this.
96+
type GLfixed = Fixed
9797

9898
-- | 64bit signed two\'s complement binary integer.
9999
type GLint64 = Int64
@@ -102,10 +102,10 @@ type GLint64 = Int64
102102
type GLuint64 = Word64
103103

104104
-- | 32bit non-negative binary integer size.
105-
type GLsizei = CInt
105+
type GLsizei = Int32
106106

107107
-- | 32bit enumerated binary integer value.
108-
type GLenum = CUInt
108+
type GLenum = Word32
109109

110110
-- | Pointer-sized signed two\'s complement binary integer.
111111
type GLintptr = CPtrdiff
@@ -119,22 +119,22 @@ type GLsizeiptr = CPtrdiff
119119
type GLsync = Ptr ()
120120

121121
-- | 32bit bit field.
122-
type GLbitfield = CUInt
122+
type GLbitfield = Word32
123123

124124
-- | 16bit half-precision floating-point value encoded in an unsigned scalar.
125125
type GLhalf = Half
126126

127127
-- | 32bit floating-point value.
128-
type GLfloat = CFloat
128+
type GLfloat = Float
129129

130130
-- | 32bit floating-point value clamped to [0, 1].
131-
type GLclampf = CFloat
131+
type GLclampf = Float
132132

133133
-- | 64bit floating-point value.
134-
type GLdouble = CDouble
134+
type GLdouble = Double
135135

136136
-- | 64bit floating-point value clamped to [0, 1].
137-
type GLclampd = CDouble
137+
type GLclampd = Double
138138

139139
-- | A pointer to a debug callback.
140140
type GLDEBUGPROC = FunPtr GLDEBUGPROCFunc
@@ -203,13 +203,12 @@ type GLDEBUGPROCKHRFunc = GLDEBUGPROCFunc
203203
makeGLDEBUGPROCKHR :: GLDEBUGPROCKHRFunc -> IO (FunPtr GLDEBUGPROCKHRFunc)
204204
makeGLDEBUGPROCKHR = makeGLDEBUGPROC
205205

206-
type GLclampx = CInt
207-
-- NOTE: OpenGL ES uses khronos_int32_t for this.
206+
type GLclampx = Fixed
208207

209208
#if HANDLE_IS_POINTER
210209
type GLhandleARB = Ptr ()
211210
#else
212-
type GLhandleARB = CUInt
211+
type GLhandleARB = Word32
213212
#endif
214213

215214
type GLvdpauSurfaceNV = GLintptr

0 commit comments

Comments
 (0)