1848b8605Smrg/*
2848b8605Smrg * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
3b8e80941Smrg * Copyright 2000-2015 Haiku, Inc. All Rights Reserved.
4848b8605Smrg * Distributed under the terms of the MIT License.
5848b8605Smrg *
6848b8605Smrg * Authors:
7848b8605Smrg *		Brian Paul <brian.e.paul@gmail.com>
8848b8605Smrg *		Philippe Houdoin <philippe.houdoin@free.fr>
9848b8605Smrg */
10848b8605Smrg#ifndef GLDISPATCHER_H
11848b8605Smrg#define GLDISPATCHER_H
12848b8605Smrg
13848b8605Smrg
14848b8605Smrg#include <BeBuild.h>
15848b8605Smrg#include <GL/gl.h>
16848b8605Smrg#include <SupportDefs.h>
17848b8605Smrg
18b8e80941Smrg#include "main/glheader.h"
19848b8605Smrg
20848b8605Smrg#include "glapi/glapi.h"
21848b8605Smrg
22848b8605Smrg
23848b8605Smrgclass BGLDispatcher
24848b8605Smrg{
25848b8605Smrg		// Private unimplemented copy constructors
26848b8605Smrg		BGLDispatcher(const BGLDispatcher &);
27848b8605Smrg		BGLDispatcher & operator=(const BGLDispatcher &);
28848b8605Smrg
29848b8605Smrg	public:
30848b8605Smrg		BGLDispatcher();
31848b8605Smrg		~BGLDispatcher();
32848b8605Smrg
33848b8605Smrg		void 					SetCurrentContext(void* context);
34848b8605Smrg		void*					CurrentContext();
35848b8605Smrg
36848b8605Smrg		struct _glapi_table* 	Table();
37848b8605Smrg		status_t				SetTable(struct _glapi_table* dispatch);
38848b8605Smrg		uint32					TableSize();
39848b8605Smrg
40848b8605Smrg		const _glapi_proc 		operator[](const char* functionName);
41848b8605Smrg		const char*				operator[](uint32 offset);
42848b8605Smrg
43848b8605Smrg		const _glapi_proc		AddressOf(const char* functionName);
44848b8605Smrg		uint32					OffsetOf(const char* functionName);
45848b8605Smrg};
46848b8605Smrg
47848b8605Smrg
48848b8605Smrg// Inlines methods
49848b8605Smrginline void
50848b8605SmrgBGLDispatcher::SetCurrentContext(void* context)
51848b8605Smrg{
52848b8605Smrg	_glapi_set_context(context);
53848b8605Smrg}
54848b8605Smrg
55848b8605Smrg
56848b8605Smrginline void*
57848b8605SmrgBGLDispatcher::CurrentContext()
58848b8605Smrg{
59848b8605Smrg	return _glapi_get_context();
60848b8605Smrg}
61848b8605Smrg
62848b8605Smrg
63848b8605Smrginline struct _glapi_table*
64848b8605SmrgBGLDispatcher::Table()
65848b8605Smrg{
66848b8605Smrg	return _glapi_get_dispatch();
67848b8605Smrg}
68848b8605Smrg
69848b8605Smrg
70848b8605Smrginline uint32
71848b8605SmrgBGLDispatcher::TableSize()
72848b8605Smrg{
73848b8605Smrg	return _glapi_get_dispatch_table_size();
74848b8605Smrg}
75848b8605Smrg
76848b8605Smrg
77848b8605Smrginline const _glapi_proc
78848b8605SmrgBGLDispatcher::operator[](const char* functionName)
79848b8605Smrg{
80848b8605Smrg	return _glapi_get_proc_address(functionName);
81848b8605Smrg}
82848b8605Smrg
83848b8605Smrg
84848b8605Smrginline const char*
85848b8605SmrgBGLDispatcher::operator[](uint32 offset)
86848b8605Smrg{
87848b8605Smrg	return _glapi_get_proc_name((GLuint) offset);
88848b8605Smrg}
89848b8605Smrg
90848b8605Smrg
91848b8605Smrginline const _glapi_proc
92848b8605SmrgBGLDispatcher::AddressOf(const char* functionName)
93848b8605Smrg{
94848b8605Smrg	return _glapi_get_proc_address(functionName);
95848b8605Smrg}
96848b8605Smrg
97848b8605Smrg
98848b8605Smrginline uint32
99848b8605SmrgBGLDispatcher::OffsetOf(const char* functionName)
100848b8605Smrg{
101848b8605Smrg	return (uint32) _glapi_get_proc_offset(functionName);
102848b8605Smrg}
103848b8605Smrg
104848b8605Smrg
105848b8605Smrg#endif	// GLDISPATCHER_H
106