这是一个OpenGL ES 的简单使用例子代码(主要是初始化部分),这些代码不能简单C/V到你的工程中,因为他不是完整的可运行代码。
另外,目前能够用在v1.1一
// ----------------------------------------------------------------------
// Initialization
// ----------------------------------------------------------------------
HDC hdc = GetDC(0); // the screen or window device context, for example
EGLDisplay display = eglGetDisplay(hdc);
EGLint major, minor;
if (!eglInitialize(display, &major, &minor)) {
// could not initialize display
}
EGLConfig configs[10];
EGLint matchingConfigs;
EGLint attribList[] = { 0 }; // extend this
if (!eglChooseConfig(display, attribList, &configs, 10, &matchingConfigs)) {
// could not choose config
}
if (matchingConfigs < 1) {
// did not find a suitable configuration
}
EGLConfig config = configs[0]; // pick any
EGLSurface surface = eglCreatePbufferSurface(display, config, attribList);
// test for error
EGLContext context = eglCreateContext(display, config, 0, attribList);
// test for error
// ----------------------------------------------------------------------
// Rendering Loop
// ----------------------------------------------------------------------
eglMakeCurrent(display, surface, surface, context);
// actual GL rendering goes here
eglWait();
eglSwapBuffers(display, surface);
// ----------------------------------------------------------------------
// Cleanup
// ----------------------------------------------------------------------
if (!eglDestoyContext(display, context)) {
// error deallocating context
}
if (!eglDestroySurface(display, surface)) {
// error deallocating surface
}
if (!eglTerminate(display)) {
// error while cleaning up display
}