Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use VertexAttribPointer #93

Closed
neclepsio opened this issue Sep 4, 2014 · 3 comments
Closed

How to use VertexAttribPointer #93

neclepsio opened this issue Sep 4, 2014 · 3 comments

Comments

@neclepsio
Copy link

There are some issues with OpenGL wrapper.

  1. Is this the way to pass a slice to VertexAttribPointer, without the use of buffers?
gl.VertexAttribPointer(ca.Position, 3, GL.FLOAT, false, 0, int(uintptr(unsafe.Pointer(&m.Vertices[0]))))

(I'm not sure int(uintptr(...)) is correct)
2. I think GetProgramInfoLog and GetShaderInfoLog should return string and not []byte.

Thank you
Ignazio

@niemeyer
Copy link
Contributor

niemeyer commented Sep 5, 2014

Please see the documentation of the function:

http://gopkg.in/qml.v1/gl/2.0#GL.VertexAttribPointer

The short version is that providing a buffer to VertexAttrbPointer is deprecated. The modern way to do this is via GenBuffer+BindBuffer+BufferData. The painting-es2 example uses it:

https://github.com/go-qml/qml/blob/v1/examples/painting-es2/painting.go

Regarding point 2, I disagree. Using []byte is idiomatic and prevents a copy.

@niemeyer niemeyer changed the title OpenGL tweaks How to use VertexAttribPointer Sep 5, 2014
@neclepsio
Copy link
Author

It's ok it's deprecated in you api, but if I still want to use it, is
int(uintptr(unsafe.Pointer(&slice[0]))) the way to go? Can int(uintptr)
overflow/underflow, for example?
Il 06/set/2014 00:46 "Gustavo Niemeyer" notifications@github.com ha
scritto:

Please see the documentation of the function:

http://gopkg.in/qml.v1/gl/2.0#GL.VertexAttribPointer

The short version is that providing a buffer to VertexAttrbPointer is
deprecated. The modern way to do this is via
GenBuffer+BindBuffer+BufferData. The painting-es2 example uses it:

https://github.com/go-qml/qml/blob/v1/examples/painting-es2/painting.go

Regarding point 2, I disagree. Using []byte is idiomatic and prevents a
copy.


Reply to this email directly or view it on GitHub
#93 (comment).

@niemeyer
Copy link
Contributor

niemeyer commented Sep 6, 2014

I meant that my understanding is that the use of the pointer attribute to provide an array is obsoleted in OpenGL in general.

That said, I'd like to support your use of it, if you really want to, and there's no good way to do that while the parameter is an int, because it may not necessarily be sized after the machine word size (although it generally is, right now).

To fix that problem, I'll convert the offset type into a "uintptr", so that the proper way to do what you want would be:

uintptr(unsafe.Pointer(&slice[0]))

That said, I'd still encourage you to provide the array as buffer data instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants