mbohun
10/25/2012 - 6:51 AM

OpenGL, libSDL, C++, list OpenGL extensions

OpenGL, libSDL, C++, list OpenGL extensions

#include <iostream>
#include <string>
#include <sstream>
#include <set>
#include <SDL.h>
#include <GL/gl.h>

using namespace std;

int main(int argc, char* argv[] )
{

    SDL_Surface* scr;
    const char* gl_ext_string;
    Uint32 sdl_init_flags =0;
    Uint32 video_mode_flags =0;

    sdl_init_flags = sdl_init_flags | SDL_INIT_VIDEO;
    SDL_Init(sdl_init_flags);

    video_mode_flags =video_mode_flags | SDL_OPENGL;
    scr =SDL_SetVideoMode(640, 480, 32, video_mode_flags );

    string ext_string(reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS ) ) );
    const string TOKEN(" ");

    bool done_flag =false;
    int from =0;

    set<string> result;

    do {

	int to =ext_string.find(TOKEN, from );
	if(to==string::npos)
	{
	    to =ext_string.size();
	    done_flag =true;
	}

	string sub =ext_string.substr(from, to-from ); //from + number of chars to read
	result.insert(sub);
	from =to+1;

    } while(!done_flag);

    cout << "vendor:" << glGetString(GL_VENDOR) << endl;
    cout << "renderer:" << glGetString(GL_RENDERER) << endl;
    cout << "version:" << glGetString(GL_VERSION) << endl;

    set<string>::const_iterator iter;
    iter =result.begin();
    while(iter!=result.end() ) {
      cout << *iter << endl;
      iter++;
    }

    GLint noab;
    glGetIntegerv(GL_AUX_BUFFERS, &noab );
    cout << "GL_AUX_BUFFERS:" << noab;

    SDL_Quit();
}