go-gl-legacy / gl

Go bindings for OpenGL
BSD 3-Clause "New" or "Revised" License
342 stars 52 forks source link

glGetShaderSource is passed wrong type? (go 1.1 beta2 / tip) #104

Closed RStainforth closed 11 years ago

RStainforth commented 11 years ago

When I run the following, it doesn't compile, unless I apply the patch below:

$ go build
# github.com/go-gl/gl
shader.go:38: cannot use _Ctype_GLuint(shader) (type C.GLuint) as type C.GLint in function argument
diff --git a/shader.go b/shader.go
index 8052beb..d1659d2 100644
--- a/shader.go
+++ b/shader.go
@@ -36,7 +36,7 @@ func (shader Shader) GetSource() string {
    if length > 1 {
        log := C.malloc(C.size_t(length + 1))
        defer C.free(log)
-       C.glGetShaderSource(C.GLuint(shader), C.GLsizei(length), nil, (*C.GLchar)(log))
+       C.glGetShaderSource(C.GLint(shader), C.GLsizei(length), nil, (*C.GLchar)(log))
        return C.GoString((*C.char)(log))
    }
    return ""
vova616 commented 11 years ago

http://www.opengl.org/sdk/docs/man/xhtml/glGetShaderSource.xml

void glGetShaderSource( GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * source);

it also works ok for me (go 1.1 beta2), what's your os?

RStainforth commented 11 years ago

I am running Scientific Linux 6. With the following:

glew-1.5.5-1.el6.x86_64 glew-devel-1.5.5-1.el6.x86_64

freeglut-2.6.0-1.el6.x86_64 freeglut-devel-2.6.0-1.el6.x86_64

pwaller commented 11 years ago

Pinging the thread since @RStainforth edited his response - Just so you know, if you edit the post it doesn't notify people watching the thread.

RStainforth commented 11 years ago

Just to add which mesa version I have also:

mesa-libGL-devel-9.0-0.7.el6.x86_64 mesa-libGL-devel-9.0-0.7.el6.i686

vova616 commented 11 years ago

Sorry for the late response, glGetShaderSource is defined in glew.h and your glew version is pretty old, try using 1.9.0

in glew 1.5.5 ypedef void (GLAPIENTRY * PFNGLGETSHADERSOURCEPROC) (GLint obj, GLsizei maxLength, GLsizei* length, GLchar* source);

and glew 1.9.0 typedef void (GLAPIENTRY * PFNGLGETSHADERSOURCEPROC) (GLuint obj, GLsizei maxLength, GLsizei* length, GLchar* source);

its possible to write a proxy c function and let the c compiler handle the conversion to gluint/glint but I think because the readme specifies that the version of glew should be at least 1.5.8, this is working as intended.

pwaller commented 11 years ago

Hmm. That's unfortunate because this seems to be the most recent version of glew shipped with @RStainforth's operating system, and if you change this one thing, it builds. I'm somewhat tempted to put such a wrapper in.

@banthar, were there other reasons that 1.5.5<=v<1.5.8 are not supported?

banthar commented 11 years ago

In GLEW < 1.5.4 some definitions we use are missing. E.g.: glIsTransformFeedback. I don't know of any other issues.

lclarkmichalek commented 11 years ago

This is affecting me, Arch Linux 32 bit. Glew 1.9.0, mesa 9.1.3.

> grep "PFNGLGETSHADERSOURCEPROC" /usr/include/GL/glew.h
typedef void (GLAPIENTRY * PFNGLGETSHADERSOURCEPROC) (GLint obj, GLsizei maxLength, GLsizei* length, GLchar* source);
> pacman -Qo /usr/include/GL/glew.h
/usr/include/GL/glew.h is owned by glew 1.9.0-2

This is running on an ancient laptop, so that might be related. On another machine (same configuration except 64bit and with more modern graphics) I have no problems.

pwaller commented 11 years ago

@bluepeppers, can you confirm that #106 fixes your problem? If so, I'll merge it.

lclarkmichalek commented 11 years ago

I don't have any code to hand that uses the function, so I can't test that, but it fixes the build for me.

pwaller commented 11 years ago

Thanks, that was what I wanted to know. I've merged #106.

lclarkmichalek commented 11 years ago

Hmm, it seems I may have been building the wrong branch (Could have sworn I checked-out your issue-104 branch), and there seem to be a couple of bugs in the patch. Applying this diff changes resolves all issues for me. Sorry for the inconvenience.

pwaller commented 11 years ago

@bluepeppers Thanks for reporting it quickly. Can you please submit a pull request?

pwaller commented 11 years ago

Thanks @bluepeppers!