是顶点数组对象支持Android的OpenGL ES 2.0的使用扩展? [英] Are Vertex Array Objects supported in Android OpenGL ES 2.0 using extensions?

查看:2435
本文介绍了是顶点数组对象支持Android的OpenGL ES 2.0的使用扩展?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要编写使用VAOs在C ++中使用Android NDK编译一些code。我希望能够使用 glDeleteVertexArraysOES glGenVertexArraysOES glBindVertexArrayOES

I'm trying to write some code that uses VAOs in C++ using the Android NDK to compile. I expect to be able to use glDeleteVertexArraysOES, glGenVertexArraysOES, and glBindVertexArrayOES.

我包括我的头中的标头的OpenGL ES 2.0和扩展。

I am including the headers for OpenGL ES 2 and the extensions in my header.

#define GL_GLEXT_PROTOTYPES
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>

我还链接到的OpenGL ES 2 Android.mk

LOCAL_LDLIBS += -lGLESv2

但是,当code被链接某种原因失败。

But for some reason when the code is being linked, it fails.

undefined reference to 'glDeleteVertexArraysOES'
undefined reference to 'glGenVertexArraysOES'
undefined reference to 'glBindVertexArrayOES'

时不包括连接器 GLES2 / gl2ext.h

推荐答案

这是包含与NDK可能只包括标准的OpenGL ES 2.0拨打电话,避免可能会或可能不会被每一个特定的设备支持任何扩展GLES2库/制造商/驱动器...

The GLES2 library that gets included with NDK may only include the standard OpenGL ES 2.0 calls, without any extensions that may or may not be supported by each particular device/manufacturer/driver...

虽然大部分新设备都支持VAO,你可能必须得到指针的函数自己,或者得到一个不同的二进制库(你可以从你的设备中提取,或从一些ROM)。

While most new devices support VAO, you may have to get the pointers to the functions yourself, or get a different binary library (you can extract it from your device, or from some ROM).

我不得不求助于使用此code来从dylib的函数指针:

I had to resort to using this code to get the function pointers from the dylib:

//these ugly typenames are defined in GLES2/gl2ext.h
PFNGLBINDVERTEXARRAYOESPROC bindVertexArrayOES;
PFNGLDELETEVERTEXARRAYSOESPROC deleteVertexArraysOES;
PFNGLGENVERTEXARRAYSOESPROC genVertexArraysOES;
PFNGLISVERTEXARRAYOESPROC isVertexArrayOES;

void initialiseFunctions () {

//[check here that VAOs are actually supported]

void *libhandle = dlopen("libGLESv2.so", RTLD_LAZY);

bindVertexArrayOES = (PFNGLBINDVERTEXARRAYOESPROC) dlsym(libhandle,
                                                         "glBindVertexArrayOES");
deleteVertexArraysOES = (PFNGLDELETEVERTEXARRAYSOESPROC) dlsym(libhandle,
                                                               "glDeleteVertexArraysOES");
genVertexArraysOES = (PFNGLGENVERTEXARRAYSOESPROC)dlsym(libhandle,
                                                        "glGenVertexArraysOES");
isVertexArrayOES = (PFNGLISVERTEXARRAYOESPROC)dlsym(libhandle,
                                                    "glIsVertexArrayOES");

[...]
}

我定义一个静态对象中,这些函数指针。可能有这样做的更好的办法,但这种迄今已为我工作。

I define these function pointers inside a static object. There may be better ways of doing it, but this has worked for me so far.

希望这有助于。

这篇关于是顶点数组对象支持Android的OpenGL ES 2.0的使用扩展?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆