go-gl / gl

Go bindings for OpenGL (generated via glow)
MIT License
1.07k stars 74 forks source link

Argument size changes #103

Closed jeff-emanuel closed 6 years ago

jeff-emanuel commented 6 years ago

Hi,

I've been using v4.5-core commit 39ef8e959f4050148ec5a59816a93b9e65b4528f for some time. I recently tried to call gl.NamedBufferPageCommitmentARB and it crashed my process. It looks like the third parameter bit size was incorrect. It was declared in package.go as:

// typedef void (APIENTRYP GPNAMEDBUFFERPAGECOMMITMENTARB)(GLuint buffer, GLintptr offset, GLsizei size, GLboolean commit);

and

func NamedBufferPageCommitmentARB(buffer uint32, offset int, size int32, commit bool) {

but the extension spec https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_sparse_buffer.txt reports it as:

    void NamedBufferPageCommitmentARB(uint buffer,
                                      intptr offset,
                                      sizeiptr size,
                                      boolean commit);

At https://www.khronos.org/opengl/wiki/OpenGL_Type, it says that GLsizei is a 32-bit integer and GLsizeiptr is the size of a pointer, 64-bits in my case. Note the mismatch in the third argument.

So I tried updating to the latest version, because I see in the repository that NamedBufferPageCommitmentARB parameter sizes now match the spec, but I get a bunch of new compile errors in my (working) code calling gl.NamedBufferSubData and gl.NamedBufferStorage. It seems that some arguments have changed, incorrectly I believe, from int32 to int.

According to the docs at https://www.khronos.org/registry/OpenGL-Refpages/gl4/

void glNamedBufferSubData( GLuint buffer, GLintptr offset, GLsizei size, const void *data);

Note the third argument is GLsizei, or 32-bits.

But the latest //raw.githubusercontent.com/go-gl/gl/master/v4.5-core/gl/package.go has

// typedef void (APIENTRYP GPNAMEDBUFFERSUBDATA)(GLuint buffer, GLintptr offset, GLsizeiptr size, const void * data); func NamedBufferSubData(buffer uint32, offset int, size int, data unsafe.Pointer) {

And here, the third argument is GLsizeiptr, 64-bits on my system.

Similarly for NamedBufferStorage, the docs say:

void glNamedBufferStorage( GLuint buffer, GLsizei size, const void *data, GLbitfield flags);

and package.go has:

// typedef void (APIENTRYP GPNAMEDBUFFERSTORAGE)(GLuint buffer, GLsizeiptr size, const void * data, GLbitfield flags); func NamedBufferStorage(buffer uint32, size int, data unsafe.Pointer, flags uint32) {

The mismatch is in the second argument here.

Thanks for any assistance you can offer.

jeff-emanuel commented 6 years ago

I see in other OpenGL documents declarations of NamedBufferSubData and NamedBufferStorage matching the arguments in your latest package.go. So that begs the question of how my code runs now, and will this be driver dependent?