一个OpenGL ES 的简单使用例子代码
2011-02-17 10:42
489 查看
这是一个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
}
另外,目前能够用在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
}
相关文章推荐
- 一个使用PJSUA-API编写的简单例子,演示了SIP注册,呼叫,语音交互(少于200行代码)【译】
- Spring MVC:使用SimpleUrlHandlerMapping的一个简单例子
- 一个简单的存储过程使用事务的例子
- 使用jquery flip插件的一个简单例子
- 使用debugfs导出调试信息--一个简单的例子
- 一个简单的framebuffer的显示使用例子
- 使用axis测试一个简单的webservice的应用例子
- web.config文件自定义配置节的使用方法的一个简单例子
- 【iOS开展-50】使用它来创建一个新的类的实现代码包,因此,不自觉地练习简单MVC实验,附带动画
- 使用maven创建一个简单的MyBatis例子
- 一个简单的epoll使用例子
- C# 一个简单分词程序的思路和代码(五) 使用代码
- 一个简单的打印HttpServletRequest头jsp代码例子
- 词法分析程序 LEX和VC6整合使用的一个简单例子
- 使用Multiplayer Networking做一个简单的多人游戏例子-1/3(Unity3D开发之二十五)
- 如何使用Oracle存储过程的一个简单例子
- 一个简单例子了解使用互斥量线程同步
- 使用servlet开发动态wap的一个简单例子
- 一个简单的HTTP通讯的例子,使用了CInternetSession,CHttpConnection,CHttpFile三个类
- c# 学习笔记之九 事件(event)的使用,一个简单例子揭示机理