1 | // Copyright (C) 2012-2014 ChaosForge Ltd
|
---|
2 | // http://chaosforge.org/
|
---|
3 | //
|
---|
4 | // This file is part of NV Libraries.
|
---|
5 | // For conditions of distribution and use, see copyright notice in nv.hh
|
---|
6 |
|
---|
7 | #ifndef NV_LIB_GL_HH
|
---|
8 | #define NV_LIB_GL_HH
|
---|
9 |
|
---|
10 | #include <nv/core/common.hh>
|
---|
11 |
|
---|
12 | #if NV_PLATFORM == NV_WINDOWS
|
---|
13 | # ifndef WIN32_LEAN_AND_MEAN
|
---|
14 | # define WIN32_LEAN_AND_MEAN 1
|
---|
15 | # endif
|
---|
16 | #include <windows.h>
|
---|
17 | # undef WIN32_LEAN_AND_MEAN
|
---|
18 | # undef near
|
---|
19 | # undef far
|
---|
20 | #endif
|
---|
21 |
|
---|
22 | #include <stddef.h>
|
---|
23 |
|
---|
24 | //#define NV_SDL_GL
|
---|
25 | #define NV_GL_DYNAMIC
|
---|
26 | //#define NV_GL_SHARED
|
---|
27 |
|
---|
28 | #if NV_PLATFORM == NV_WINDOWS
|
---|
29 | # define NV_GL_PATH "opengl32.dll"
|
---|
30 | #elif NV_PLATFORM == NV_APPLE
|
---|
31 | # define NV_GL_PATH "/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib"
|
---|
32 | #else
|
---|
33 | # define NV_GL_PATH "libGL.so"
|
---|
34 | #endif
|
---|
35 |
|
---|
36 | #include <stdint.h>
|
---|
37 |
|
---|
38 | extern "C" {
|
---|
39 |
|
---|
40 | #if NV_PLATFORM == NV_WINDOWS
|
---|
41 | # define NV_GL_APIENTRY __stdcall
|
---|
42 | #else
|
---|
43 | # define NV_GL_APIENTRY
|
---|
44 | #endif
|
---|
45 |
|
---|
46 | #if defined(NV_GL_SHARED) && (NV_PLATFORM == NV_WINDOWS)
|
---|
47 | # define NV_GL_API __declspec(dllimport)
|
---|
48 | #else
|
---|
49 | # define NV_GL_API extern
|
---|
50 | #endif
|
---|
51 |
|
---|
52 | #include <nv/lib/detail/gl_types.inc>
|
---|
53 | #if NV_PLATFORM == NV_WINDOWS
|
---|
54 | #include <nv/lib/detail/wgl_types.inc>
|
---|
55 | #endif
|
---|
56 | #include <nv/lib/detail/gl_ext/gl_ext_all_types.inc>
|
---|
57 |
|
---|
58 | #if defined(NV_GL_DYNAMIC)
|
---|
59 | # define NV_GL_FUN_REN( rtype, fname, rname, fparams ) NV_GL_API rtype ( NV_GL_APIENTRY *rname) fparams
|
---|
60 | # define NV_GL_FUN( rtype, fname, fparams ) NV_GL_API rtype ( NV_GL_APIENTRY *fname) fparams
|
---|
61 | #else
|
---|
62 | # define NV_GL_FUN( rtype, fname, fparams ) NV_GL_API rtype NV_GL_APIENTRY fname fparams
|
---|
63 | #endif
|
---|
64 | #define NV_GL_FUN_EXT NV_GL_FUN
|
---|
65 |
|
---|
66 | #include <nv/lib/detail/gl_functions.inc>
|
---|
67 | #if NV_PLATFORM == NV_WINDOWS
|
---|
68 | #include <nv/lib/detail/wgl_functions.inc>
|
---|
69 | #endif
|
---|
70 | #include <nv/lib/detail/gl_ext/gl_ext_all_functions.inc>
|
---|
71 |
|
---|
72 | #undef NV_GL_FUN_REN
|
---|
73 | #undef NV_GL_FUN_EXT
|
---|
74 | #undef NV_GL_FUN
|
---|
75 |
|
---|
76 | }
|
---|
77 |
|
---|
78 | namespace nv {
|
---|
79 |
|
---|
80 | enum gl_extensions
|
---|
81 | {
|
---|
82 | EXT_NONE = 0,
|
---|
83 | #define NV_GL_EXTENSION( count, id, name ) GL_EXT_##id = 1u << (count-1),
|
---|
84 | #include <nv/lib/detail/gl_ext/gl_ext_info.inc>
|
---|
85 | #undef NV_GL_EXTENSION
|
---|
86 | // EXT_PIXEL_BUFFER_OBJECT = 0x00000004,
|
---|
87 | // EXT_TEXTURE_CUBE_MAP = 0x00000008,
|
---|
88 | // EXT_TEXTURE_3D = 0x00000010,
|
---|
89 | };
|
---|
90 |
|
---|
91 | const char* get_gl_extension_name( gl_extensions extension );
|
---|
92 | bool load_gl_extension( gl_extensions extension );
|
---|
93 | gl_extensions load_gl_extensions( uint32 extensions );
|
---|
94 | bool is_gl_extension_loaded( gl_extensions extensions );
|
---|
95 | bool are_gl_extensions_loaded( uint32 extensions );
|
---|
96 | bool load_gl_no_context( const char* path = NV_GL_PATH );
|
---|
97 | /* Dynamic load support */
|
---|
98 | # if defined( NV_GL_DYNAMIC )
|
---|
99 | bool load_gl_library( const char* path = NV_GL_PATH, bool force_reload = false );
|
---|
100 | bool load_wgl_library( const char* path = NV_GL_PATH, bool force_reload = false );
|
---|
101 | # else
|
---|
102 | inline bool load_gl_library( const char* = "", bool = false ) { return true; }
|
---|
103 | inline bool load_wgl_library( const char* = "", bool = false ) { return true; }
|
---|
104 | # endif
|
---|
105 | }
|
---|
106 |
|
---|
107 | #endif // NV_LIB_GL_HH
|
---|