Shared opengl context
This commit is contained in:
parent
549753d0c2
commit
0cd3fd4bb3
|
@ -54,7 +54,10 @@ void engine_init()
|
||||||
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 2); /* How many x MSAA */
|
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 2); /* How many x MSAA */
|
||||||
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 1);
|
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 1);
|
||||||
resources_init();
|
|
||||||
|
|
||||||
|
|
||||||
|
resources_init();
|
||||||
script_init();
|
script_init();
|
||||||
registry_init();
|
registry_init();
|
||||||
init_gameobjects();
|
init_gameobjects();
|
||||||
|
|
|
@ -93,10 +93,8 @@ static struct mSprite *tanim = NULL;
|
||||||
|
|
||||||
static unsigned int projUBO;
|
static unsigned int projUBO;
|
||||||
|
|
||||||
void openglInit(struct mSDLWindow *window)
|
void openglInit()
|
||||||
{
|
{
|
||||||
window_makecurrent(window);
|
|
||||||
|
|
||||||
if (SDL_GL_SetSwapInterval(1)) {
|
if (SDL_GL_SetSwapInterval(1)) {
|
||||||
YughLog(0, SDL_LOG_PRIORITY_WARN,
|
YughLog(0, SDL_LOG_PRIORITY_WARN,
|
||||||
"Unable to set VSync! SDL Error: %s", SDL_GetError());
|
"Unable to set VSync! SDL Error: %s", SDL_GetError());
|
||||||
|
@ -178,9 +176,11 @@ void openglRender(struct mSDLWindow *window, struct mCamera *mcamera)
|
||||||
renderText(stdFont, textShader, "Sample text", fontpos, 0.4f, fontcolor, -1.f);
|
renderText(stdFont, textShader, "Sample text", fontpos, 0.4f, fontcolor, -1.f);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
for (int i = 0; i < numSprites; i++) {
|
for (int i = 0; i < numSprites; i++) {
|
||||||
sprite_draw(sprites[i]);
|
sprite_draw(sprites[i]);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
//glDepthFunc(GL_LESS);
|
//glDepthFunc(GL_LESS);
|
||||||
|
|
|
@ -43,7 +43,7 @@ enum RenderMode {
|
||||||
OBJECTPICKER
|
OBJECTPICKER
|
||||||
};
|
};
|
||||||
|
|
||||||
void openglInit(struct mSDLWindow *window);
|
void openglInit();
|
||||||
void openglRender(struct mSDLWindow *window, struct mCamera *camera);
|
void openglRender(struct mSDLWindow *window, struct mCamera *camera);
|
||||||
|
|
||||||
void openglInit3d(struct mSDLWindow *window);
|
void openglInit3d(struct mSDLWindow *window);
|
||||||
|
|
|
@ -11,6 +11,8 @@ struct mSDLWindow *window = NULL;
|
||||||
static struct mSDLWindow *windows[5];
|
static struct mSDLWindow *windows[5];
|
||||||
static int numWindows = 0;
|
static int numWindows = 0;
|
||||||
|
|
||||||
|
static SDL_GLContext publicGLContext = NULL;
|
||||||
|
|
||||||
struct mSDLWindow *MakeSDLWindow(const char *name, int width, int height,
|
struct mSDLWindow *MakeSDLWindow(const char *name, int width, int height,
|
||||||
uint32_t flags)
|
uint32_t flags)
|
||||||
{
|
{
|
||||||
|
@ -24,13 +26,20 @@ struct mSDLWindow *MakeSDLWindow(const char *name, int width, int height,
|
||||||
"Window could not be created! SDL Error: %s",
|
"Window could not be created! SDL Error: %s",
|
||||||
SDL_GetError());
|
SDL_GetError());
|
||||||
} else {
|
} else {
|
||||||
w->glContext = SDL_GL_CreateContext(w->window);
|
if (publicGLContext == NULL) {
|
||||||
|
publicGLContext = SDL_GL_CreateContext(w->window);
|
||||||
|
}
|
||||||
|
|
||||||
if (w->glContext == NULL) {
|
w->glContext = publicGLContext;
|
||||||
|
SDL_GL_MakeCurrent(w->window, w->glContext);
|
||||||
|
|
||||||
|
|
||||||
|
if (publicGLContext == NULL) {
|
||||||
YughLog(0, SDL_LOG_PRIORITY_ERROR,
|
YughLog(0, SDL_LOG_PRIORITY_ERROR,
|
||||||
"OpenGL context could not be created! SDL Error: %s",
|
"OpenGL context could not be created! SDL Error: %s",
|
||||||
SDL_GetError());
|
SDL_GetError());
|
||||||
}
|
}
|
||||||
|
|
||||||
w->id = SDL_GetWindowID(w->window);
|
w->id = SDL_GetWindowID(w->window);
|
||||||
|
|
||||||
glewExperimental = GL_TRUE;
|
glewExperimental = GL_TRUE;
|
||||||
|
|
Loading…
Reference in a new issue