0022819: Redesign of OpenGl driver
[occt.git] / src / OpenGl / OpenGl_Context.hxx
CommitLineData
2166f0fa
SK
1// File: OpenGl_Context.hxx
2// Created: 26 January 2012
3// Author: Kirill GAVRILOV
4// Copyright: OPEN CASCADE 2012
5
6#ifndef _OpenGl_Context_H__
7#define _OpenGl_Context_H__
8
9#include <OpenGl_ArbVBO.hxx>
10#include <OpenGl_ExtFBO.hxx>
11#include <Standard_Transient.hxx>
12#include <Handle_OpenGl_Context.hxx>
13
14#if (!defined(_WIN32) && !defined(__WIN32__))
15 extern "C" {
16 extern void (*glXGetProcAddress (const GLubyte* theProcName))();
17 }
18#endif
19
20//! This class provide access to the GL context and available extensions.
21class OpenGl_Context : public Standard_Transient
22{
23public:
24
25 OpenGl_Context();
26 virtual ~OpenGl_Context();
27
28 //! Initialize available extensions.
29 //! GL context should be active!
30 void Init();
31
32 //! Parse theExtString string for presence of theExtName extension.
33 static Standard_Boolean CheckExtension (const char* theExtName,
34 const char* theExtString);
35
36 //! Auxiliary template to retrieve GL function pointer.
37 //! The context should be bound before call.
38 template <typename FuncType_t>
39 bool FindProc (const char* theFuncName,
40 FuncType_t& theFuncPtr)
41 {
42 #if (defined(_WIN32) || defined(__WIN32__))
43 theFuncPtr = (FuncType_t )wglGetProcAddress (theFuncName);
44 #else
45 theFuncPtr = (FuncType_t )glXGetProcAddress ((const GLubyte* )theFuncName);
46 #endif
47 return (theFuncPtr != NULL);
48 }
49
50public:
51
52 OpenGl_ArbVBO* arbVBO;
53 OpenGl_ExtFBO* extFBO;
54
55public:
56
57 DEFINE_STANDARD_RTTI(OpenGl_Window) // Type definition
58
59};
60
61#endif // _OpenGl_Context_H__