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

@ -54,32 +54,32 @@ bool cInterfaceEGL::Create(void *&window_handle)
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
@ -115,21 +115,21 @@ bool cInterfaceEGL::Create(void *&window_handle)
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;
@ -145,32 +145,26 @@ bool cInterfaceEGL::Create(void *&window_handle)
#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;
} }