Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /*
  2.  * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
  3.  * Copyright 2000-2015 Haiku, Inc. All Rights Reserved.
  4.  * Distributed under the terms of the MIT License.
  5.  *
  6.  * Authors:
  7.  *              Brian Paul <brian.e.paul@gmail.com>
  8.  *              Philippe Houdoin <philippe.houdoin@free.fr>
  9.  */
  10. #ifndef GLDISPATCHER_H
  11. #define GLDISPATCHER_H
  12.  
  13.  
  14. #include <BeBuild.h>
  15. #include <GL/gl.h>
  16. #include <SupportDefs.h>
  17.  
  18. #include "glheader.h"
  19.  
  20. #include "glapi/glapi.h"
  21.  
  22.  
  23. class BGLDispatcher
  24. {
  25.                 // Private unimplemented copy constructors
  26.                 BGLDispatcher(const BGLDispatcher &);
  27.                 BGLDispatcher & operator=(const BGLDispatcher &);
  28.  
  29.         public:
  30.                 BGLDispatcher();
  31.                 ~BGLDispatcher();
  32.  
  33.                 void                                    SetCurrentContext(void* context);
  34.                 void*                                   CurrentContext();
  35.  
  36.                 struct _glapi_table*    Table();
  37.                 status_t                                CheckTable(
  38.                                                                         const struct _glapi_table* dispatch = NULL);
  39.                 status_t                                SetTable(struct _glapi_table* dispatch);
  40.                 uint32                                  TableSize();
  41.  
  42.                 const _glapi_proc               operator[](const char* functionName);
  43.                 const char*                             operator[](uint32 offset);
  44.  
  45.                 const _glapi_proc               AddressOf(const char* functionName);
  46.                 uint32                                  OffsetOf(const char* functionName);
  47. };
  48.  
  49.  
  50. // Inlines methods
  51. inline void
  52. BGLDispatcher::SetCurrentContext(void* context)
  53. {
  54.         _glapi_set_context(context);
  55. }
  56.  
  57.  
  58. inline void*
  59. BGLDispatcher::CurrentContext()
  60. {
  61.         return _glapi_get_context();
  62. }
  63.  
  64.  
  65. inline struct _glapi_table*
  66. BGLDispatcher::Table()
  67. {
  68.         return _glapi_get_dispatch();
  69. }
  70.  
  71.  
  72. inline uint32
  73. BGLDispatcher::TableSize()
  74. {
  75.         return _glapi_get_dispatch_table_size();
  76. }
  77.  
  78.  
  79. inline const _glapi_proc
  80. BGLDispatcher::operator[](const char* functionName)
  81. {
  82.         return _glapi_get_proc_address(functionName);
  83. }
  84.  
  85.  
  86. inline const char*
  87. BGLDispatcher::operator[](uint32 offset)
  88. {
  89.         return _glapi_get_proc_name((GLuint) offset);
  90. }
  91.  
  92.  
  93. inline const _glapi_proc
  94. BGLDispatcher::AddressOf(const char* functionName)
  95. {
  96.         return _glapi_get_proc_address(functionName);
  97. }
  98.  
  99.  
  100. inline uint32
  101. BGLDispatcher::OffsetOf(const char* functionName)
  102. {
  103.         return (uint32) _glapi_get_proc_offset(functionName);
  104. }
  105.  
  106.  
  107. #endif  // GLDISPATCHER_H
  108.