internal.dox 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*!
  2. @page internals_guide Internal structure
  3. @tableofcontents
  4. There are several interfaces inside GLFW. Each interface has its own area of
  5. responsibility and its own naming conventions.
  6. @section internals_public Public interface
  7. The most well-known is the public interface, described in the glfw3.h header
  8. file. This is implemented in source files shared by all platforms and these
  9. files contain no platform-specific code. This code usually ends up calling the
  10. platform and internal interfaces to do the actual work.
  11. The public interface uses the OpenGL naming conventions except with GLFW and
  12. glfw instead of GL and gl. For struct members, where OpenGL sets no precedent,
  13. it use headless camel case.
  14. Examples: `glfwCreateWindow`, `GLFWwindow`, `GLFW_RED_BITS`
  15. @section internals_native Native interface
  16. The [native interface](@ref native) is a small set of publicly available
  17. but platform-specific functions, described in the glfw3native.h header file and
  18. used to gain access to the underlying window, context and (on some platforms)
  19. display handles used by the platform interface.
  20. The function names of the native interface are similar to those of the public
  21. interface, but embeds the name of the interface that the returned handle is
  22. from.
  23. Examples: `glfwGetX11Window`, `glfwGetWGLContext`
  24. @section internals_internal Internal interface
  25. The internal interface consists of utility functions used by all other
  26. interfaces. It is shared code implemented in the same shared source files as
  27. the public and event interfaces. The internal interface is described in the
  28. internal.h header file.
  29. The internal interface is in charge of GLFW's global data, which it stores in
  30. a `_GLFWlibrary` struct named `_glfw`.
  31. The internal interface uses the same style as the public interface, except all
  32. global names have a leading underscore.
  33. Examples: `_glfwIsValidContextConfig`, `_GLFWwindow`, `_glfw.monitorCount`
  34. @section internals_platform Platform interface
  35. The platform interface implements all platform-specific operations as a service
  36. to the public interface. This includes event processing. The platform
  37. interface is never directly called by application code and never directly calls
  38. application-provided callbacks. It is also prohibited from modifying the
  39. platform-independent part of the internal structs. Instead, it calls the event
  40. interface when events interesting to GLFW are received.
  41. The platform interface mirrors those parts of the public interface that needs to
  42. perform platform-specific operations on some or all platforms. The are also
  43. named the same except that the glfw function prefix is replaced by
  44. _glfwPlatform.
  45. Examples: `_glfwPlatformCreateWindow`
  46. The platform interface also defines structs that contain platform-specific
  47. global and per-object state. Their names mirror those of the internal
  48. interface, except that an interface-specific suffix is added.
  49. Examples: `_GLFWwindowX11`, `_GLFWcontextWGL`
  50. These structs are incorporated as members into the internal interface structs
  51. using special macros that name them after the specific interface used. This
  52. prevents shared code from accidentally using these members.
  53. Examples: `window->win32.handle`, `_glfw.x11.display`
  54. @section internals_event Event interface
  55. The event interface is implemented in the same shared source files as the public
  56. interface and is responsible for delivering the events it receives to the
  57. application, either via callbacks, via window state changes or both.
  58. The function names of the event interface use a `_glfwInput` prefix and the
  59. ObjectEvent pattern.
  60. Examples: `_glfwInputWindowFocus`, `_glfwInputCursorPos`
  61. @section internals_static Static functions
  62. Static functions may be used by any interface and have no prefixes or suffixes.
  63. These use headless camel case.
  64. Examples: `isValidElementForJoystick`
  65. @section internals_config Configuration macros
  66. GLFW uses a number of configuration macros to select at compile time which
  67. interfaces and code paths to use. They are defined in the glfw_config.h header file,
  68. which is generated from the `glfw_config.h.in` file by CMake.
  69. Configuration macros the same style as tokens in the public interface, except
  70. with a leading underscore.
  71. Examples: `_GLFW_WIN32`, `_GLFW_BUILD_DLL`
  72. */