From 96e44e285f7bde926b626a0e5ecc80113d1f5c8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=9A=93?= Date: Sat, 15 Mar 2025 01:29:12 -0400 Subject: [PATCH] Prevent type conflicts between Khronos OpenGL headers and PortableGL headers --- meson.build | 2 +- shader/alphaSprite.pgl.h | 1 - shader/bitmapBlit.pgl.h | 1 - shader/blurH.pgl.h | 1 - shader/blurV.pgl.h | 1 - shader/flashMap.pgl.h | 1 - shader/flatColor.pgl.h | 1 - shader/gray.pgl.h | 1 - shader/hue.pgl.h | 1 - shader/plane.pgl.h | 1 - shader/simple.pgl.h | 1 - shader/simpleAlpha.pgl.h | 1 - shader/simpleColor.pgl.h | 1 - shader/simpleMatrix.pgl.h | 1 - shader/simpleSprite.pgl.h | 1 - shader/sprite.pgl.h | 1 - shader/tilemap.pgl.h | 1 - shader/tilemapvx.pgl.h | 1 - shader/trans.pgl.h | 1 - shader/transSimple.pgl.h | 1 - src/display/gl/pgl-enum.cpp | 1 - subprojects/opengl-registry.wrap | 2 +- .../opengl-registry-portablegl.patch | 67 +++++++ .../packagefiles/opengl-registry-types.patch | 39 ---- .../packagefiles/opengl-registry/meson.build | 2 +- .../packagefiles/portablegl-defines.patch | 174 ++++++++++++++++++ .../packagefiles/portablegl-types.patch | 18 ++ subprojects/portablegl.wrap | 2 +- 28 files changed, 263 insertions(+), 63 deletions(-) create mode 100644 subprojects/packagefiles/opengl-registry-portablegl.patch delete mode 100644 subprojects/packagefiles/opengl-registry-types.patch create mode 100644 subprojects/packagefiles/portablegl-defines.patch create mode 100644 subprojects/packagefiles/portablegl-types.patch diff --git a/meson.build b/meson.build index 34cdaac7..08e2ae4b 100644 --- a/meson.build +++ b/meson.build @@ -517,8 +517,8 @@ if is_libretro cmake.subproject('libsndfile', options: libsndfile_options).dependency('sndfile'), cmake.subproject('pixman-region', options: pixman_region_options).dependency('pixman-region'), subproject('stb').get_variable('stb'), - subproject('opengl-registry').get_variable('opengl_registry'), subproject('portablegl').get_variable('portablegl'), + subproject('opengl-registry').get_variable('opengl_registry'), subproject('freetype', default_options: freetype_options).get_variable('freetype_dep'), declare_dependency( link_with: static_library( diff --git a/shader/alphaSprite.pgl.h b/shader/alphaSprite.pgl.h index e55bf230..81e7eb84 100644 --- a/shader/alphaSprite.pgl.h +++ b/shader/alphaSprite.pgl.h @@ -1,6 +1,5 @@ #include #include -#define MKXPZ_NO_GL_TYPES #ifdef __cplusplus extern "C" { diff --git a/shader/bitmapBlit.pgl.h b/shader/bitmapBlit.pgl.h index cf93908a..9e9f6f34 100644 --- a/shader/bitmapBlit.pgl.h +++ b/shader/bitmapBlit.pgl.h @@ -1,5 +1,4 @@ #include -#define MKXPZ_NO_GL_TYPES #ifdef __cplusplus extern "C" { diff --git a/shader/blurH.pgl.h b/shader/blurH.pgl.h index 8c0aee57..79d98ee0 100644 --- a/shader/blurH.pgl.h +++ b/shader/blurH.pgl.h @@ -1,5 +1,4 @@ #include -#define MKXPZ_NO_GL_TYPES #ifdef __cplusplus extern "C" { diff --git a/shader/blurV.pgl.h b/shader/blurV.pgl.h index 67eb6d90..65bbdee8 100644 --- a/shader/blurV.pgl.h +++ b/shader/blurV.pgl.h @@ -1,5 +1,4 @@ #include -#define MKXPZ_NO_GL_TYPES #ifdef __cplusplus extern "C" { diff --git a/shader/flashMap.pgl.h b/shader/flashMap.pgl.h index fa1ea736..1688ed1b 100644 --- a/shader/flashMap.pgl.h +++ b/shader/flashMap.pgl.h @@ -1,5 +1,4 @@ #include -#define MKXPZ_NO_GL_TYPES #ifdef __cplusplus extern "C" { diff --git a/shader/flatColor.pgl.h b/shader/flatColor.pgl.h index 1e7be722..630983da 100644 --- a/shader/flatColor.pgl.h +++ b/shader/flatColor.pgl.h @@ -1,5 +1,4 @@ #include -#define MKXPZ_NO_GL_TYPES #ifdef __cplusplus extern "C" { diff --git a/shader/gray.pgl.h b/shader/gray.pgl.h index 925918dc..a08c8a29 100644 --- a/shader/gray.pgl.h +++ b/shader/gray.pgl.h @@ -1,5 +1,4 @@ #include -#define MKXPZ_NO_GL_TYPES #ifdef __cplusplus extern "C" { diff --git a/shader/hue.pgl.h b/shader/hue.pgl.h index 398ea7f7..3ae93fd7 100644 --- a/shader/hue.pgl.h +++ b/shader/hue.pgl.h @@ -1,5 +1,4 @@ #include -#define MKXPZ_NO_GL_TYPES #ifdef __cplusplus extern "C" { diff --git a/shader/plane.pgl.h b/shader/plane.pgl.h index d2c2a7ea..b1b4eef8 100644 --- a/shader/plane.pgl.h +++ b/shader/plane.pgl.h @@ -1,5 +1,4 @@ #include -#define MKXPZ_NO_GL_TYPES #ifdef __cplusplus extern "C" { diff --git a/shader/simple.pgl.h b/shader/simple.pgl.h index bfa37d51..bed2986d 100644 --- a/shader/simple.pgl.h +++ b/shader/simple.pgl.h @@ -1,5 +1,4 @@ #include -#define MKXPZ_NO_GL_TYPES #ifdef __cplusplus extern "C" { diff --git a/shader/simpleAlpha.pgl.h b/shader/simpleAlpha.pgl.h index 66a923c3..325863f6 100644 --- a/shader/simpleAlpha.pgl.h +++ b/shader/simpleAlpha.pgl.h @@ -1,5 +1,4 @@ #include -#define MKXPZ_NO_GL_TYPES #ifdef __cplusplus extern "C" { diff --git a/shader/simpleColor.pgl.h b/shader/simpleColor.pgl.h index 031ff0d9..9e2bfb71 100644 --- a/shader/simpleColor.pgl.h +++ b/shader/simpleColor.pgl.h @@ -1,5 +1,4 @@ #include -#define MKXPZ_NO_GL_TYPES #ifdef __cplusplus extern "C" { diff --git a/shader/simpleMatrix.pgl.h b/shader/simpleMatrix.pgl.h index 6a39acef..e5d37c6c 100644 --- a/shader/simpleMatrix.pgl.h +++ b/shader/simpleMatrix.pgl.h @@ -1,5 +1,4 @@ #include -#define MKXPZ_NO_GL_TYPES #ifdef __cplusplus extern "C" { diff --git a/shader/simpleSprite.pgl.h b/shader/simpleSprite.pgl.h index 46a1a8bb..406ad59c 100644 --- a/shader/simpleSprite.pgl.h +++ b/shader/simpleSprite.pgl.h @@ -1,6 +1,5 @@ #include #include -#define MKXPZ_NO_GL_TYPES #ifdef __cplusplus extern "C" { diff --git a/shader/sprite.pgl.h b/shader/sprite.pgl.h index 8008b68e..e55c5a01 100644 --- a/shader/sprite.pgl.h +++ b/shader/sprite.pgl.h @@ -1,6 +1,5 @@ #include #include -#define MKXPZ_NO_GL_TYPES #ifdef __cplusplus extern "C" { diff --git a/shader/tilemap.pgl.h b/shader/tilemap.pgl.h index 4d8ea29a..6a80813d 100644 --- a/shader/tilemap.pgl.h +++ b/shader/tilemap.pgl.h @@ -1,5 +1,4 @@ #include -#define MKXPZ_NO_GL_TYPES #ifdef __cplusplus extern "C" { diff --git a/shader/tilemapvx.pgl.h b/shader/tilemapvx.pgl.h index a2d26e33..d4ac1f72 100644 --- a/shader/tilemapvx.pgl.h +++ b/shader/tilemapvx.pgl.h @@ -1,5 +1,4 @@ #include -#define MKXPZ_NO_GL_TYPES #ifdef __cplusplus extern "C" { diff --git a/shader/trans.pgl.h b/shader/trans.pgl.h index 9e81dc77..8dff62a4 100644 --- a/shader/trans.pgl.h +++ b/shader/trans.pgl.h @@ -1,5 +1,4 @@ #include -#define MKXPZ_NO_GL_TYPES #ifdef __cplusplus extern "C" { diff --git a/shader/transSimple.pgl.h b/shader/transSimple.pgl.h index 2e8a3622..fef0ced8 100644 --- a/shader/transSimple.pgl.h +++ b/shader/transSimple.pgl.h @@ -1,5 +1,4 @@ #include -#define MKXPZ_NO_GL_TYPES #ifdef __cplusplus extern "C" { diff --git a/src/display/gl/pgl-enum.cpp b/src/display/gl/pgl-enum.cpp index 24bba7d0..054f6d0d 100644 --- a/src/display/gl/pgl-enum.cpp +++ b/src/display/gl/pgl-enum.cpp @@ -20,7 +20,6 @@ */ #include -#define MKXPZ_NO_GL_TYPES #include #include diff --git a/subprojects/opengl-registry.wrap b/subprojects/opengl-registry.wrap index 60f40f10..61843f11 100644 --- a/subprojects/opengl-registry.wrap +++ b/subprojects/opengl-registry.wrap @@ -3,4 +3,4 @@ url = https://github.com/KhronosGroup/OpenGL-Registry revision = b53ca669bea4715b6d5fa53c459f47a1fecd7944 depth = 1 patch_directory = opengl-registry -diff_files = opengl-registry-types.patch +diff_files = opengl-registry-portablegl.patch diff --git a/subprojects/packagefiles/opengl-registry-portablegl.patch b/subprojects/packagefiles/opengl-registry-portablegl.patch new file mode 100644 index 00000000..17abebb8 --- /dev/null +++ b/subprojects/packagefiles/opengl-registry-portablegl.patch @@ -0,0 +1,67 @@ +# Makes the Khronos OpenGL headers use the OpenGL types defined by PortableGL to avoid type conflicts when both the Khronos OpenGL headers and the PortableGL headers are being used. + +--- a/api/GLES3/gl3.h ++++ b/api/GLES3/gl3.h +@@ -1,6 +1,6 @@ + #ifndef __gles2_gl3_h_ + #define __gles2_gl3_h_ 1 +- ++#include + #ifdef __cplusplus + extern "C" { + #endif +@@ -40,26 +40,26 @@ extern "C" { + #ifndef GL_ES_VERSION_2_0 + #define GL_ES_VERSION_2_0 1 + #include +-typedef khronos_int8_t GLbyte; +-typedef khronos_float_t GLclampf; +-typedef khronos_int32_t GLfixed; +-typedef khronos_int16_t GLshort; +-typedef khronos_uint16_t GLushort; +-typedef void GLvoid; ++ ++ ++ ++ ++ ++ + typedef struct __GLsync *GLsync; +-typedef khronos_int64_t GLint64; +-typedef khronos_uint64_t GLuint64; +-typedef unsigned int GLenum; +-typedef unsigned int GLuint; +-typedef char GLchar; +-typedef khronos_float_t GLfloat; +-typedef khronos_ssize_t GLsizeiptr; +-typedef khronos_intptr_t GLintptr; +-typedef unsigned int GLbitfield; +-typedef int GLint; +-typedef unsigned char GLboolean; +-typedef int GLsizei; +-typedef khronos_uint8_t GLubyte; ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ + #define GL_DEPTH_BUFFER_BIT 0x00000100 + #define GL_STENCIL_BUFFER_BIT 0x00000400 + #define GL_COLOR_BUFFER_BIT 0x00004000 +@@ -651,7 +651,7 @@ GL_APICALL void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei + + #ifndef GL_ES_VERSION_3_0 + #define GL_ES_VERSION_3_0 1 +-typedef khronos_uint16_t GLhalf; ++ + #define GL_READ_BUFFER 0x0C02 + #define GL_UNPACK_ROW_LENGTH 0x0CF2 + #define GL_UNPACK_SKIP_ROWS 0x0CF3 diff --git a/subprojects/packagefiles/opengl-registry-types.patch b/subprojects/packagefiles/opengl-registry-types.patch deleted file mode 100644 index 3cebdf72..00000000 --- a/subprojects/packagefiles/opengl-registry-types.patch +++ /dev/null @@ -1,39 +0,0 @@ -# Prevents OpenGL types from being defined in gl3.h if MKXPZ_NO_GL_TYPES is defined. - ---- a/api/GLES3/gl3.h -+++ b/api/GLES3/gl3.h -@@ -40,13 +40,16 @@ extern "C" { - #ifndef GL_ES_VERSION_2_0 - #define GL_ES_VERSION_2_0 1 - #include -+#ifndef MKXPZ_NO_GL_TYPES - typedef khronos_int8_t GLbyte; - typedef khronos_float_t GLclampf; - typedef khronos_int32_t GLfixed; - typedef khronos_int16_t GLshort; - typedef khronos_uint16_t GLushort; - typedef void GLvoid; -+#endif // MKXPZ_NO_GL_TYPES - typedef struct __GLsync *GLsync; -+#ifndef MKXPZ_NO_GL_TYPES - typedef khronos_int64_t GLint64; - typedef khronos_uint64_t GLuint64; - typedef unsigned int GLenum; -@@ -60,6 +63,7 @@ typedef int GLint; - typedef unsigned char GLboolean; - typedef int GLsizei; - typedef khronos_uint8_t GLubyte; -+#endif // MKXPZ_NO_GL_TYPES - #define GL_DEPTH_BUFFER_BIT 0x00000100 - #define GL_STENCIL_BUFFER_BIT 0x00000400 - #define GL_COLOR_BUFFER_BIT 0x00004000 -@@ -651,7 +655,9 @@ GL_APICALL void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei - - #ifndef GL_ES_VERSION_3_0 - #define GL_ES_VERSION_3_0 1 -+#ifndef MKXPZ_NO_GL_TYPES - typedef khronos_uint16_t GLhalf; -+#endif // MKXPZ_NO_GL_TYPES - #define GL_READ_BUFFER 0x0C02 - #define GL_UNPACK_ROW_LENGTH 0x0CF2 - #define GL_UNPACK_SKIP_ROWS 0x0CF3 diff --git a/subprojects/packagefiles/opengl-registry/meson.build b/subprojects/packagefiles/opengl-registry/meson.build index 7e82fa99..36d0fb36 100644 --- a/subprojects/packagefiles/opengl-registry/meson.build +++ b/subprojects/packagefiles/opengl-registry/meson.build @@ -1,2 +1,2 @@ project('opengl-registry', 'c', meson_version: '>=1.3.0') -opengl_registry = declare_dependency(include_directories: 'api', dependencies: [subproject('egl-registry').get_variable('egl_registry')]) +opengl_registry = declare_dependency(include_directories: 'api', dependencies: [subproject('egl-registry').get_variable('egl_registry'), subproject('portablegl').get_variable('portablegl')]) diff --git a/subprojects/packagefiles/portablegl-defines.patch b/subprojects/packagefiles/portablegl-defines.patch new file mode 100644 index 00000000..c25bf9dc --- /dev/null +++ b/subprojects/packagefiles/portablegl-defines.patch @@ -0,0 +1,174 @@ +# Renames all the GL_MAX_* macros defined by PortableGL to PGL_MAX_* to avoid conflicts with the Khronos OpenGL headers. + +--- a/portablegl.h ++++ b/portablegl.h +@@ -2450,7 +2450,7 @@ enum + #define GL_FALSE 0 + #define GL_TRUE 1 + +-#define GL_STENCIL_BITS 8 ++#define PGL_STENCIL_BITS 8 + + // Just GL_STENCIL_BITS of 1's, not an official GL enum/value + //#define PGL_STENCIL_MASK ((1 << GL_STENCIL_BITS)-1) +@@ -2460,10 +2460,10 @@ enum + + // Feel free to change these + #define PGL_MAX_VERTICES 500000 +-#define GL_MAX_VERTEX_ATTRIBS 8 +-#define GL_MAX_VERTEX_OUTPUT_COMPONENTS (4*GL_MAX_VERTEX_ATTRIBS) +-#define GL_MAX_DRAW_BUFFERS 4 +-#define GL_MAX_COLOR_ATTACHMENTS 4 ++#define PGL_MAX_VERTEX_ATTRIBS 8 ++#define PGL_MAX_VERTEX_OUTPUT_COMPONENTS (4*PGL_MAX_VERTEX_ATTRIBS) ++#define PGL_MAX_DRAW_BUFFERS 4 ++#define PGL_MAX_COLOR_ATTACHMENTS 4 + + //TODO use prefix like GL_SMOOTH? PGL_SMOOTH? + enum { PGL_SMOOTH, PGL_FLAT, PGL_NOPERSPECTIVE }; +@@ -2522,7 +2522,7 @@ typedef struct glProgram + frag_func fragment_shader; + void* uniform; + GLsizei vs_output_size; +- GLenum interpolation[GL_MAX_VERTEX_OUTPUT_COMPONENTS]; ++ GLenum interpolation[PGL_MAX_VERTEX_OUTPUT_COMPONENTS]; + + GLboolean fragdepth_or_discard; + +@@ -2571,7 +2571,7 @@ void init_glVertex_Attrib(glVertex_Attrib* v); + + typedef struct glVertex_Array + { +- glVertex_Attrib vertex_attribs[GL_MAX_VERTEX_ATTRIBS]; ++ glVertex_Attrib vertex_attribs[PGL_MAX_VERTEX_ATTRIBS]; + + //GLuint n_array_bufs; + GLuint element_buffer; +@@ -2893,10 +2893,10 @@ typedef struct glContext + // TODO make some or all of these locals, measure performance + // impact. Would be necessary in the long term if I ever + // parallelize more +- vec4 vertex_attribs_vs[GL_MAX_VERTEX_ATTRIBS]; ++ vec4 vertex_attribs_vs[PGL_MAX_VERTEX_ATTRIBS]; + Shader_Builtins builtins; + Vertex_Shader_output vs_output; +- float fs_input[GL_MAX_VERTEX_OUTPUT_COMPONENTS]; ++ float fs_input[PGL_MAX_VERTEX_OUTPUT_COMPONENTS]; + + GLboolean depth_test; + GLboolean line_smooth; +@@ -3032,7 +3032,7 @@ typedef struct pgl_prog_info + vert_func vs; + frag_func fs; + int vs_out_sz; +- GLenum interp[GL_MAX_VERTEX_OUTPUT_COMPONENTS]; ++ GLenum interp[PGL_MAX_VERTEX_OUTPUT_COMPONENTS]; + GLboolean uses_fragdepth_or_discard; + } pgl_prog_info; + +@@ -5924,8 +5924,8 @@ static void vertex_stage(const GLvoid* indices, GLsizei count, GLsizei instance_ + //also initialize the vertex_attrib space + // TODO does creating enabled array actually help perf? At what number + // of GL_MAX_VERTEX_ATTRIBS and vertices does it become a benefit? +- int enabled[GL_MAX_VERTEX_ATTRIBS] = { 0 }; +- for (i=0, j=0; iscreen_space); + point.z += poly_offset; // couldn't this put it outside of [-1,1]? +@@ -6203,8 +6203,8 @@ static void draw_line_clip(glVertex* v1, glVertex* v2) + p1 = v1->clip_space; + p2 = v2->clip_space; + +- float v1_out[GL_MAX_VERTEX_OUTPUT_COMPONENTS]; +- float v2_out[GL_MAX_VERTEX_OUTPUT_COMPONENTS]; ++ float v1_out[PGL_MAX_VERTEX_OUTPUT_COMPONENTS]; ++ float v2_out[PGL_MAX_VERTEX_OUTPUT_COMPONENTS]; + + vec3 hp1, hp2; + +@@ -6901,8 +6901,8 @@ static void draw_triangle_clip(glVertex* v0, glVertex* v1, glVertex* v2, unsigne + float tt; + + //quite a bit of stack if there's a lot of clipping ... +- float tmp1_out[GL_MAX_VERTEX_OUTPUT_COMPONENTS]; +- float tmp2_out[GL_MAX_VERTEX_OUTPUT_COMPONENTS]; ++ float tmp1_out[PGL_MAX_VERTEX_OUTPUT_COMPONENTS]; ++ float tmp2_out[PGL_MAX_VERTEX_OUTPUT_COMPONENTS]; + + tmp1.vs_out = tmp1_out; + tmp2.vs_out = tmp2_out; +@@ -7136,14 +7136,14 @@ static void draw_triangle_fill(glVertex* v0, glVertex* v1, glVertex* v2, unsigne + Line l20 = make_Line(hp2.x, hp2.y, hp0.x, hp0.y); + + float alpha, beta, gamma, tmp, tmp2, z; +- float fs_input[GL_MAX_VERTEX_OUTPUT_COMPONENTS]; +- float perspective[GL_MAX_VERTEX_OUTPUT_COMPONENTS*3]; ++ float fs_input[PGL_MAX_VERTEX_OUTPUT_COMPONENTS]; ++ float perspective[PGL_MAX_VERTEX_OUTPUT_COMPONENTS*3]; + float* vs_output = &c->vs_output.output_buf.a[0]; + + for (int i=0; ivs_output.size; ++i) { + perspective[i] = v0->vs_out[i]/p0.w; +- perspective[GL_MAX_VERTEX_OUTPUT_COMPONENTS + i] = v1->vs_out[i]/p1.w; +- perspective[2*GL_MAX_VERTEX_OUTPUT_COMPONENTS + i] = v2->vs_out[i]/p2.w; ++ perspective[PGL_MAX_VERTEX_OUTPUT_COMPONENTS + i] = v1->vs_out[i]/p1.w; ++ perspective[2*PGL_MAX_VERTEX_OUTPUT_COMPONENTS + i] = v2->vs_out[i]/p2.w; + } + float inv_w0 = 1/p0.w; //is this worth it? faster than just dividing by w down below? + float inv_w1 = 1/p1.w; +@@ -7190,7 +7190,7 @@ static void draw_triangle_fill(glVertex* v0, glVertex* v1, glVertex* v2, unsigne + + for (int i=0; ivs_output.size; ++i) { + if (c->vs_output.interpolation[i] == PGL_SMOOTH) { +- tmp = alpha*perspective[i] + beta*perspective[GL_MAX_VERTEX_OUTPUT_COMPONENTS + i] + gamma*perspective[2*GL_MAX_VERTEX_OUTPUT_COMPONENTS + i]; ++ tmp = alpha*perspective[i] + beta*perspective[PGL_MAX_VERTEX_OUTPUT_COMPONENTS + i] + gamma*perspective[2*PGL_MAX_VERTEX_OUTPUT_COMPONENTS + i]; + + fs_input[i] = tmp/tmp2; + +@@ -7705,7 +7705,7 @@ void default_fs(float* fs_input, Shader_Builtins* builtins, void* uniforms) + void init_glVertex_Array(glVertex_Array* v) + { + v->deleted = GL_FALSE; +- for (int i=0; ivertex_attribs[i]); + } + +@@ -8937,7 +8937,7 @@ void glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean norm + // but you can easily remove c->cur_vertex_array from the check + // below to enable client arrays for all VAOs and it will + // still work just fine +- if (index >= GL_MAX_VERTEX_ATTRIBS || size < 1 || size > 4 || ++ if (index >= PGL_MAX_VERTEX_ATTRIBS || size < 1 || size > 4 || + (c->cur_vertex_array && !c->bound_buffers[GL_ARRAY_BUFFER-GL_ARRAY_BUFFER] && pointer)) { + if (!c->error) + c->error = GL_INVALID_OPERATION; +@@ -8990,7 +8990,7 @@ void glDisableVertexAttribArray(GLuint index) + + void glVertexAttribDivisor(GLuint index, GLuint divisor) + { +- if (index >= GL_MAX_VERTEX_ATTRIBS) { ++ if (index >= PGL_MAX_VERTEX_ATTRIBS) { + if (!c->error) + c->error = GL_INVALID_VALUE; + return; +@@ -9694,7 +9694,7 @@ GLuint pglCreateProgram(vert_func vertex_shader, frag_func fragment_shader, GLsi + return 0; + } + +- if (n < 0 || n > GL_MAX_VERTEX_OUTPUT_COMPONENTS) { ++ if (n < 0 || n > PGL_MAX_VERTEX_OUTPUT_COMPONENTS) { + if (!c->error) + c->error = GL_INVALID_VALUE; + return 0; diff --git a/subprojects/packagefiles/portablegl-types.patch b/subprojects/packagefiles/portablegl-types.patch new file mode 100644 index 00000000..c21d8729 --- /dev/null +++ b/subprojects/packagefiles/portablegl-types.patch @@ -0,0 +1,18 @@ +# Changes some of PortableGL's types to more accurately match those of the real OpenGL API. + +--- a/portablegl.h ++++ b/portablegl.h +@@ -2054,11 +2054,11 @@ typedef uint64_t GLuint64; + // the pgl macro wrapper) + typedef int32_t GLsizei; + +-typedef int32_t GLenum; ++typedef uint32_t GLenum; + typedef int32_t GLbitfield; + + typedef intptr_t GLintptr; +-typedef uintptr_t GLsizeiptr; ++typedef ssize_t GLsizeiptr; + typedef void GLvoid; + + typedef float GLfloat; diff --git a/subprojects/portablegl.wrap b/subprojects/portablegl.wrap index 65bb4c20..7166fd03 100644 --- a/subprojects/portablegl.wrap +++ b/subprojects/portablegl.wrap @@ -3,4 +3,4 @@ url = https://github.com/rswinkle/PortableGL revision = 0.98.0 depth = 1 patch_directory = portablegl -diff_files = portablegl-emscripten-symbol-conflict.patch, portablegl-texture.patch +diff_files = portablegl-defines.patch, portablegl-emscripten-symbol-conflict.patch, portablegl-texture.patch, portablegl-types.patch