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 "main/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 SetTable(struct _glapi_table* dispatch); 38 uint32 TableSize(); 39 40 const _glapi_proc operator[](const char* functionName); 41 const char* operator[](uint32 offset); 42 43 const _glapi_proc AddressOf(const char* functionName); 44 uint32 OffsetOf(const char* functionName); 45 }; 46 47 48 // Inlines methods 49 inline void SetCurrentContext(void * context)50BGLDispatcher::SetCurrentContext(void* context) 51 { 52 _glapi_set_context(context); 53 } 54 55 56 inline void* CurrentContext()57BGLDispatcher::CurrentContext() 58 { 59 return _glapi_get_context(); 60 } 61 62 63 inline struct _glapi_table* Table()64BGLDispatcher::Table() 65 { 66 return _glapi_get_dispatch(); 67 } 68 69 70 inline uint32 TableSize()71BGLDispatcher::TableSize() 72 { 73 return _glapi_get_dispatch_table_size(); 74 } 75 76 77 inline const _glapi_proc 78 BGLDispatcher::operator[](const char* functionName) 79 { 80 return _glapi_get_proc_address(functionName); 81 } 82 83 84 inline const char* 85 BGLDispatcher::operator[](uint32 offset) 86 { 87 return _glapi_get_proc_name((GLuint) offset); 88 } 89 90 91 inline const _glapi_proc AddressOf(const char * functionName)92BGLDispatcher::AddressOf(const char* functionName) 93 { 94 return _glapi_get_proc_address(functionName); 95 } 96 97 98 inline uint32 OffsetOf(const char * functionName)99BGLDispatcher::OffsetOf(const char* functionName) 100 { 101 return (uint32) _glapi_get_proc_offset(functionName); 102 } 103 104 105 #endif // GLDISPATCHER_H 106