1 /************************************************************************
3 * voxelands - 3d voxel world sandbox game
4 * Copyright (C) Lisa 'darkrose' Milne 2016 <lisa@ltmnet.com>
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 * See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>
18 ************************************************************************/
27 float anisotropic_max
;
33 int cfg_particles_max
;
49 /* command anisotropic setter */
50 int opengl_anisotropic_setter(char* value
)
52 opengl_features
.cfg_anisotropic
= parse_bool(value
);
55 /* command bilinear setter */
56 int opengl_bilinear_setter(char* value
)
58 opengl_features
.cfg_bilinear
= parse_bool(value
);
61 /* command trilinear setter */
62 int opengl_trilinear_setter(char* value
)
64 opengl_features
.cfg_trilinear
= parse_bool(value
);
67 /* command mipmap setter */
68 int opengl_mipmap_setter(char* value
)
70 opengl_features
.cfg_mipmap
= parse_bool(value
);
73 /* command particles setter */
74 int opengl_particles_setter(char* value
)
76 opengl_features
.cfg_particles
= parse_bool(value
);
79 /* command particlesmax setter */
80 int opengl_particles_max_setter(char* value
)
82 opengl_features
.cfg_particles_max
= strtol(value
,NULL
,10);
85 /* command bumpmap setter */
86 int opengl_bumpmap_setter(char* value
)
88 opengl_features
.cfg_bumpmap
= parse_bool(value
);
91 /* command psdf setter */
92 int opengl_psdf_setter(char* value
)
94 opengl_features
.cfg_pseudosdf
= parse_bool(value
);
98 /* check for anisotropic filtering support */
99 int opengl_has_anisotropic()
101 if (opengl_features
.anisotropic
< 0) {
102 char* t
= (char*)glGetString(GL_EXTENSIONS
);
103 opengl_features
.anisotropic
= 0;
104 if (glGetError() == GL_NO_ERROR
&& strstr(t
,"GL_EXT_texture_filter_anisotropic"))
105 opengl_features
.anisotropic
= 1;
106 glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT
, &opengl_features
.anisotropic_max
);
107 if (glGetError() == GL_NO_ERROR
)
108 opengl_features
.anisotropic_max
= 1.0;
111 if (!opengl_features
.anisotropic
)
114 if (opengl_features
.cfg_anisotropic
&& opengl_features
.cfg_mipmap
)
120 /* get the maximum anisotropic filtering value */
121 float opengl_max_anisotropic()
123 return opengl_features
.anisotropic_max
;
126 /* check for bilinear filtering support */
127 int opengl_has_bilinear()
129 return opengl_features
.cfg_bilinear
;
132 /* check for trilinear filtering support */
133 int opengl_has_trilinear()
135 return opengl_features
.cfg_trilinear
;
138 /* check for mipmap support */
139 int opengl_has_mipmap()
141 return opengl_features
.cfg_mipmap
;
144 /* check if particle effects are enabled */
145 int opengl_has_particles()
147 return opengl_features
.cfg_particles
;
150 /* get the maximum number of particles allowed */
151 int opengl_particles_max()
153 if (!opengl_has_particles())
155 return opengl_features
.cfg_particles_max
;
158 /* check if pseudo signed distance field rendering is enabled */
159 int opengl_has_psdf()
161 return opengl_features
.cfg_pseudosdf
;
164 /* converts an opengl error enum into a string */
165 char* opengl_error_string(GLenum e
)
169 case GL_INVALID_ENUM
:
170 return "OpenGL: GL_INVALID_ENUM";
172 case GL_INVALID_VALUE
:
173 return "OpenGL: GL_INVALID_VALUE";
175 case GL_INVALID_OPERATION
:
176 return "OpenGL: GL_INVALID_OPERATION";
181 return "Unknown OpenGL Error";