Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

pugl_internal.h 2.9KB

12 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. Copyright 2012 David Robillard <http://drobilla.net>
  3. Permission to use, copy, modify, and/or distribute this software for any
  4. purpose with or without fee is hereby granted, provided that the above
  5. copyright notice and this permission notice appear in all copies.
  6. THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  7. WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  8. MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  9. ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  10. WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  11. ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  12. OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  13. */
  14. /**
  15. @file pugl_internal.h Private platform-independent definitions.
  16. Note this file contains function definitions, so it must be compiled into
  17. the final binary exactly once. Each platform specific implementation file
  18. including it once should achieve this.
  19. */
  20. #include "pugl.h"
  21. typedef struct PuglInternalsImpl PuglInternals;
  22. struct PuglViewImpl {
  23. PuglHandle handle;
  24. PuglCloseFunc closeFunc;
  25. PuglDisplayFunc displayFunc;
  26. PuglKeyboardFunc keyboardFunc;
  27. PuglMotionFunc motionFunc;
  28. PuglMouseFunc mouseFunc;
  29. PuglReshapeFunc reshapeFunc;
  30. PuglScrollFunc scrollFunc;
  31. PuglSpecialFunc specialFunc;
  32. PuglInternals* impl;
  33. int width;
  34. int height;
  35. int mods;
  36. bool ignoreKeyRepeat;
  37. bool redisplay;
  38. };
  39. void
  40. puglSetHandle(PuglView* view, PuglHandle handle)
  41. {
  42. view->handle = handle;
  43. }
  44. PuglHandle
  45. puglGetHandle(PuglView* view)
  46. {
  47. return view->handle;
  48. }
  49. int
  50. puglGetModifiers(PuglView* view)
  51. {
  52. return view->mods;
  53. }
  54. static inline void
  55. puglDefaultReshape(PuglView* view, int width, int height)
  56. {
  57. glMatrixMode(GL_PROJECTION);
  58. glLoadIdentity();
  59. glOrtho(0, width, height, 0, 0, 1);
  60. glViewport(0, 0, width, height);
  61. glMatrixMode(GL_MODELVIEW);
  62. glLoadIdentity();
  63. return;
  64. // unused
  65. (void)view;
  66. }
  67. void
  68. puglIgnoreKeyRepeat(PuglView* view, bool ignore)
  69. {
  70. view->ignoreKeyRepeat = ignore;
  71. }
  72. void
  73. puglSetCloseFunc(PuglView* view, PuglCloseFunc closeFunc)
  74. {
  75. view->closeFunc = closeFunc;
  76. }
  77. void
  78. puglSetDisplayFunc(PuglView* view, PuglDisplayFunc displayFunc)
  79. {
  80. view->displayFunc = displayFunc;
  81. }
  82. void
  83. puglSetKeyboardFunc(PuglView* view, PuglKeyboardFunc keyboardFunc)
  84. {
  85. view->keyboardFunc = keyboardFunc;
  86. }
  87. void
  88. puglSetMotionFunc(PuglView* view, PuglMotionFunc motionFunc)
  89. {
  90. view->motionFunc = motionFunc;
  91. }
  92. void
  93. puglSetMouseFunc(PuglView* view, PuglMouseFunc mouseFunc)
  94. {
  95. view->mouseFunc = mouseFunc;
  96. }
  97. void
  98. puglSetReshapeFunc(PuglView* view, PuglReshapeFunc reshapeFunc)
  99. {
  100. view->reshapeFunc = reshapeFunc;
  101. }
  102. void
  103. puglSetScrollFunc(PuglView* view, PuglScrollFunc scrollFunc)
  104. {
  105. view->scrollFunc = scrollFunc;
  106. }
  107. void
  108. puglSetSpecialFunc(PuglView* view, PuglSpecialFunc specialFunc)
  109. {
  110. view->specialFunc = specialFunc;
  111. }