#include "image.hpp"
#include "json.hpp"
#include "glproc.hpp"
+#include "glws.hpp"
#include "glsize.hpp"
#include "glstate.hpp"
#include "glstate_internal.hpp"
memset(this, 0, sizeof *this);
const char *version = (const char *)glGetString(GL_VERSION);
+ unsigned version_major = 0;
+ unsigned version_minor = 0;
+ unsigned version_release = 0;
if (version) {
if (version[0] == 'O' &&
version[1] == 'p' &&
(version[9] == ' ' || version[9] == '-')) {
ES = true;
}
+ if (version[0] >= '0' && version[0] <= '9') {
+ sscanf(version, "%u.%u.%u", &version_major, &version_minor, &version_release);
+ }
}
ARB_draw_buffers = !ES;
- // TODO: Check extensions we use below
+ // Check extensions we use.
+
+ if (!ES) {
+ if (version_major > 3 ||
+ (version_major == 3 && version_minor >= 2)) {
+ GLint num_extensions = 0;
+ glGetIntegerv(GL_NUM_EXTENSIONS, &num_extensions);
+ for (GLint i = 0; i < num_extensions; ++i) {
+ const char *extension = (const char *)glGetStringi(GL_EXTENSIONS, i);
+ if (extension &&
+ strcmp(extension, "ARB_sampler_objects")) {
+ ARB_sampler_objects = true;
+ }
+ }
+ } else {
+ const char *extensions = (const char *)glGetString(GL_EXTENSIONS);
+ if (glws::checkExtension("ARB_sampler_objects", extensions)) {
+ ARB_sampler_objects = true;
+ }
+ }
+ }
}
void
print
def dump_sampler_params(self):
- # Avoid crash on MacOSX
- # XXX: The right fix would be to look at the support extensions..
- import platform
- if platform.system() == 'Darwin':
- return
-
print ' // GL_SAMPLER_BINDING'
- print ' flushErrors();'
- print ' GLint sampler_binding = 0;'
- print ' glGetIntegerv(GL_SAMPLER_BINDING, &sampler_binding);'
- print ' if (glGetError() != GL_NO_ERROR) {'
- print ' flushErrors();'
- print ' } else {'
+ print ' if (context.ARB_sampler_objects) {'
+ print ' GLint sampler_binding = 0;'
+ print ' glGetIntegerv(GL_SAMPLER_BINDING, &sampler_binding);'
print ' json.beginMember("GL_SAMPLER_BINDING");'
print ' json.writeInt(sampler_binding);'
print ' json.endMember();'
print ' json.beginObject();'
for _, _, name in glGetSamplerParameter.iter():
self.dump_atom(glGetSamplerParameter, 'sampler_binding', name)
- print ' json.endObject();'
- print ' json.endMember(); // GL_SAMPLER'
- print ' }'
+ print ' json.endObject();'
+ print ' json.endMember(); // GL_SAMPLER'
+ print ' }'
print ' }'
def texenv_param_target(self, name):
def dump_atom(self, getter, *args):
name = args[-1]
- # Avoid crash on MacOSX
- # XXX: The right fix would be to look at the support extensions..
- import platform
- if name == 'GL_SAMPLER_BINDING' and platform.system() == 'Darwin':
- return
-
print ' // %s' % name
print ' {'
print ' flushErrors();'