forked from CelestiaProject/Celestia
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglcontext.cpp
More file actions
90 lines (68 loc) · 1.97 KB
/
glcontext.cpp
File metadata and controls
90 lines (68 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// glcontext.h
//
// Copyright (C) 2003, Chris Laurel <claurel@shatters.net>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
#include <algorithm>
#include <celutil/debug.h>
#include "glcontext.h"
#include "glsupport.h"
using namespace std;
void GLContext::init(const vector<string>& ignoreExt)
{
auto* extensionsString = (char*) glGetString(GL_EXTENSIONS);
if (extensionsString != nullptr)
{
char* next = extensionsString;
while (*next != '\0')
{
while (*next != '\0' && *next != ' ')
next++;
string ext(extensionsString, next - extensionsString);
// scan the ignore list
auto iter = std::find(ignoreExt.begin(), ignoreExt.end(), ext);
if (iter == ignoreExt.end())
extensions.push_back(ext);
if (*next == '\0')
break;
next++;
extensionsString = next;
}
}
glGetIntegerv(GL_MAX_TEXTURE_UNITS,
(GLint*) &maxSimultaneousTextures);
}
bool GLContext::setRenderPath(GLRenderPath path)
{
if (!renderPathSupported(path))
return false;
renderPath = path;
return true;
}
bool GLContext::renderPathSupported(GLRenderPath path) const
{
switch (path)
{
case GLPath_GLSL:
return GLEW_VERSION_2_1 != GL_FALSE;
default:
return false;
}
}
GLContext::GLRenderPath GLContext::nextRenderPath()
{
#if 0
GLContext::GLRenderPath newPath = renderPath;
do {
newPath = (GLRenderPath) ((int) newPath + 1);;
if (newPath > GLPath_GLSL)
newPath = GLPath_Basic;
} while (newPath != renderPath && !renderPathSupported(newPath));
renderPath = newPath;
return renderPath;
#endif
return GLPath_GLSL;
}