GL: refuse multiple init

This commit is contained in:
Martin Pulec
2019-01-17 10:51:25 +01:00
committed by Martin Pulec
parent 1846029eb9
commit ebc6cc4452

View File

@@ -409,11 +409,13 @@ static void gl_load_splashscreen(struct state_gl *s)
static void * display_gl_init(struct module *parent, const char *fmt, unsigned int flags) {
UNUSED(flags);
if (gl) {
LOG(LOG_LEVEL_ERROR) << "Multiple instances of GL display is disallowed!\n";
return nullptr;
}
struct state_gl *s = new state_gl(parent);
/* GLUT callbacks take only some arguments so we need static variable */
gl = s;
// parse parameters
if (fmt != NULL) {
if (strcmp(fmt, "help") == 0) {
@@ -504,6 +506,9 @@ static void * display_gl_init(struct module *parent, const char *fmt, unsigned i
gl_load_splashscreen(s);
/* GLUT callbacks take only some arguments so we need static variable */
gl = s;
return (void*)s;
}
@@ -1702,6 +1707,8 @@ static void display_gl_done(void *state)
spout_sender_unregister(s->syphon_spout);
#endif
}
gl = nullptr;
delete s;
}