comparison pytouhou/lib/opengl.pxd @ 584:538b52aafbca

Split GLenum into subtypes, in order to add type safety when calling OpenGL functions.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Wed, 08 Oct 2014 13:21:03 +0200
parents 47cf4e3d159d
children e0166cda75d5
comparison
equal deleted inserted replaced
583:47cf4e3d159d 584:538b52aafbca
16 cdef extern from 'epoxy/gl.h' nogil: 16 cdef extern from 'epoxy/gl.h' nogil:
17 ctypedef unsigned int GLuint 17 ctypedef unsigned int GLuint
18 ctypedef unsigned short GLushort 18 ctypedef unsigned short GLushort
19 ctypedef int GLint 19 ctypedef int GLint
20 ctypedef float GLfloat 20 ctypedef float GLfloat
21 ctypedef float GLclampf
22 ctypedef char GLboolean 21 ctypedef char GLboolean
23 ctypedef char GLchar 22 ctypedef char GLchar
24 ctypedef unsigned int GLsizei 23 ctypedef unsigned int GLsizei
25 ctypedef unsigned int GLsizeiptr 24 ctypedef unsigned int GLsizeiptr
26 ctypedef unsigned int GLbitfield 25 ctypedef unsigned int GLbitfield
27 ctypedef void GLvoid 26 ctypedef void GLvoid
28 27
29 ctypedef enum GLenum: 28 ctypedef enum GLenum_blendfunc 'GLenum':
30 GL_ARRAY_BUFFER 29 GL_SRC_ALPHA
31 GL_ELEMENT_ARRAY_BUFFER 30 GL_ONE_MINUS_SRC_ALPHA
32 GL_STATIC_DRAW 31 GL_ONE
33 GL_DYNAMIC_DRAW 32 GL_ZERO
33
34 ctypedef enum GLenum_type 'GLenum':
34 GL_UNSIGNED_BYTE 35 GL_UNSIGNED_BYTE
35 GL_UNSIGNED_SHORT 36 GL_UNSIGNED_SHORT
36 GL_SHORT 37 GL_SHORT
37 GL_FLOAT 38 GL_FLOAT
38 GL_SRC_ALPHA 39 GL_UNSIGNED_SHORT_5_6_5
39 GL_ONE_MINUS_SRC_ALPHA 40 GL_UNSIGNED_SHORT_4_4_4_4
40 GL_ONE 41 GL_UNSIGNED_SHORT_4_4_4_4_REV
41 GL_ZERO 42
42 GL_TEXTURE_2D 43 ctypedef enum GLenum_format 'GLenum':
43 GL_TRIANGLES
44 GL_DEPTH_TEST
45 GL_QUADS
46
47 GL_TEXTURE_MIN_FILTER
48 GL_TEXTURE_MAG_FILTER
49 GL_LINEAR
50 GL_BGRA 44 GL_BGRA
51 GL_RGBA 45 GL_RGBA
52 GL_RGB 46 GL_RGB
53 GL_LUMINANCE 47 GL_LUMINANCE
54 GL_UNSIGNED_SHORT_5_6_5 48
55 GL_UNSIGNED_SHORT_4_4_4_4 49 ctypedef enum GLenum_bitfield 'GLenum':
56 GL_UNSIGNED_SHORT_4_4_4_4_REV
57
58 GL_COLOR_BUFFER_BIT 50 GL_COLOR_BUFFER_BIT
59 GL_SCISSOR_TEST 51 GL_DEPTH_BUFFER_BIT
52
53 ctypedef GLenum GLenum_textarget
54
55 ctypedef enum GLenum_texparam 'GLenum':
56 GL_TEXTURE_MIN_FILTER
57 GL_TEXTURE_MAG_FILTER
58
59 ctypedef enum GLenum_client_state 'GLenum':
60 GL_COLOR_ARRAY
61 GL_VERTEX_ARRAY
62 GL_TEXTURE_COORD_ARRAY
63
64 ctypedef enum GLenum_matrix 'GLenum':
60 GL_MODELVIEW 65 GL_MODELVIEW
61 GL_FOG
62
63 GL_DEPTH_BUFFER_BIT
64 GL_PROJECTION 66 GL_PROJECTION
67
68 ctypedef enum GLenum_fog 'GLenum':
65 GL_FOG_MODE 69 GL_FOG_MODE
66 GL_FOG_START 70 GL_FOG_START
67 GL_FOG_END 71 GL_FOG_END
68 GL_FOG_COLOR 72 GL_FOG_COLOR
69 73
70 GL_BLEND 74 ctypedef enum GLenum_hint 'GLenum':
75 GL_FOG_HINT
71 GL_PERSPECTIVE_CORRECTION_HINT 76 GL_PERSPECTIVE_CORRECTION_HINT
72 GL_FOG_HINT 77
78 ctypedef enum GLenum_quality 'GLenum':
73 GL_NICEST 79 GL_NICEST
74 GL_COLOR_ARRAY 80
75 GL_VERTEX_ARRAY 81 ctypedef enum GLenum_mode 'GLenum':
76 GL_TEXTURE_COORD_ARRAY 82 GL_TRIANGLES
77 83
84 ctypedef enum GLenum_buffer 'GLenum':
85 GL_ARRAY_BUFFER
86 GL_ELEMENT_ARRAY_BUFFER
87
88 ctypedef enum GLenum_usage 'GLenum':
89 GL_STATIC_DRAW
90 GL_DYNAMIC_DRAW
91
92 ctypedef enum GLenum_shader 'GLenum':
78 GL_VERTEX_SHADER 93 GL_VERTEX_SHADER
79 GL_FRAGMENT_SHADER 94 GL_FRAGMENT_SHADER
95
96 ctypedef enum GLenum_shader_param 'GLenum':
80 GL_INFO_LOG_LENGTH 97 GL_INFO_LOG_LENGTH
81 GL_COMPILE_STATUS 98 GL_COMPILE_STATUS
82 GL_LINK_STATUS 99 GL_LINK_STATUS
83 100
101 ctypedef enum GLenum_framebuffer 'GLenum':
84 GL_FRAMEBUFFER 102 GL_FRAMEBUFFER
103
104 ctypedef enum GLenum_renderbuffer 'GLenum':
105 GL_RENDERBUFFER
106
107 ctypedef enum GLenum_renderbuffer_format 'GLenum':
108 GL_DEPTH_COMPONENT16
109
110 ctypedef enum GLenum_attachment 'GLenum':
85 GL_COLOR_ATTACHMENT0 111 GL_COLOR_ATTACHMENT0
86 GL_RENDERBUFFER
87 GL_DEPTH_COMPONENT16
88 GL_DEPTH_ATTACHMENT 112 GL_DEPTH_ATTACHMENT
113
114 ctypedef enum GLenum_framebuffer_status 'GLenum':
89 GL_FRAMEBUFFER_COMPLETE 115 GL_FRAMEBUFFER_COMPLETE
90 116
91 # Debug 117 ctypedef enum GLenum_debug 'GLenum':
92
93 GL_DEBUG_SOURCE_APPLICATION 118 GL_DEBUG_SOURCE_APPLICATION
94 119
95 void glVertexPointer(GLint size, GLenum type_, GLsizei stride, GLvoid *pointer) 120 ctypedef enum GLenum:
96 void glTexCoordPointer(GLint size, GLenum type_, GLsizei stride, GLvoid *pointer) 121 GL_BLEND
97 void glColorPointer(GLint size, GLenum type_, GLsizei stride, GLvoid *pointer) 122 GL_TEXTURE_2D
98 123 GL_DEPTH_TEST
99 void glBlendFunc(GLenum sfactor, GLenum dfactor) 124 GL_LINEAR
100 void glDrawArrays(GLenum mode, GLint first, GLsizei count) 125 GL_SCISSOR_TEST
101 void glDrawElements(GLenum mode, GLsizei count, GLenum type_, const GLvoid *indices) 126 GL_FOG
127
128 void glVertexPointer(GLint size, GLenum_type type_, GLsizei stride, GLvoid *pointer)
129 void glTexCoordPointer(GLint size, GLenum_type type_, GLsizei stride, GLvoid *pointer)
130 void glColorPointer(GLint size, GLenum_type type_, GLsizei stride, GLvoid *pointer)
131
132 void glBlendFunc(GLenum_blendfunc sfactor, GLenum_blendfunc dfactor)
133 void glDrawElements(GLenum_mode mode, GLsizei count, GLenum_type type_, const GLvoid *indices)
102 void glEnable(GLenum cap) 134 void glEnable(GLenum cap)
103 void glDisable(GLenum cap) 135 void glDisable(GLenum cap)
104 136
105 void glGenTextures(GLsizei n, GLuint *textures) 137 void glGenTextures(GLsizei n, GLuint *textures)
106 void glDeleteTextures(GLsizei n, const GLuint *textures) 138 void glDeleteTextures(GLsizei n, const GLuint *textures)
107 void glBindTexture(GLenum target, GLuint texture) 139 void glBindTexture(GLenum_textarget target, GLuint texture)
108 void glTexParameteri(GLenum target, GLenum pname, GLint param) 140 void glTexParameteri(GLenum_textarget target, GLenum_texparam pname, GLint param)
109 void glTexImage2D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format_, GLenum type_, const GLvoid *data) 141 void glTexImage2D(GLenum_textarget target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum_format format_, GLenum_type type_, const GLvoid *data)
110 142
111 void glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) #XXX 143 void glClearColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
112 void glClear(GLbitfield mask) 144 void glClear(GLbitfield mask)
113 void glViewport(GLint x, GLint y, GLsizei width, GLsizei height) 145 void glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
114 void glScissor(GLint x, GLint y, GLsizei width, GLsizei height) 146 void glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
115 void glMatrixMode(GLenum mode) 147 void glMatrixMode(GLenum_matrix mode)
116 void glLoadIdentity() 148 void glLoadIdentity()
117 void glLoadMatrixf(const GLfloat * m) 149 void glLoadMatrixf(const GLfloat * m)
118 150
119 void glFogi(GLenum pname, GLint param) 151 void glFogi(GLenum_fog pname, GLint param)
120 void glFogf(GLenum pname, GLfloat param) 152 void glFogf(GLenum_fog pname, GLfloat param)
121 void glFogfv(GLenum pname, const GLfloat * params) 153 void glFogfv(GLenum_fog pname, const GLfloat * params)
122 154
123 void glHint(GLenum target, GLenum mode) 155 void glHint(GLenum_hint target, GLenum_quality mode)
124 void glEnableClientState(GLenum cap) 156 void glEnableClientState(GLenum_client_state cap)
125 157
126 # Here start non-1.x declarations. 158 # Here start non-1.x declarations.
127 159
128 void glVertexAttribPointer(GLuint index, GLint size, GLenum type_, GLboolean normalized, GLsizei stride, const GLvoid *pointer) 160 void glVertexAttribPointer(GLuint index, GLint size, GLenum_type type_, GLboolean normalized, GLsizei stride, const GLvoid *pointer)
129 void glEnableVertexAttribArray(GLuint index) 161 void glEnableVertexAttribArray(GLuint index)
130 162
131 void glGenBuffers(GLsizei n, GLuint * buffers) 163 void glGenBuffers(GLsizei n, GLuint * buffers)
132 void glDeleteBuffers(GLsizei n, const GLuint * buffers) 164 void glDeleteBuffers(GLsizei n, const GLuint * buffers)
133 void glBindBuffer(GLenum target, GLuint buffer_) 165 void glBindBuffer(GLenum_buffer target, GLuint buffer_)
134 void glBufferData(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage) 166 void glBufferData(GLenum_buffer target, GLsizeiptr size, const GLvoid *data, GLenum_usage usage)
135 167
136 GLuint glCreateProgram() 168 GLuint glCreateProgram()
137 GLuint glCreateShader(GLenum shaderType) 169 GLuint glCreateShader(GLenum_shader shaderType)
138 void glLinkProgram(GLuint program) 170 void glLinkProgram(GLuint program)
139 void glUseProgram(GLuint program) 171 void glUseProgram(GLuint program)
140 void glGetProgramiv(GLuint program, GLenum pname, GLint *params) 172 void glGetProgramiv(GLuint program, GLenum_shader_param pname, GLint *params)
141 void glGetProgramInfoLog(GLuint program, GLsizei maxLength, GLsizei *length, GLchar *infoLog) 173 void glGetProgramInfoLog(GLuint program, GLsizei maxLength, GLsizei *length, GLchar *infoLog)
142 174
143 void glShaderSource(GLuint shader, GLsizei count, const GLchar **string, const GLint *length) 175 void glShaderSource(GLuint shader, GLsizei count, const GLchar **string, const GLint *length)
144 void glCompileShader(GLuint shader) 176 void glCompileShader(GLuint shader)
145 void glGetShaderiv(GLuint shader, GLenum pname, GLint *params) 177 void glGetShaderiv(GLuint shader, GLenum_shader_param pname, GLint *params)
146 void glGetShaderInfoLog(GLuint shader, GLsizei maxLength, GLsizei *length, GLchar *infoLog) 178 void glGetShaderInfoLog(GLuint shader, GLsizei maxLength, GLsizei *length, GLchar *infoLog)
147 void glAttachShader(GLuint program, GLuint shader) 179 void glAttachShader(GLuint program, GLuint shader)
148 180
149 GLint glGetUniformLocation(GLuint program, const GLchar *name) 181 GLint glGetUniformLocation(GLuint program, const GLchar *name)
150 void glBindAttribLocation(GLuint program, GLuint index, const GLchar *name) 182 void glBindAttribLocation(GLuint program, GLuint index, const GLchar *name)
151 void glUniform1fv(GLint location, GLsizei count, const GLfloat *value) 183 void glUniform1fv(GLint location, GLsizei count, const GLfloat *value)
152 void glUniform4fv(GLint location, GLsizei count, const GLfloat *value) 184 void glUniform4fv(GLint location, GLsizei count, const GLfloat *value)
153 void glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) 185 void glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
154 186
155 void glGenFramebuffers(GLsizei n, GLuint *ids) 187 void glGenFramebuffers(GLsizei n, GLuint *ids)
156 void glBindFramebuffer(GLenum target, GLuint framebuffer) 188 void glBindFramebuffer(GLenum_framebuffer target, GLuint framebuffer)
157 void glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) 189 void glFramebufferTexture2D(GLenum_framebuffer target, GLenum_attachment attachment, GLenum_textarget textarget, GLuint texture, GLint level)
158 void glGenRenderbuffers(GLsizei n, GLuint *renderbuffers) 190 void glGenRenderbuffers(GLsizei n, GLuint *renderbuffers)
159 void glBindRenderbuffer(GLenum target, GLuint renderbuffer) 191 void glBindRenderbuffer(GLenum_renderbuffer target, GLuint renderbuffer)
160 void glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) 192 void glRenderbufferStorage(GLenum_renderbuffer target, GLenum_renderbuffer_format internalformat, GLsizei width, GLsizei height)
161 void glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) 193 void glFramebufferRenderbuffer(GLenum_framebuffer target, GLenum_attachment attachment, GLenum_renderbuffer renderbuffertarget, GLuint renderbuffer)
162 GLenum glCheckFramebufferStatus(GLenum target) 194 GLenum_framebuffer_status glCheckFramebufferStatus(GLenum_framebuffer target)
163 195
164 void glGenVertexArrays(GLsizei n, GLuint *arrays) 196 void glGenVertexArrays(GLsizei n, GLuint *arrays)
165 void glDeleteVertexArrays(GLsizei n, const GLuint *arrays) 197 void glDeleteVertexArrays(GLsizei n, const GLuint *arrays)
166 void glBindVertexArray(GLuint array) 198 void glBindVertexArray(GLuint array)
167 199
168 # Debug 200 # Debug
169 201
170 void glPushDebugGroup(GLenum source, GLuint id_, GLsizei length, const char *message) 202 void glPushDebugGroup(GLenum_debug source, GLuint id_, GLsizei length, const char *message)
171 void glPopDebugGroup() 203 void glPopDebugGroup()
172 204
173 # Non-OpenGL libepoxy functions. 205 # Non-OpenGL libepoxy functions.
174 206
175 int epoxy_gl_version() 207 int epoxy_gl_version()