gallium/st + hgl: Build fixes for Haiku
[mesa.git] / src / hgl / GLDispatcher.h
1 /*
2 * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
3 * Copyright 2000-2012 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 extern "C" {
21 #include "glapi/glapi.h"
22 }
23
24
25 class BGLDispatcher
26 {
27 // Private unimplemented copy constructors
28 BGLDispatcher(const BGLDispatcher &);
29 BGLDispatcher & operator=(const BGLDispatcher &);
30
31 public:
32 BGLDispatcher();
33 ~BGLDispatcher();
34
35 void SetCurrentContext(void* context);
36 void* CurrentContext();
37
38 struct _glapi_table* Table();
39 status_t CheckTable(
40 const struct _glapi_table* dispatch = NULL);
41 status_t SetTable(struct _glapi_table* dispatch);
42 uint32 TableSize();
43
44 const _glapi_proc operator[](const char* functionName);
45 const char* operator[](uint32 offset);
46
47 const _glapi_proc AddressOf(const char* functionName);
48 uint32 OffsetOf(const char* functionName);
49 };
50
51
52 // Inlines methods
53 inline void
54 BGLDispatcher::SetCurrentContext(void* context)
55 {
56 _glapi_set_context(context);
57 }
58
59
60 inline void*
61 BGLDispatcher::CurrentContext()
62 {
63 return _glapi_get_context();
64 }
65
66
67 inline struct _glapi_table*
68 BGLDispatcher::Table()
69 {
70 return _glapi_get_dispatch();
71 }
72
73
74 inline uint32
75 BGLDispatcher::TableSize()
76 {
77 return _glapi_get_dispatch_table_size();
78 }
79
80
81 inline const _glapi_proc
82 BGLDispatcher::operator[](const char* functionName)
83 {
84 return _glapi_get_proc_address(functionName);
85 }
86
87
88 inline const char*
89 BGLDispatcher::operator[](uint32 offset)
90 {
91 return _glapi_get_proc_name((GLuint) offset);
92 }
93
94
95 inline const _glapi_proc
96 BGLDispatcher::AddressOf(const char* functionName)
97 {
98 return _glapi_get_proc_address(functionName);
99 }
100
101
102 inline uint32
103 BGLDispatcher::OffsetOf(const char* functionName)
104 {
105 return (uint32) _glapi_get_proc_offset(functionName);
106 }
107
108
109 #endif // GLDISPATCHER_H