(proc_type)egl_glx->glXGetProcAddress((const GLubyte*)#proc_name); \
if (!egl_glx->proc_name) { \
YAGL_LOG_ERROR("Unable to get symbol: %s", \
- yagl_dyn_lib_get_error(egl_glx->dyn_lib)); \
- goto fail2; \
+ yagl_dyn_lib_get_error(egl_driver->dyn_lib)); \
+ goto fail; \
} \
} while (0)
{
struct yagl_egl_driver base;
- struct yagl_dyn_lib *dyn_lib;
-
/* GLX 1.0 */
GLXCREATECONTEXTPROC glXCreateContext;
GLXDESTROYCONTEXTPROC glXDestroyContext;
YAGL_LOG_FUNC_ENTER_NPT(yagl_egl_glx_destroy, NULL);
- yagl_dyn_lib_destroy(egl_glx->dyn_lib);
-
yagl_egl_driver_cleanup(&egl_glx->base);
g_free(egl_glx);
struct yagl_egl_driver *yagl_egl_glx_create(void)
{
+ struct yagl_egl_driver *egl_driver;
struct yagl_egl_glx *egl_glx;
YAGL_LOG_FUNC_ENTER_NPT(yagl_egl_glx_create, NULL);
egl_glx = g_malloc0(sizeof(*egl_glx));
- yagl_egl_driver_init(&egl_glx->base);
+ egl_driver = &egl_glx->base;
+
+ yagl_egl_driver_init(egl_driver);
- egl_glx->dyn_lib = yagl_dyn_lib_create();
+ egl_driver->dyn_lib = yagl_dyn_lib_create();
- if (!egl_glx->dyn_lib) {
- goto fail1;
+ if (!egl_driver->dyn_lib) {
+ goto fail;
}
- if (!yagl_dyn_lib_load(egl_glx->dyn_lib, "libGL.so.1")) {
+ if (!yagl_dyn_lib_load(egl_driver->dyn_lib, "libGL.so.1")) {
YAGL_LOG_ERROR("Unable to load libGL.so.1: %s",
- yagl_dyn_lib_get_error(egl_glx->dyn_lib));
- goto fail2;
+ yagl_dyn_lib_get_error(egl_driver->dyn_lib));
+ goto fail;
}
egl_glx->glXGetProcAddress =
- yagl_dyn_lib_get_sym(egl_glx->dyn_lib, "glXGetProcAddress");
+ yagl_dyn_lib_get_sym(egl_driver->dyn_lib, "glXGetProcAddress");
if (!egl_glx->glXGetProcAddress) {
egl_glx->glXGetProcAddress =
- yagl_dyn_lib_get_sym(egl_glx->dyn_lib, "glXGetProcAddressARB");
+ yagl_dyn_lib_get_sym(egl_driver->dyn_lib, "glXGetProcAddressARB");
}
if (!egl_glx->glXGetProcAddress) {
YAGL_LOG_ERROR("Unable to get symbol: %s",
- yagl_dyn_lib_get_error(egl_glx->dyn_lib));
- goto fail2;
+ yagl_dyn_lib_get_error(egl_driver->dyn_lib));
+ goto fail;
}
/* GLX 1.0 */
return &egl_glx->base;
-fail2:
- yagl_dyn_lib_destroy(egl_glx->dyn_lib);
-fail1:
+fail:
yagl_egl_driver_cleanup(&egl_glx->base);
g_free(egl_glx);
{
struct yagl_gles1_driver base;
- struct yagl_dyn_lib *dyn_lib;
-
struct yagl_gles_ogl *gles_ogl;
YAGL_GLES_OGL_PROC2(glAlphaFunc, GLenum, GLclampf, func, ref)
yagl_gles_ogl_destroy(gles1_ogl->gles_ogl);
- yagl_dyn_lib_destroy(gles1_ogl->dyn_lib);
-
yagl_gles1_driver_cleanup(&gles1_ogl->base);
g_free(gles1_ogl);
YAGL_LOG_FUNC_EXIT(NULL);
}
-struct yagl_gles1_driver *yagl_gles1_ogl_create(void)
+struct yagl_gles1_driver *yagl_gles1_ogl_create(struct yagl_dyn_lib *dyn_lib)
{
struct yagl_gles1_ogl *gles1_ogl = NULL;
PFNGLXGETPROCADDRESSPROC get_address = NULL;
- struct yagl_dyn_lib *dyn_lib = NULL;
struct yagl_gles_ogl *gles_ogl = NULL;
YAGL_LOG_FUNC_ENTER_NPT(yagl_gles1_ogl_create, NULL);
yagl_gles1_driver_init(&gles1_ogl->base);
- dyn_lib = yagl_dyn_lib_create();
-
- if (!dyn_lib) {
- goto fail;
- }
-
- if (!yagl_dyn_lib_load(dyn_lib, "libGL.so.1")) {
- YAGL_LOG_ERROR("Unable to load libGL.so.1: %s",
- yagl_dyn_lib_get_error(dyn_lib));
- goto fail;
- }
-
gles_ogl = yagl_gles_ogl_create(dyn_lib);
if (!gles_ogl) {
YAGL_GLES_OGL_GET_PROC(gles1_ogl, glTexEnviv);
YAGL_GLES_OGL_GET_PROC(gles1_ogl, glVertexPointer);
- gles1_ogl->dyn_lib = dyn_lib;
gles1_ogl->gles_ogl = gles_ogl;
gles1_ogl->base.process_init = &yagl_gles1_ogl_process_init;
gles1_ogl->base.destroy = &yagl_gles1_ogl_destroy;
if (gles_ogl) {
yagl_gles_ogl_destroy(gles_ogl);
}
- if (dyn_lib) {
- yagl_dyn_lib_destroy(dyn_lib);
- }
yagl_gles1_driver_cleanup(&gles1_ogl->base);
g_free(gles1_ogl);
#define _QEMU_YAGL_GLES1_OGL_H
#include "yagl_types.h"
+#include "yagl_dyn_lib.h"
struct yagl_gles1_driver;
-struct yagl_gles1_driver *yagl_gles1_ogl_create(void);
+struct yagl_gles1_driver *yagl_gles1_ogl_create(struct yagl_dyn_lib *dyn_lib);
#endif
{
struct yagl_gles2_driver base;
- struct yagl_dyn_lib *dyn_lib;
-
struct yagl_gles_ogl *gles_ogl;
YAGL_GLES_OGL_PROC2(glAttachShader, GLuint, GLuint, program, shader)
yagl_gles_ogl_destroy(gles2_ogl->gles_ogl);
- yagl_dyn_lib_destroy(gles2_ogl->dyn_lib);
-
yagl_gles2_driver_cleanup(&gles2_ogl->base);
g_free(gles2_ogl);
YAGL_LOG_FUNC_EXIT(NULL);
}
-struct yagl_gles2_driver *yagl_gles2_ogl_create(void)
+struct yagl_gles2_driver *yagl_gles2_ogl_create(struct yagl_dyn_lib *dyn_lib)
{
struct yagl_gles2_ogl *gles2_ogl = NULL;
PFNGLXGETPROCADDRESSPROC get_address = NULL;
- struct yagl_dyn_lib *dyn_lib = NULL;
struct yagl_gles_ogl *gles_ogl = NULL;
YAGL_LOG_FUNC_ENTER_NPT(yagl_gles2_ogl_create, NULL);
yagl_gles2_driver_init(&gles2_ogl->base);
- dyn_lib = yagl_dyn_lib_create();
-
- if (!dyn_lib) {
- goto fail;
- }
-
- if (!yagl_dyn_lib_load(dyn_lib, "libGL.so.1")) {
- YAGL_LOG_ERROR("Unable to load libGL.so.1: %s",
- yagl_dyn_lib_get_error(dyn_lib));
- goto fail;
- }
-
gles_ogl = yagl_gles_ogl_create(dyn_lib);
if (!gles_ogl) {
YAGL_GLES_OGL_GET_PROC(gles2_ogl, glVertexAttrib4fv);
YAGL_GLES_OGL_GET_PROC(gles2_ogl, glVertexAttribPointer);
- gles2_ogl->dyn_lib = dyn_lib;
gles2_ogl->gles_ogl = gles_ogl;
gles2_ogl->base.process_init = &yagl_gles2_ogl_process_init;
gles2_ogl->base.destroy = &yagl_gles2_ogl_destroy;
if (gles_ogl) {
yagl_gles_ogl_destroy(gles_ogl);
}
- if (dyn_lib) {
- yagl_dyn_lib_destroy(dyn_lib);
- }
yagl_gles2_driver_cleanup(&gles2_ogl->base);
g_free(gles2_ogl);
#define _QEMU_YAGL_GLES2_OGL_H
#include "yagl_types.h"
+#include "yagl_dyn_lib.h"
struct yagl_gles2_driver;
-struct yagl_gles2_driver *yagl_gles2_ogl_create(void);
+struct yagl_gles2_driver *yagl_gles2_ogl_create(struct yagl_dyn_lib *dyn_lib);
#endif
#include "yagl_egl_driver.h"
+#include "yagl_dyn_lib.h"
void yagl_egl_driver_ps_init(struct yagl_egl_driver_ps *driver_ps,
struct yagl_egl_driver *driver,
void yagl_egl_driver_init(struct yagl_egl_driver *driver)
{
+ driver->dyn_lib = NULL;
}
void yagl_egl_driver_cleanup(struct yagl_egl_driver *driver)
{
+ if (driver->dyn_lib) {
+ yagl_dyn_lib_destroy(driver->dyn_lib);
+ }
}
#define _QEMU_YAGL_EGL_DRIVER_H
#include "yagl_types.h"
+#include "yagl_dyn_lib.h"
#include <EGL/egl.h>
struct yagl_thread_state;
struct yagl_process_state */*ps*/);
void (*destroy)(struct yagl_egl_driver */*driver*/);
+
+ struct yagl_dyn_lib *dyn_lib;
};
#ifdef CONFIG_YAGL_EGL_GLX
goto fail;
}
- gles2_driver = yagl_gles2_ogl_create();
+ gles2_driver = yagl_gles2_ogl_create(egl_driver->dyn_lib);
if (!gles2_driver) {
goto fail;