Replace GLsizeiptr in PortableGL headers with uintptr_t

Required to account for the fact that we changed the typedef for
`GLsizeiptr` from `uintptr_t` to `ssize_t`, and PortableGL, for some
reason, incorrectly relies on `GLsizeiptr` being an unsigned
pointer-sized integer in some places.
This commit is contained in:
刘皓 2025-03-15 11:50:50 -04:00
parent 96e44e285f
commit 0e786c4e48
No known key found for this signature in database
GPG key ID: 7901753DB465B711

View file

@ -16,3 +16,39 @@
typedef void GLvoid;
typedef float GLfloat;
@@ -2558,7 +2558,7 @@ typedef struct glVertex_Attrib
GLint size; // number of components 1-4
GLenum type; // GL_FLOAT, default
GLsizei stride; //
- GLsizeiptr offset; //
+ uintptr_t offset; //
GLboolean normalized;
GLuint buf;
GLboolean enabled;
@@ -5835,7 +5835,7 @@ static vec4 get_v_attrib(glVertex_Attrib* v, GLsizei i)
// is always NULL so this works for both but we have to cast
// the pointer to GLsizeiptr because adding an offset to a NULL pointer
// is undefined. So, do the math as numbers and convert back to a pointer
- GLsizeiptr buf_data = (GLsizeiptr)c->buffers.a[v->buf].data;
+ uintptr_t buf_data = (uintptr_t)c->buffers.a[v->buf].data;
u8* u8p = (u8*)(buf_data + v->offset + v->stride*i);
i8* i8p = (i8*)u8p;
@@ -5944,7 +5944,7 @@ static void vertex_stage(const GLvoid* indices, GLsizei count, GLsizei instance_
// https://www.khronos.org/opengl/wiki/Built-in_Variable_(GLSL)#Vertex_shader_inputs
c->builtins.gl_InstanceID = instance_id;
c->builtins.gl_BaseInstance = base_instance;
- GLsizeiptr first = (GLsizeiptr)indices;
+ uintptr_t first = (uintptr_t)indices;
if (!use_elems_type) {
for (vert=0, i=first; i<first+count; ++i, ++vert) {
@@ -8973,7 +8973,7 @@ void glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean norm
// offset can still really a pointer if using the 0 VAO
// and no bound ARRAY_BUFFER. !v->buf and !(buf data) see vertex_stage()
- v->offset = (GLsizeiptr)pointer;
+ v->offset = (uintptr_t)pointer;
// I put ARRAY_BUFFER-itself instead of 0 to reinforce that bound_buffers is indexed that way, buffer type - GL_ARRAY_BUFFER
v->buf = c->bound_buffers[GL_ARRAY_BUFFER-GL_ARRAY_BUFFER];
}