GLContext.cpp 705 B

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * Copyright (c) 2021, Jesse Buhagiar <jooster669@gmail.com>
  3. * Copyright (c) 2021, Stephan Unverwerth <s.unverwerth@serenityos.org>
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #include "SoftwareGLContext.h"
  8. #include <LibGfx/Bitmap.h>
  9. __attribute__((visibility("hidden"))) GL::GLContext* g_gl_context;
  10. namespace GL {
  11. GLContext::~GLContext()
  12. {
  13. if (g_gl_context == this)
  14. make_context_current(nullptr);
  15. }
  16. OwnPtr<GLContext> create_context(Gfx::Bitmap& bitmap)
  17. {
  18. auto context = adopt_own(*new SoftwareGLContext(bitmap));
  19. if (!g_gl_context)
  20. g_gl_context = context;
  21. return context;
  22. }
  23. void make_context_current(GLContext* context)
  24. {
  25. g_gl_context = context;
  26. }
  27. }