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_STENCIL_SIZE, 1);
|
||||
resources_init();
|
||||
|
||||
|
||||
|
||||
resources_init();
|
||||
script_init();
|
||||
registry_init();
|
||||
init_gameobjects();
|
||||
|
|
|
@ -93,10 +93,8 @@ static struct mSprite *tanim = NULL;
|
|||
|
||||
static unsigned int projUBO;
|
||||
|
||||
void openglInit(struct mSDLWindow *window)
|
||||
void openglInit()
|
||||
{
|
||||
window_makecurrent(window);
|
||||
|
||||
if (SDL_GL_SetSwapInterval(1)) {
|
||||
YughLog(0, SDL_LOG_PRIORITY_WARN,
|
||||
"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);
|
||||
*/
|
||||
|
||||
/*
|
||||
for (int i = 0; i < numSprites; i++) {
|
||||
sprite_draw(sprites[i]);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
//glDepthFunc(GL_LESS);
|
||||
|
|
|
@ -43,7 +43,7 @@ enum RenderMode {
|
|||
OBJECTPICKER
|
||||
};
|
||||
|
||||
void openglInit(struct mSDLWindow *window);
|
||||
void openglInit();
|
||||
void openglRender(struct mSDLWindow *window, struct mCamera *camera);
|
||||
|
||||
void openglInit3d(struct mSDLWindow *window);
|
||||
|
|
|
@ -11,6 +11,8 @@ struct mSDLWindow *window = NULL;
|
|||
static struct mSDLWindow *windows[5];
|
||||
static int numWindows = 0;
|
||||
|
||||
static SDL_GLContext publicGLContext = NULL;
|
||||
|
||||
struct mSDLWindow *MakeSDLWindow(const char *name, int width, int height,
|
||||
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",
|
||||
SDL_GetError());
|
||||
} 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,
|
||||
"OpenGL context could not be created! SDL Error: %s",
|
||||
SDL_GetError());
|
||||
}
|
||||
|
||||
w->id = SDL_GetWindowID(w->window);
|
||||
|
||||
glewExperimental = GL_TRUE;
|
||||
|
|
Loading…
Reference in a new issue