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
;
47 /* command anisotropic setter */
48 int opengl_anisotropic_setter(char* value
)
50 opengl_features
.cfg_anisotropic
= parse_bool(value
);
53 /* command bilinear setter */
54 int opengl_bilinear_setter(char* value
)
56 opengl_features
.cfg_bilinear
= parse_bool(value
);
59 /* command trilinear setter */
60 int opengl_trilinear_setter(char* value
)
62 opengl_features
.cfg_trilinear
= parse_bool(value
);
65 /* command mipmap setter */
66 int opengl_mipmap_setter(char* value
)
68 opengl_features
.cfg_mipmap
= parse_bool(value
);
71 /* command particles setter */
72 int opengl_particles_setter(char* value
)
74 opengl_features
.cfg_particles
= parse_bool(value
);
77 /* command particlesmax setter */
78 int opengl_particles_max_setter(char* value
)
80 opengl_features
.cfg_particles_max
= strtol(value
,NULL
,10);
83 /* command bumpmap setter */
84 int opengl_bumpmap_setter(char* value
)
86 opengl_features
.cfg_bumpmap
= parse_bool(value
);
90 /* check for anisotropic filtering support */
91 int opengl_has_anisotropic()
93 if (opengl_features
.anisotropic
< 0) {
94 char* t
= (char*)glGetString(GL_EXTENSIONS
);
95 opengl_features
.anisotropic
= 0;
96 if (glGetError() == GL_NO_ERROR
&& strstr(t
,"GL_EXT_texture_filter_anisotropic"))
97 opengl_features
.anisotropic
= 1;
98 glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT
, &opengl_features
.anisotropic_max
);
99 if (glGetError() == GL_NO_ERROR
)
100 opengl_features
.anisotropic_max
= 1.0;
103 if (!opengl_features
.anisotropic
)
106 if (opengl_features
.cfg_anisotropic
&& opengl_features
.cfg_mipmap
)
112 /* get the maximum anisotropic filtering value */
113 float opengl_max_anisotropic()
115 return opengl_features
.anisotropic_max
;
118 /* check for bilinear filtering support */
119 int opengl_has_bilinear()
121 return opengl_features
.cfg_bilinear
;
124 /* check for trilinear filtering support */
125 int opengl_has_trilinear()
127 return opengl_features
.cfg_trilinear
;
130 /* check for mipmap support */
131 int opengl_has_mipmap()
133 return opengl_features
.cfg_mipmap
;
136 /* check if particle effects are enabled */
137 int opengl_has_particles()
139 return opengl_features
.cfg_particles
;
142 /* check if backface culling is enabled */
143 int opengl_particles_max()
145 if (!opengl_has_particles())
147 return opengl_features
.cfg_particles_max
;
150 /* converts an opengl error enum into a string */
151 char* opengl_error_string(GLenum e
)
155 case GL_INVALID_ENUM
:
156 return "OpenGL: GL_INVALID_ENUM";
158 case GL_INVALID_VALUE
:
159 return "OpenGL: GL_INVALID_VALUE";
161 case GL_INVALID_OPERATION
:
162 return "OpenGL: GL_INVALID_OPERATION";
167 return "Unknown OpenGL Error";