Jonas Sourlier
Jonas Sourlier

Reputation: 14465

Call Apple-specific OpenGL commands through MonoTouch/OpenTK

If I understand things correctly, Apple's OpenGL ES 2.0 implementation uses some methods from OpenGL ES 3.0, for example

glBindVertexArrayAPPLE

or

glBindVertexArrayOES

instead of

glBindVertexArray

It seems that the OpenTK compilation that gets delivered with MonoTouch does not include either of these methods, although there exist OpenTK bindings for them, see for example line 229 of http://www.opentk.com/files/doc/_g_l_core_8cs_source.html.

Is there any way I can use these features in MonoTouch? Maybe some way to call them through a P/Invoke?

Upvotes: 2

Views: 347

Answers (3)

poupou
poupou

Reputation: 43553

To make things clear, OpenTK-1.0.dll as shipped with MonoTouch since early 2012 (no need to install anything else), supports glBindVertexArrayOES by calling:

GL.Oes.BindVertexArray([u]int);

No additional p/invoke is required in user code. As for glBindVertexArrayAPPLE, which would logically be available as:

GL.Apple.BindVertexArray([u]int);

it is not part of the API since GL_APPLE_vertex_array_object is not defined in the iOS version of glext.h (like it is for OSX version of the same file). Note that GL_OES_vertex_array_object is defined in both iOS and OSX versions of glext.h which is why the Oes API is available.

A quick grep (to find all occurances) did not show the symbols as available in any of the .dylib (so adding it or p/invoking it would fail at runtime).

Upvotes: 3

Rolf Bjarne Kvinge
Rolf Bjarne Kvinge

Reputation: 19345

If you reference OpenTK-1.0 instead of OpenTK you will find this API there.

Upvotes: 1

Jonas Sourlier
Jonas Sourlier

Reputation: 14465

That's it:

[DllImport(Constants.OpenGLESLibrary, EntryPoint="glGenVertexArraysOES")]
public extern static void GenVertexArrays(int n, out int id);

[DllImport(Constants.OpenGLESLibrary, EntryPoint="glBindVertexArrayOES")]
public extern static void BindVertexArray(int id);

There are more functions like these two. @Xamarin, maybe they could be included in the next MonoTouch release?

Upvotes: 1

Related Questions