문제

For the life of me, I cannot find any good pure Android NDK examples for OpenGL ES 2. The one included native-activity sample project builds an ES 1 context. Are there any sample programs demonstrating the creation of an ES 2 context in pure C++?

도움이 되었습니까?

해결책

Creating an OpenGL ES 2 context should be about the same than creating an OpenGL ES 1. Based on the "native-activity" sample from the NDK, you just need to add this to the attribute list passed to eglChooseConfig:

const EGLint attribs[] =
{
    EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
    ...
    EGL_NONE
};

This should ensure your config is ES2-compatible.

Then pass this attribute list to eglCreateContext:

EGLint AttribList[] = 
{
    EGL_CONTEXT_CLIENT_VERSION, 2,
    EGL_NONE
};

with a call like this:

context = eglCreateContext(display, config, NULL, AttribList);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top