_EGL_DRIVER_STANDARD_TYPECASTS(haiku_egl)
-struct haiku_egl_driver
-{
- _EGLDriver base;
-};
-
struct haiku_egl_config
{
_EGLConfig base;
return NULL;
}
- if (!_eglInitSurface(&surface->surf, disp, EGL_WINDOW_BIT, conf, attrib_list))
- goto cleanup_surface;
+ if (!_eglInitSurface(&surface->surf, disp, EGL_WINDOW_BIT,
+ conf, attrib_list)) {
+ free(surface);
+ return NULL;
+ }
(&surface->surf)->SwapInterval = 1;
TRACE("Showing window\n");
win->Show();
return &surface->surf;
-
-cleanup_surface:
- free(surface);
- return NULL;
}
if (_eglPutSurface(surf)) {
// XXX: detach haiku_egl_surface::gl from the native window and destroy it
free(surf);
- }
+ }
return EGL_TRUE;
}
struct haiku_egl_config* conf;
conf = (struct haiku_egl_config*) calloc(1, sizeof (*conf));
- if (!conf) {
- _eglError(EGL_BAD_ALLOC, "haiku_add_configs_for_visuals");
- return NULL;
- }
+ if (!conf)
+ return _eglError(EGL_BAD_ALLOC, "haiku_add_configs_for_visuals");
_eglInitConfig(&conf->base, dpy, 1);
TRACE("Config inited\n");
_eglSetConfigKey(&conf->base, EGL_LUMINANCE_SIZE, 0);
_eglSetConfigKey(&conf->base, EGL_ALPHA_SIZE, 8);
_eglSetConfigKey(&conf->base, EGL_COLOR_BUFFER_TYPE, EGL_RGB_BUFFER);
- EGLint r = (_eglGetConfigKey(&conf->base, EGL_RED_SIZE)
+ EGLint r = (_eglGetConfigKey(&conf->base, EGL_RED_SIZE)
+ _eglGetConfigKey(&conf->base, EGL_GREEN_SIZE)
+ _eglGetConfigKey(&conf->base, EGL_BLUE_SIZE)
+ _eglGetConfigKey(&conf->base, EGL_ALPHA_SIZE));
goto cleanup;
}
TRACE("Validated config\n");
-
+
_eglLinkConfig(&conf->base);
if (!_eglGetArraySize(dpy->Configs)) {
_eglLog(_EGL_WARNING, "Haiku: failed to create any config");
return EGL_FALSE;
}
+
extern "C"
EGLBoolean
init_haiku(_EGLDriver *drv, _EGLDisplay *dpy)
return EGL_FALSE;
dpy->Version = 14;
-
+
TRACE("Initialization finished\n");
return EGL_TRUE;
if (_eglPutContext(ctx)) {
// XXX: teardown the context ?
free(context);
- ctx = NULL
+ ctx = NULL;
}
return EGL_TRUE;
}
extern "C"
EGLBoolean
haiku_make_current(_EGLDriver* drv, _EGLDisplay* dpy, _EGLSurface *dsurf,
- _EGLSurface *rsurf, _EGLContext *ctx)
+ _EGLSurface *rsurf, _EGLContext *ctx)
{
CALLED();
}
-extern "C"
-void
-haiku_unload(_EGLDriver* drv)
-{
-
-}
-
-
/**
* This is the main entrypoint into the driver, called by libEGL.
- * Create a new _EGLDriver object and init its dispatch table.
+ * Gets an _EGLDriver object and init its dispatch table.
*/
extern "C"
-_EGLDriver*
-_eglBuiltInDriverHaiku(const char *args)
+void
+_eglInitDriver(_EGLDriver *driver)
{
CALLED();
- struct haiku_egl_driver* driver;
- driver = (struct haiku_egl_driver*) calloc(1, sizeof(*driver));
- if (!driver) {
- _eglError(EGL_BAD_ALLOC, "_eglBuiltInDriverHaiku");
- return NULL;
- }
-
- _eglInitDriverFallbacks(&driver->base);
- driver->base.API.Initialize = init_haiku;
- driver->base.API.Terminate = haiku_terminate;
- driver->base.API.CreateContext = haiku_create_context;
- driver->base.API.DestroyContext = haiku_destroy_context;
- driver->base.API.MakeCurrent = haiku_make_current;
- driver->base.API.CreateWindowSurface = haiku_create_window_surface;
- driver->base.API.CreatePixmapSurface = haiku_create_pixmap_surface;
- driver->base.API.CreatePbufferSurface = haiku_create_pbuffer_surface;
- driver->base.API.DestroySurface = haiku_destroy_surface;
+ driver->API.Initialize = init_haiku;
+ driver->API.Terminate = haiku_terminate;
+ driver->API.CreateContext = haiku_create_context;
+ driver->API.DestroyContext = haiku_destroy_context;
+ driver->API.MakeCurrent = haiku_make_current;
+ driver->API.CreateWindowSurface = haiku_create_window_surface;
+ driver->API.CreatePixmapSurface = haiku_create_pixmap_surface;
+ driver->API.CreatePbufferSurface = haiku_create_pbuffer_surface;
+ driver->API.DestroySurface = haiku_destroy_surface;
- driver->base.API.SwapBuffers = haiku_swap_buffers;
+ driver->API.SwapBuffers = haiku_swap_buffers;
- driver->base.Name = "Haiku";
- driver->base.Unload = haiku_unload;
+ driver->Name = "Haiku";
TRACE("API Calls defined\n");
-
- return &driver->base;
}