我找到了这篇iOS的
教程,还有Windows的
教程。
以下是从后者中提取的一些示例代码,用于获取显示并使用EGL进行配置:
EGLDisplay display = eglGetDisplay(GetDC(hWnd));
if (display == EGL_NO_DISPLAY)
{
return EGL_FALSE;
}
if (!eglInitialize(display, &majorVersion, &minorVersion))
{
return EGL_FALSE;
}
if (!eglGetConfigs(display, NULL, 0, &numConfigs))
{
return EGL_FALSE;
}
if (!eglChooseConfig(display, attribList, &config, 1, &numConfigs))
{
return EGL_FALSE;
}
surface = eglCreateWindowSurface(display, config, (EGLNativeWindowType)hWnd, NULL);
if (surface == EGL_NO_SURFACE)
{
return EGL_FALSE;
}
context = eglCreateContext(display, config, EGL_NO_CONTEXT, contextAttribs);
if (context == EGL_NO_CONTEXT)
{
return EGL_FALSE;
}
if (!eglMakeCurrent(display, surface, surface, context))
{
return EGL_FALSE;
}
eglSwapBuffers(drawContext->eglDisplay, drawContext->eglSurface);
EGLBoolean eglTerminate(eglDisplay);