Cleans up EGL. Removes printf output with INFO_LOG and ERROR_LOG

This commit is contained in:
Ryan Houdek 2013-01-24 10:39:38 -06:00
parent 73eb98ed8e
commit 52ead25534
1 changed files with 60 additions and 66 deletions

View File

@ -49,37 +49,37 @@ bool cInterfaceEGL::Create(void *&window_handle)
s_backbuffer_height = _theight; s_backbuffer_height = _theight;
const char *s; const char *s;
EGLint egl_major, egl_minor; EGLint egl_major, egl_minor;
GLWin.dpy = XOpenDisplay(NULL); GLWin.dpy = XOpenDisplay(NULL);
if (!GLWin.dpy) { if (!GLWin.dpy) {
printf("Error: couldn't open display\n"); ERROR_LOG(VIDEO, "Error: couldn't open display\n");
return false; return false;
} }
GLWin.egl_dpy = eglGetDisplay(GLWin.dpy); GLWin.egl_dpy = eglGetDisplay(GLWin.dpy);
if (!GLWin.egl_dpy) { if (!GLWin.egl_dpy) {
printf("Error: eglGetDisplay() failed\n"); ERROR_LOG(VIDEO, "Error: eglGetDisplay() failed\n");
return false; return false;
} }
if (!eglInitialize(GLWin.egl_dpy, &egl_major, &egl_minor)) { if (!eglInitialize(GLWin.egl_dpy, &egl_major, &egl_minor)) {
printf("Error: eglInitialize() failed\n"); ERROR_LOG(VIDEO, "Error: eglInitialize() failed\n");
return false; return false;
} }
s = eglQueryString(GLWin.egl_dpy, EGL_VERSION); s = eglQueryString(GLWin.egl_dpy, EGL_VERSION);
printf("EGL_VERSION = %s\n", s); INFO_LOG(VIDEO, "EGL_VERSION = %s\n", s);
s = eglQueryString(GLWin.egl_dpy, EGL_VENDOR); s = eglQueryString(GLWin.egl_dpy, EGL_VENDOR);
printf("EGL_VENDOR = %s\n", s); INFO_LOG(VIDEO, "EGL_VENDOR = %s\n", s);
s = eglQueryString(GLWin.egl_dpy, EGL_EXTENSIONS); s = eglQueryString(GLWin.egl_dpy, EGL_EXTENSIONS);
printf("EGL_EXTENSIONS = %s\n", s); INFO_LOG(VIDEO, "EGL_EXTENSIONS = %s\n", s);
s = eglQueryString(GLWin.egl_dpy, EGL_CLIENT_APIS); s = eglQueryString(GLWin.egl_dpy, EGL_CLIENT_APIS);
printf("EGL_CLIENT_APIS = %s\n", s); INFO_LOG(VIDEO, "EGL_CLIENT_APIS = %s\n", s);
// attributes for a visual in RGBA format with at least // attributes for a visual in RGBA format with at least
// 8 bits per color and a 24 bit depth buffer // 8 bits per color and a 24 bit depth buffer
@ -108,29 +108,29 @@ bool cInterfaceEGL::Create(void *&window_handle)
if (GLWin.parent == 0) if (GLWin.parent == 0)
GLWin.parent = RootWindow(GLWin.dpy, GLWin.screen); GLWin.parent = RootWindow(GLWin.dpy, GLWin.screen);
XVisualInfo visTemplate; XVisualInfo visTemplate;
int num_visuals; int num_visuals;
EGLConfig config; EGLConfig config;
EGLint num_configs; EGLint num_configs;
EGLint vid; EGLint vid;
if (!eglChooseConfig( GLWin.egl_dpy, attribs, &config, 1, &num_configs)) { if (!eglChooseConfig( GLWin.egl_dpy, attribs, &config, 1, &num_configs)) {
printf("Error: couldn't get an EGL visual config\n"); ERROR_LOG(VIDEO, "Error: couldn't get an EGL visual config\n");
exit(1); return false;
} }
if (!eglGetConfigAttrib(GLWin.egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) { if (!eglGetConfigAttrib(GLWin.egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) {
printf("Error: eglGetConfigAttrib() failed\n"); ERROG_LOG(VIDEO, "Error: eglGetConfigAttrib() failed\n");
exit(1); return false;
} }
/* The X window visual must match the EGL config */ /* The X window visual must match the EGL config */
visTemplate.visualid = vid; visTemplate.visualid = vid;
GLWin.vi = XGetVisualInfo(GLWin.dpy, VisualIDMask, &visTemplate, &num_visuals); GLWin.vi = XGetVisualInfo(GLWin.dpy, VisualIDMask, &visTemplate, &num_visuals);
if (!GLWin.vi) { if (!GLWin.vi) {
printf("Error: couldn't get X visual\n"); ERROR_LOG(VIDEO, "Error: couldn't get X visual\n");
exit(1); return false;
} }
GLWin.x = _tx; GLWin.x = _tx;
GLWin.y = _ty; GLWin.y = _ty;
@ -144,33 +144,27 @@ bool cInterfaceEGL::Create(void *&window_handle)
eglBindAPI(EGL_OPENGL_API); eglBindAPI(EGL_OPENGL_API);
#endif #endif
GLWin.egl_ctx = eglCreateContext(GLWin.egl_dpy, config, EGL_NO_CONTEXT, ctx_attribs ); GLWin.egl_ctx = eglCreateContext(GLWin.egl_dpy, config, EGL_NO_CONTEXT, ctx_attribs );
if (!GLWin.egl_ctx) { if (!GLWin.egl_ctx) {
printf("Error: eglCreateContext failed\n"); ERROR_LOG(VIDEO, "Error: eglCreateContext failed\n");
exit(1); return false;
} }
GLWin.egl_surf = eglCreateWindowSurface(GLWin.egl_dpy, config, GLWin.win, NULL); GLWin.egl_surf = eglCreateWindowSurface(GLWin.egl_dpy, config, GLWin.win, NULL);
if (!GLWin.egl_surf) { if (!GLWin.egl_surf) {
printf("Error: eglCreateWindowSurface failed\n"); ERROR_LOG(VIDEO, "Error: eglCreateWindowSurface failed\n");
exit(1); return false;
} }
if (!eglMakeCurrent(GLWin.egl_dpy, GLWin.egl_surf, GLWin.egl_surf, GLWin.egl_ctx)) { if (!eglMakeCurrent(GLWin.egl_dpy, GLWin.egl_surf, GLWin.egl_surf, GLWin.egl_ctx)) {
ERROR_LOG(VIDEO, "Error: eglMakeCurrent() failed\n");
printf("Error: eglMakeCurrent() failed\n"); return false;
return false; }
}
printf("GL_VENDOR: %s\n", glGetString(GL_VENDOR)); INFO_LOG(VIDEO, "GL_VENDOR: %s\n", glGetString(GL_VENDOR));
printf("GL_RENDERER: %s\n", glGetString(GL_RENDERER)); INFO_LOG(VIDEO, "GL_RENDERER: %s\n", glGetString(GL_RENDERER));
printf("GL_VERSION: %s\n", glGetString(GL_VERSION)); INFO_LOG(VIDEO, "GL_VERSION: %s\n", glGetString(GL_VERSION));
printf("GL_EXTENSIONS: %s\n", glGetString(GL_EXTENSIONS)); INFO_LOG(VIDEO, "GL_EXTENSIONS: %s\n", glGetString(GL_EXTENSIONS));
/* Set initial projection/viewing transformation.
* We can't be sure we'll get a ConfigureNotify event when the window
* first appears.
*/
glViewport(0, 0, (GLint) _twidth, (GLint) _theight);
window_handle = (void *)GLWin.win; window_handle = (void *)GLWin.win;
return true; return true;
} }