SDL_bvideo.cc 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. #include "../../SDL_internal.h"
  19. #if SDL_VIDEO_DRIVER_HAIKU
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. #include "SDL_bkeyboard.h"
  24. #include "SDL_bwindow.h"
  25. #include "SDL_bclipboard.h"
  26. #include "SDL_bvideo.h"
  27. #include "SDL_bopengl.h"
  28. #include "SDL_bmodes.h"
  29. #include "SDL_bframebuffer.h"
  30. #include "SDL_bevents.h"
  31. /* FIXME: Undefined functions */
  32. // #define BE_PumpEvents NULL
  33. #define BE_StartTextInput NULL
  34. #define BE_StopTextInput NULL
  35. #define BE_SetTextInputRect NULL
  36. // #define BE_DeleteDevice NULL
  37. /* End undefined functions */
  38. static SDL_VideoDevice *
  39. BE_CreateDevice(int devindex)
  40. {
  41. SDL_VideoDevice *device;
  42. /*SDL_VideoData *data;*/
  43. /* Initialize all variables that we clean on shutdown */
  44. device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
  45. device->driverdata = NULL; /* FIXME: Is this the cause of some of the
  46. SDL_Quit() errors? */
  47. /* TODO: Figure out if any initialization needs to go here */
  48. /* Set the function pointers */
  49. device->VideoInit = BE_VideoInit;
  50. device->VideoQuit = BE_VideoQuit;
  51. device->GetDisplayBounds = BE_GetDisplayBounds;
  52. device->GetDisplayModes = BE_GetDisplayModes;
  53. device->SetDisplayMode = BE_SetDisplayMode;
  54. device->PumpEvents = BE_PumpEvents;
  55. device->CreateWindow = BE_CreateWindow;
  56. device->CreateWindowFrom = BE_CreateWindowFrom;
  57. device->SetWindowTitle = BE_SetWindowTitle;
  58. device->SetWindowIcon = BE_SetWindowIcon;
  59. device->SetWindowPosition = BE_SetWindowPosition;
  60. device->SetWindowSize = BE_SetWindowSize;
  61. device->ShowWindow = BE_ShowWindow;
  62. device->HideWindow = BE_HideWindow;
  63. device->RaiseWindow = BE_RaiseWindow;
  64. device->MaximizeWindow = BE_MaximizeWindow;
  65. device->MinimizeWindow = BE_MinimizeWindow;
  66. device->RestoreWindow = BE_RestoreWindow;
  67. device->SetWindowBordered = BE_SetWindowBordered;
  68. device->SetWindowFullscreen = BE_SetWindowFullscreen;
  69. device->SetWindowGammaRamp = BE_SetWindowGammaRamp;
  70. device->GetWindowGammaRamp = BE_GetWindowGammaRamp;
  71. device->SetWindowGrab = BE_SetWindowGrab;
  72. device->DestroyWindow = BE_DestroyWindow;
  73. device->GetWindowWMInfo = BE_GetWindowWMInfo;
  74. device->CreateWindowFramebuffer = BE_CreateWindowFramebuffer;
  75. device->UpdateWindowFramebuffer = BE_UpdateWindowFramebuffer;
  76. device->DestroyWindowFramebuffer = BE_DestroyWindowFramebuffer;
  77. device->shape_driver.CreateShaper = NULL;
  78. device->shape_driver.SetWindowShape = NULL;
  79. device->shape_driver.ResizeWindowShape = NULL;
  80. device->GL_LoadLibrary = BE_GL_LoadLibrary;
  81. device->GL_GetProcAddress = BE_GL_GetProcAddress;
  82. device->GL_UnloadLibrary = BE_GL_UnloadLibrary;
  83. device->GL_CreateContext = BE_GL_CreateContext;
  84. device->GL_MakeCurrent = BE_GL_MakeCurrent;
  85. device->GL_SetSwapInterval = BE_GL_SetSwapInterval;
  86. device->GL_GetSwapInterval = BE_GL_GetSwapInterval;
  87. device->GL_SwapWindow = BE_GL_SwapWindow;
  88. device->GL_DeleteContext = BE_GL_DeleteContext;
  89. device->StartTextInput = BE_StartTextInput;
  90. device->StopTextInput = BE_StopTextInput;
  91. device->SetTextInputRect = BE_SetTextInputRect;
  92. device->SetClipboardText = BE_SetClipboardText;
  93. device->GetClipboardText = BE_GetClipboardText;
  94. device->HasClipboardText = BE_HasClipboardText;
  95. device->free = BE_DeleteDevice;
  96. return device;
  97. }
  98. VideoBootStrap HAIKU_bootstrap = {
  99. "haiku", "Haiku graphics",
  100. BE_Available, BE_CreateDevice
  101. };
  102. void BE_DeleteDevice(SDL_VideoDevice * device)
  103. {
  104. SDL_free(device->driverdata);
  105. SDL_free(device);
  106. }
  107. int BE_VideoInit(_THIS)
  108. {
  109. /* Initialize the Be Application for appserver interaction */
  110. if (SDL_InitBeApp() < 0) {
  111. return -1;
  112. }
  113. /* Initialize video modes */
  114. BE_InitModes(_this);
  115. /* Init the keymap */
  116. BE_InitOSKeymap();
  117. #if SDL_VIDEO_OPENGL
  118. /* testgl application doesn't load library, just tries to load symbols */
  119. /* is it correct? if so we have to load library here */
  120. BE_GL_LoadLibrary(_this, NULL);
  121. #endif
  122. /* We're done! */
  123. return (0);
  124. }
  125. int BE_Available(void)
  126. {
  127. return (1);
  128. }
  129. void BE_VideoQuit(_THIS)
  130. {
  131. BE_QuitModes(_this);
  132. SDL_QuitBeApp();
  133. }
  134. #ifdef __cplusplus
  135. }
  136. #endif
  137. #endif /* SDL_VIDEO_DRIVER_HAIKU */