3 This file is part of libmspgl
4 Copyright © 2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
13 #include <msp/strings/utils.h>
14 #include "arb_shader_objects.h"
15 #include "arb_vertex_shader.h"
16 #include "ext_framebuffer_object.h"
18 #include "extension.h"
25 bool is_supported(const string &ext)
27 static set<string> extensions;
28 static bool init_done=false;
32 if(const char *gl_ext=reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS)))
34 vector<string> exts=split(gl_ext);
35 extensions.insert(exts.begin(), exts.end());
38 /* XXX Conceptually a bit weird place for this, but I couldn't really come up
39 with anything better that would still be transparent. */
40 if(extensions.count("GL_ARB_shader_objects"))
41 init_arb_shader_objects();
42 if(extensions.count("GL_ARB_vertex_shader"))
43 init_arb_vertex_shader();
44 if(extensions.count("GL_EXT_framebuffer_object"))
45 init_ext_framebuffer_object();
50 return extensions.count(ext);
53 void require_extension(const string &ext)
55 if(!is_supported(ext))
56 throw UnsupportedExtension(ext+" is not supported");
59 ExtFunc *get_proc_address(const string &name)
62 return glXGetProcAddressARB(reinterpret_cast<const GLubyte *>(name.c_str()));