context_gl_haiku.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*************************************************************************/
  2. /* context_gl_haiku.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #include "context_gl_haiku.h"
  31. #if defined(OPENGL_ENABLED)
  32. ContextGL_Haiku::ContextGL_Haiku(HaikuDirectWindow *p_window) {
  33. window = p_window;
  34. uint32 type = BGL_RGB | BGL_DOUBLE | BGL_DEPTH;
  35. view = new HaikuGLView(window->Bounds(), type);
  36. use_vsync = false;
  37. }
  38. ContextGL_Haiku::~ContextGL_Haiku() {
  39. delete view;
  40. }
  41. Error ContextGL_Haiku::initialize() {
  42. window->AddChild(view);
  43. window->SetHaikuGLView(view);
  44. return OK;
  45. }
  46. void ContextGL_Haiku::release_current() {
  47. view->UnlockGL();
  48. }
  49. void ContextGL_Haiku::make_current() {
  50. view->LockGL();
  51. }
  52. void ContextGL_Haiku::swap_buffers() {
  53. view->SwapBuffers(use_vsync);
  54. }
  55. int ContextGL_Haiku::get_window_width() {
  56. return window->Bounds().IntegerWidth();
  57. }
  58. int ContextGL_Haiku::get_window_height() {
  59. return window->Bounds().IntegerHeight();
  60. }
  61. void ContextGL_Haiku::set_use_vsync(bool p_use) {
  62. use_vsync = p_use;
  63. }
  64. bool ContextGL_Haiku::is_using_vsync() const {
  65. return use_vsync;
  66. }
  67. #endif