2021-01-06 11:58:01 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2021, Jesse Buhagiar <jooster669@gmail.com>
|
|
|
|
* Copyright (c) 2021, Stephan Unverwerth <s.unverwerth@gmx.de>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "SoftwareGLContext.h"
|
2021-04-23 23:57:01 +00:00
|
|
|
#include <LibGfx/Bitmap.h>
|
2021-01-06 11:58:01 +00:00
|
|
|
|
|
|
|
__attribute__((visibility("hidden"))) GL::GLContext* g_gl_context;
|
|
|
|
|
|
|
|
namespace GL {
|
|
|
|
|
|
|
|
GLContext::~GLContext()
|
|
|
|
{
|
|
|
|
if (g_gl_context == this)
|
|
|
|
make_context_current(nullptr);
|
|
|
|
}
|
|
|
|
|
2021-04-23 23:57:01 +00:00
|
|
|
OwnPtr<GLContext> create_context(Gfx::Bitmap& bitmap)
|
2021-01-06 11:58:01 +00:00
|
|
|
{
|
2021-04-23 23:57:01 +00:00
|
|
|
auto context = adopt_own(*new SoftwareGLContext(bitmap));
|
2021-01-06 11:58:01 +00:00
|
|
|
|
|
|
|
if (!g_gl_context)
|
|
|
|
g_gl_context = context;
|
|
|
|
|
|
|
|
return context;
|
|
|
|
}
|
|
|
|
|
|
|
|
void make_context_current(GLContext* context)
|
|
|
|
{
|
|
|
|
g_gl_context = context;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|