mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-13 01:38:20 +00:00
[client] allow renderers to pass back if they need an OpenGL context
This commit is contained in:
parent
cc521eab90
commit
4dfe4b8e2b
@ -63,6 +63,9 @@ typedef struct LG_DSInitParams
|
|||||||
bool borderless;
|
bool borderless;
|
||||||
bool maximize;
|
bool maximize;
|
||||||
bool minimizeOnFocusLoss;
|
bool minimizeOnFocusLoss;
|
||||||
|
|
||||||
|
// if true the renderer requires an OpenGL context
|
||||||
|
bool opengl;
|
||||||
}
|
}
|
||||||
LG_DSInitParams;
|
LG_DSInitParams;
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ typedef const char * (* LG_RendererGetName)();
|
|||||||
// called pre-creation to allow the renderer to register any options it might have
|
// called pre-creation to allow the renderer to register any options it might have
|
||||||
typedef void (* LG_RendererSetup)();
|
typedef void (* LG_RendererSetup)();
|
||||||
|
|
||||||
typedef bool (* LG_RendererCreate )(void ** opaque, const LG_RendererParams params);
|
typedef bool (* LG_RendererCreate )(void ** opaque, const LG_RendererParams params, bool * needsOpenGL);
|
||||||
typedef bool (* LG_RendererInitialize )(void * opaque);
|
typedef bool (* LG_RendererInitialize )(void * opaque);
|
||||||
typedef void (* LG_RendererDeInitialize )(void * opaque);
|
typedef void (* LG_RendererDeInitialize )(void * opaque);
|
||||||
typedef bool (* LG_RendererSupports )(void * opaque, LG_RendererSupport support);
|
typedef bool (* LG_RendererSupports )(void * opaque, LG_RendererSupport support);
|
||||||
|
@ -162,7 +162,7 @@ void egl_setup(void)
|
|||||||
option_register(egl_options);
|
option_register(egl_options);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool egl_create(void ** opaque, const LG_RendererParams params)
|
bool egl_create(void ** opaque, const LG_RendererParams params, bool * needsOpenGL)
|
||||||
{
|
{
|
||||||
// check if EGL is even available
|
// check if EGL is even available
|
||||||
if (!eglQueryString(EGL_NO_DISPLAY, EGL_VERSION))
|
if (!eglQueryString(EGL_NO_DISPLAY, EGL_VERSION))
|
||||||
@ -198,6 +198,7 @@ bool egl_create(void ** opaque, const LG_RendererParams params)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*needsOpenGL = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,7 +193,8 @@ static void opengl_setup(void)
|
|||||||
option_register(opengl_options);
|
option_register(opengl_options);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool opengl_create(void ** opaque, const LG_RendererParams params)
|
bool opengl_create(void ** opaque, const LG_RendererParams params,
|
||||||
|
bool * needsOpenGL)
|
||||||
{
|
{
|
||||||
// create our local storage
|
// create our local storage
|
||||||
*opaque = malloc(sizeof(struct Inst));
|
*opaque = malloc(sizeof(struct Inst));
|
||||||
@ -232,21 +233,21 @@ bool opengl_create(void ** opaque, const LG_RendererParams params)
|
|||||||
|
|
||||||
this->alerts = ll_new();
|
this->alerts = ll_new();
|
||||||
|
|
||||||
|
*needsOpenGL = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool opengl_initialize(void * opaque)
|
bool opengl_initialize(void * opaque)
|
||||||
{
|
{
|
||||||
//FIXME
|
|
||||||
return false;
|
|
||||||
#if 0
|
|
||||||
struct Inst * this = (struct Inst *)opaque;
|
struct Inst * this = (struct Inst *)opaque;
|
||||||
if (!this)
|
if (!this)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
this->waiting = true;
|
this->waiting = true;
|
||||||
this->waitDone = false;
|
this->waitDone = false;
|
||||||
|
return true;
|
||||||
|
|
||||||
|
#if 0
|
||||||
*sdlFlags = SDL_WINDOW_OPENGL;
|
*sdlFlags = SDL_WINDOW_OPENGL;
|
||||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER , 1);
|
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER , 1);
|
||||||
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
|
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
|
||||||
|
@ -590,7 +590,8 @@ void intHandler(int sig)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool tryRenderer(const int index, const LG_RendererParams lgrParams)
|
static bool tryRenderer(const int index, const LG_RendererParams lgrParams,
|
||||||
|
bool * needsOpenGL)
|
||||||
{
|
{
|
||||||
const LG_Renderer *r = LG_Renderers[index];
|
const LG_Renderer *r = LG_Renderers[index];
|
||||||
|
|
||||||
@ -602,7 +603,8 @@ static bool tryRenderer(const int index, const LG_RendererParams lgrParams)
|
|||||||
|
|
||||||
// create the renderer
|
// create the renderer
|
||||||
g_state.lgrData = NULL;
|
g_state.lgrData = NULL;
|
||||||
if (!r->create(&g_state.lgrData, lgrParams))
|
*needsOpenGL = false;
|
||||||
|
if (!r->create(&g_state.lgrData, lgrParams, needsOpenGL))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// initialize the renderer
|
// initialize the renderer
|
||||||
@ -686,6 +688,7 @@ static int lg_run(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// select and init a renderer
|
// select and init a renderer
|
||||||
|
bool needsOpenGL;
|
||||||
LG_RendererParams lgrParams;
|
LG_RendererParams lgrParams;
|
||||||
lgrParams.showFPS = g_params.showFPS;
|
lgrParams.showFPS = g_params.showFPS;
|
||||||
lgrParams.quickSplash = g_params.quickSplash;
|
lgrParams.quickSplash = g_params.quickSplash;
|
||||||
@ -693,7 +696,7 @@ static int lg_run(void)
|
|||||||
if (g_params.forceRenderer)
|
if (g_params.forceRenderer)
|
||||||
{
|
{
|
||||||
DEBUG_INFO("Trying forced renderer");
|
DEBUG_INFO("Trying forced renderer");
|
||||||
if (!tryRenderer(g_params.forceRendererIndex, lgrParams))
|
if (!tryRenderer(g_params.forceRendererIndex, lgrParams, &needsOpenGL))
|
||||||
{
|
{
|
||||||
DEBUG_ERROR("Forced renderer failed to iniailize");
|
DEBUG_ERROR("Forced renderer failed to iniailize");
|
||||||
return -1;
|
return -1;
|
||||||
@ -705,7 +708,7 @@ static int lg_run(void)
|
|||||||
// probe for a a suitable renderer
|
// probe for a a suitable renderer
|
||||||
for(unsigned int i = 0; i < LG_RENDERER_COUNT; ++i)
|
for(unsigned int i = 0; i < LG_RENDERER_COUNT; ++i)
|
||||||
{
|
{
|
||||||
if (tryRenderer(i, lgrParams))
|
if (tryRenderer(i, lgrParams, &needsOpenGL))
|
||||||
{
|
{
|
||||||
g_state.lgr = LG_Renderers[i];
|
g_state.lgr = LG_Renderers[i];
|
||||||
break;
|
break;
|
||||||
@ -731,7 +734,8 @@ static int lg_run(void)
|
|||||||
.resizable = g_params.allowResize,
|
.resizable = g_params.allowResize,
|
||||||
.borderless = g_params.borderless,
|
.borderless = g_params.borderless,
|
||||||
.maximize = g_params.maximize,
|
.maximize = g_params.maximize,
|
||||||
.minimizeOnFocusLoss = g_params.minimizeOnFocusLoss
|
.minimizeOnFocusLoss = g_params.minimizeOnFocusLoss,
|
||||||
|
.opengl = needsOpenGL
|
||||||
};
|
};
|
||||||
|
|
||||||
g_state.dsInitialized = g_state.ds->init(params);
|
g_state.dsInitialized = g_state.ds->init(params);
|
||||||
|
Loading…
Reference in New Issue
Block a user