int glutCreateWindow (const char *title) { EGLConfig config; EGLint num_configs; atexit(cleanup); /* pass NativeDisplay=0, we only have one screen... */ EGLCHK(dpy = eglGetDisplay(0)); EGLCHK(eglInitialize(dpy, NULL, NULL)); psp_log("EGL vendor \"%s\"\n", eglQueryString(dpy, EGL_VENDOR)); psp_log("EGL version \"%s\"\n", eglQueryString(dpy, EGL_VERSION)); psp_log("EGL extensions \"%s\"\n", eglQueryString(dpy, EGL_EXTENSIONS)); if (glut_display_mode & GLUT_ALPHA) attrib_list[7] = 8; if (glut_display_mode & GLUT_STENCIL) attrib_list[9] = 8; if (glut_display_mode & GLUT_DEPTH) attrib_list[11] = 16; EGLCHK(eglChooseConfig(dpy, attrib_list, &config, 1, &num_configs)); if (num_configs == 0) { __pspgl_log("glutCreateWindow: eglChooseConfig returned no configurations for display mode %x\n", glut_display_mode); return 0; } psp_log("eglChooseConfig() returned config 0x%04x\n", (unsigned int) config); EGLCHK(eglGetConfigAttrib(dpy, config, EGL_WIDTH, &width)); EGLCHK(eglGetConfigAttrib(dpy, config, EGL_HEIGHT, &height)); EGLCHK(ctx = eglCreateContext(dpy, config, NULL, NULL)); EGLCHK(surface = eglCreateWindowSurface(dpy, config, 0, NULL)); EGLCHK(eglMakeCurrent(dpy, surface, surface, ctx)); return 0; }
void __pspgl_assert_fail(const char *expr, const void *retaddr, const char *func, const char *file, int line) { __pspgl_log("ASSERTION FAILURE: %s:%d (%s, called from %p): %s\n", file, line, func, retaddr, expr); }
void* __pspgl_realloc (void *ptr, size_t size, const char *function, unsigned int line) { void *new_ptr = realloc(ptr, size); __pspgl_log("%s(ptr %p, size %d, called from %s: %u): %p\n", __FUNCTION__, ptr, size, function, line, new_ptr); return new_ptr; }
void __pspgl_free (void *ptr, const char *function, unsigned int line) { __pspgl_log("%s(ptr %p, called from %s: %u)\n", __FUNCTION__, ptr, function, line); free(ptr); }
void* __pspgl_calloc (size_t count, size_t size, const char *function, unsigned int line) { void *ptr = calloc(count, size); __pspgl_log("%s(count %d, size %d, called from %s: %u): %p\n", __FUNCTION__, count, size, function, line, ptr); return ptr; }