我發現這個適用於iOS的tutorial適用於Windows,this適用於Windows。
下面是從後者提取獲得的顯示,並與EGL配置它的一些示例代碼:
// Obtain an EGL display object.
EGLDisplay display = eglGetDisplay(GetDC(hWnd));
if (display == EGL_NO_DISPLAY)
{
return EGL_FALSE;
}
// Initialize the display
if (!eglInitialize(display, &majorVersion, &minorVersion))
{
return EGL_FALSE;
}
// Obtain the display configs
if (!eglGetConfigs(display, NULL, 0, &numConfigs))
{
return EGL_FALSE;
}
// Choose the display config
if (!eglChooseConfig(display, attribList, &config, 1, &numConfigs))
{
return EGL_FALSE;
}
// Create a surface
surface = eglCreateWindowSurface(display, config, (EGLNativeWindowType)hWnd, NULL);
if (surface == EGL_NO_SURFACE)
{
return EGL_FALSE;
}
// Create a drawing context from the EGLDisplay
context = eglCreateContext(display, config, EGL_NO_CONTEXT, contextAttribs);
if (context == EGL_NO_CONTEXT)
{
return EGL_FALSE;
}
// Make the context current
if (!eglMakeCurrent(display, surface, surface, context))
{
return EGL_FALSE;
}
//to show your drawing you swap the buffers like this
eglSwapBuffers(drawContext->eglDisplay, drawContext->eglSurface);
//Terminating a display (release the window resources)
EGLBoolean eglTerminate(eglDisplay);
儘管「無題」,我發現這個問題對解決其他「主題」問題非常有用。 –
相關:http://stackoverflow.com/questions/3127360/what-is-egl-and-how-can-i-use-it –