Skip to content

bad access: nil dereference GenBuffers() #150

Description

@tod91

Hello I'm having issues generating an vertex buffer.

I have a very simple Shader struct as so

type Shader struct {
vbo uint32
}

which I try to use in a generate in a separate function as so:

func NewShader() *Shader {
sh := &Shader{vbo: 0}
gl.GenBuffers(1, &sh.vbo)
gl.BindBuffer(gl.ARRAY_BUFFER, sh.vbo)
gl.BufferData(gl.ARRAY_BUFFER, len(vertices)*4, gl.Ptr(vertices), gl.STATIC_DRAW)
return sh
}

however I get a panic bad access: nil dereference.

I initialize the OpenGL binding in a separate init() function.

Any help would be greatly appreciated.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions