PageRenderTime 137ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 1ms

/src/Core_WindowEvents/Win32D3D9/WindowData_DIRECTX9.cpp

http://github.com/Akranar/daguerreo
C++ | 103 lines | 35 code | 9 blank | 59 comment | 4 complexity | 346ce2579a49ddc1c52ad0fb9bba7a1d MD5 | raw file
Possible License(s): AGPL-3.0, LGPL-2.1, LGPL-3.0, GPL-2.0
  1. #include "WindowData_DIRECTX9.h"
  2. #include <iostream>
  3. /*
  4. #include <GL/gl.h>
  5. #define GL_GLEXT_PROTOTYPES 1
  6. #include <GL/glext.h>
  7. #define WGL_WGLEXT_PROTOTYPES 1
  8. #include "wglext.h" //downloaded from http://www.opengl.org/registry/api/wglext.h
  9. */
  10. std::map<HWND, WindowEvents *> * WindowData::handle_map_window = 0;
  11. int WindowData::vsync = 1;
  12. WindowData::WindowData()
  13. :
  14. mouse_position_must_update(true)
  15. {
  16. if (!handle_map_window)
  17. {
  18. handle_map_window = new std::map<HWND, WindowEvents *>;
  19. }
  20. }
  21. WindowData::~WindowData()
  22. {
  23. handle_map_window->erase(handle_window);
  24. if (handle_map_window->empty())
  25. {
  26. delete handle_map_window;
  27. handle_map_window = 0;
  28. }
  29. }
  30. WindowEvents * WindowData::FindWindowEvents(HWND & hWnd)
  31. {
  32. std::map<HWND, WindowEvents *>::iterator it = handle_map_window->find(hWnd);
  33. if (it == handle_map_window->end())
  34. {
  35. return 0;
  36. }
  37. return it->second;
  38. }
  39. static bool IsExtensionSupported(const char * extension_list, const char * extension)
  40. {
  41. /*
  42. const char *start;
  43. const char *location, *terminator;
  44. //Extension names should not have spaces.
  45. location = strchr(extension, ' ');
  46. if (location || *extension == '\0') return false;
  47. //It takes a bit of care to be fool-proof about parsing the OpenGL extensions string. Don't be fooled by sub-strings, etc.
  48. for (start = extension_list; ;)
  49. {
  50. location = strstr(start, extension);
  51. if (!location) break;
  52. terminator = location + strlen(extension);
  53. if (location == start || *(location - 1) == ' ')
  54. {
  55. if (*terminator == ' ' || *terminator == '\0') return true;
  56. }
  57. start = terminator;
  58. }
  59. */
  60. return false;
  61. }
  62. /*
  63. VSync:
  64. -> http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=271567
  65. -> With GLX (X11), uses extension GLX_SGI_video_sync
  66. -> With Mac (CGL, Carbon and Cocoa), set swap internal to a none zero value:
  67. -> http://developer.apple.com/mac/library/d...1987-CH216-SW12
  68. -> With WGL (Windows), use extension WGL_EXT_swap_control
  69. */
  70. /*
  71. void WindowData::SetVSync(bool sync)
  72. {
  73. typedef bool (APIENTRY *PFNWGLSWAPINTERVALFARPROC)(int);
  74. PFNWGLSWAPINTERVALFARPROC wglSwapIntervalEXT = 0;
  75. PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC) wglGetProcAddress("wglGetExtensionsStringARB");
  76. if (wglGetExtensionsStringARB)
  77. {
  78. const char * extension_string = wglGetExtensionsStringARB(this->GetDeviceContext());
  79. if (IsExtensionSupported(extension_string, "WGL_EXT_swap_control"))
  80. {
  81. wglSwapIntervalEXT = (PFNWGLSWAPINTERVALFARPROC)wglGetProcAddress("wglSwapIntervalEXT");
  82. wglSwapIntervalEXT(sync);
  83. }
  84. }
  85. }
  86. */