go-gl / gl

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

gl.GenBuffers not accepting uint32 array? #99

Closed tehcyx closed 6 years ago

tehcyx commented 6 years ago

Hi,

I'm trying to initialize multiple buffers in one call, passing an array to the GenBuffers function, is this not possible in the port or am I just doing something wrong?

const (
    POSITION_VB int = 0
    TEXCOORD_VB int = 1
    NORMAL_VB   int = 2
    INDEX_VB    int = 3
    NUM_BUFFERS int = 4
)

type Mesh struct {
    vao uint32              // vertex array object
    vbo [NUM_BUFFERS]uint32 // vertex buffer object
}

gl.GenBuffers(int32(NUM_BUFFERS), &m.vbo)

resulting in error:

cannot use &m.vbo (type [4]uint32) as type uint32 in argument to gl.GenBuffers

I've been doing this successfully in C.

dmitshur commented 6 years ago

I think it should be possible. Since the parameter type is *uint32, you'll need to take address of the first element of the array rather than the entire array:

gl.GenBuffers(int32(NUM_BUFFERS), &m.vbo[0])
tehcyx commented 6 years ago

Well, you're right. That got rid of the error. I'll see that it works as well, as soon as I finish up that mesh generation.