forked from smcameron/space-nerds-in-space
-
Notifications
You must be signed in to change notification settings - Fork 0
/
opengl_cap.c
96 lines (80 loc) · 2.11 KB
/
opengl_cap.c
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
91
92
93
94
/*
(c) copyright 2014 jeremy van grinsven
this file is part of space nerds in space.
space nerds in space 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.
space nerds in space is distributed in the hope that it will be useful,
but without any warranty; without even the implied warranty of
merchantability or fitness for a particular purpose. see the
gnu general public license for more details.
you should have received a copy of the gnu general public license
along with space nerds in space; if not, write to the free software
foundation, inc., 51 franklin st, fifth floor, boston, ma 02110-1301 usa
*/
#include <GL/glew.h>
#include "opengl_cap.h"
#include <stdlib.h>
int msaa_framebuffer_supported()
{
static int suppress = -1;
if (suppress == -1) {
if (getenv("SNIS_SUPPRESS_MSAA") != NULL)
suppress = 1;
else
suppress = 0;
}
if (suppress)
return 0;
return GLEW_ARB_multisample;
}
int msaa_render_to_fbo_supported()
{
static int suppress = -1;
if (suppress == -1) {
if (getenv("SNIS_SUPPRESS_FBO") != NULL)
suppress = 1;
else
suppress = 0;
}
if (suppress)
return 0;
return GLEW_EXT_framebuffer_multisample && msaa_max_samples() > 0;
}
int msaa_max_samples()
{
GLint samples = 0;
glGetIntegerv(GL_MAX_SAMPLES, &samples);
return samples;
}
int fbo_render_to_texture_supported()
{
static int suppress = -1;
if (suppress == -1) {
if (getenv("SNIS_SUPPRESS_RENDER_TO_TEXTURE") != NULL)
suppress = 1;
else
suppress = 0;
}
if (suppress)
return 0;
return GLEW_EXT_framebuffer_object && GLEW_EXT_framebuffer_blit;
}
int framebuffer_srgb_supported()
{
/* see if extension exists */
if (!GLEW_EXT_framebuffer_sRGB)
return 0;
/* test the current framebuffer if it is capable */
GLboolean boolmode;
glGetBooleanv(GL_FRAMEBUFFER_SRGB_CAPABLE_EXT, &boolmode);
GLenum ret = glGetError();
if (ret != 0)
return 0;
return boolmode;
}
int texture_srgb_supported()
{
return GLEW_EXT_texture_sRGB;
}