我尽我所能搜索,但我什么也没找到。
我想做的是:
显示
对于OpenGL在ArchLinux上的ES 2.0支持,我使用MESA。我知道如何使用Xlib创建一个简单的X窗口,我对EGL和OpenGL ES有基本的了解,但我无法理解如何在conjuction中使用它们(X11 + EGL + OpenGL es2.0)。
如果有人至少编写了一个简短的代码示例,说明如何准备一个X窗口并将其与OpenGL ES 2.0正确连接并开始呈现,我将感到非常不快。
发布于 2012-02-08 16:35:47
创建窗口:
Window root;
XSetWindowAttributes swa;
XSetWindowAttributes xattr;
Atom wm_state;
XWMHints hints;
XEvent xev;
EGLConfig ecfg;
EGLint num_config;
Window win;
/*
* X11 native display initialization
*/
x_display = XOpenDisplay(NULL);
if ( x_display == NULL )
{
return EGL_FALSE;
}
root = DefaultRootWindow(x_display);
swa.event_mask = ExposureMask | PointerMotionMask | KeyPressMask;
win = XCreateWindow(
x_display, root,
0, 0, esContext->width, esContext->height, 0,
CopyFromParent, InputOutput,
CopyFromParent, CWEventMask,
&swa );
xattr.override_redirect = FALSE;
XChangeWindowAttributes ( x_display, win, CWOverrideRedirect, &xattr );
hints.input = TRUE;
hints.flags = InputHint;
XSetWMHints(x_display, win, &hints);
// make the window visible on the screen
XMapWindow (x_display, win);
XStoreName (x_display, win, title);
// get identifiers for the provided atom name strings
wm_state = XInternAtom (x_display, "_NET_WM_STATE", FALSE);
memset ( &xev, 0, sizeof(xev) );
xev.type = ClientMessage;
xev.xclient.window = win;
xev.xclient.message_type = wm_state;
xev.xclient.format = 32;
xev.xclient.data.l[0] = 1;
xev.xclient.data.l[1] = FALSE;
XSendEvent (
x_display,
DefaultRootWindow ( x_display ),
FALSE,
SubstructureNotifyMask,
&xev );设定颜色:
glClearColor ( 0.0f, 0.0f, 0.0f, 0.0f );
// Set the viewport
glViewport ( 0, 0, esContext->width, esContext->height );
// Clear the color buffer
glClear ( GL_COLOR_BUFFER_BIT );资料来源:
发布于 2013-07-29 18:44:57
这本书的样本代码实际上对我来说是失败的。如果您看到相同的init失败,那么调用eglBindAPI(EGL_OPENGL_ES_API)似乎可以修复它。
https://stackoverflow.com/questions/9196526
复制相似问题