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

APIs which take a ptr (ptr void) generated only as (ptr void) #4

Open
edwintorok opened this issue Jan 6, 2014 · 3 comments
Open

Comments

@edwintorok
Copy link
Contributor

For example the params here is an output, but in the OCaml API it seems to be only an input:
void glGetBufferPointerv(GLenum target, GLenum pname, GLvoid ** params);
val get_buffer_pointerv : enum ->
enum -> (nativeint, Bigarray.nativeint_elt) bigarray -> unit

@dbuenzli
Copy link
Owner

dbuenzli commented Jan 6, 2014

Yes, the reasons are that:

  1. I was too lazy to bind it manually
  2. If you want performance you don't specify pointers directly but use buffer objects, so what you get it here is the integer offset, mostly like 0 that you specified in glVertexAttribPointer (hence the bigarray of nativeint)
  3. If you want performance you avoid to glGet* as much as possible anyway
  4. If you really want the pointer you can still convert that integer to a pointer using ocaml-ctypes.

A warning was supposed to be written in the docs for the 5 cases where this happens, but I forgot it for glGet BufferPointerv, glGetPoinzerv, glGetVertexAttribPointerv. It's there for glMultiDrawElements and glMultiDrawElementsBaseVertex.

@dbuenzli
Copy link
Owner

dbuenzli commented Jan 6, 2014

Mmmh in fact it seems I'm wrong on 2) what you get here is a pointer on the mapped buffer, if it's mapped.

Ok so I may need to change it and return a bigarray instead, this means we need to add size parameter (i.e. the client has to know the size, see e.g. map_buffer vs. glMapBuffer). I'll also check for the other Get_Pointer. For the glMultidrawElements_ functions you may want to have a look at the warning in the docs.

That said I'm not sure I see the rationale for that function (or I'm missing something) as it allows other parts of the system to access a mapped buffer without the part that is mapping/unmapping actually knowing it. That seems a recipe for crashes, since the pointer becomes invalid once unmapped.

@edwintorok
Copy link
Contributor Author

Look like glGetBufferPointerv should return the same pointer that glMapBuffer returned to you initially. I don't really see a use-case for it either (unless you forgot to save the pointer returned by glMapBuffer), so maybe just comment it out for now in the generated file.

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