go-gl / gl

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

Runtime Panic using v2.1/gl #96

Closed Noofbiz closed 6 years ago

Noofbiz commented 6 years ago

Original issue here https://github.com/EngoEngine/engo/issues/520

Related to: https://github.com/go-gl/gl/commit/f8cee0ff968a2dd4ef2786e7a4c843a451cd40a7

If we use https://github.com/go-gl/gl/commit/eafa86a81d9705ff0b4ab163d26fe74da80e0559 everything works perfectly. It looks like it comes from the change to GlowGetProcAddress_gl21; before it returned a value and now it's not, so when ClearColor is called it gets to here in package.go:

func ClearColor(red float32, green float32, blue float32, alpha float32) {
    C.glowClearColor(gpClearColor, (C.GLfloat)(red), (C.GLfloat)(green), (C.GLfloat)(blue), (C.GLfloat)(alpha))
}

When it tries to get gpClearColor = (C.GPCLEARCOLOR)(getProcAddr("glClearColor")) it segfaults.

dmitshur commented 6 years ago

Thank you for reporting this. This is clearly a bug and shouldn't happen. We need to investigate what is different about ClearColor in new XML data.

dmitshur commented 6 years ago

@Noofbiz Since you're able to reproduce this (I can't yet), is it possible for you to make a smaller repro sample?

github.com/go-gl/example/gl21-cube works okay for me despite using ClearColor. Does it work for you too?

dmitshur commented 6 years ago

When I compare v2.1/gl/package.go before and after that commit, there is no change related to ClearColor. I suspect the issue is not tied to that particular function, but rather it just happened to be the first one called.

dmitshur commented 6 years ago

I tried the hud demo from https://github.com/EngoEngine/engo/issues/520. I got the same crash. I tried it again with go-gl/gl@eafa86a81d9705ff0b4ab163d26fe74da80e0559, and got the same crash. It doesn't seem to be an issue with go-gl/gl.

Noofbiz commented 6 years ago

Thank you for checking that out so throughly and quickly. Sorry for any inconveniences

dmitshur commented 6 years ago

No problem, thanks anyway!