summaryrefslogtreecommitdiffstats
path: root/debian/fireflies/fireflies-2.08/libgfx/tests/t-glext.cxx
blob: 82b400005e6183992d44829c94d5dc1ae644ebb2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/************************************************************************

  Test the availability of various OpenGL extensions

  by Michael Garland, 2001.
  
  $Id: t-glext.cxx 426 2004-09-27 04:34:55Z garland $

 ************************************************************************/

#include <gfx/gui.h>
#include <gfx/glext.h>
#include <string>
#include <fstream>

using namespace std;

class GUI : public MxGUI
{
public:

    virtual void setup_for_drawing();
};

GUI gui;

static void dump_string(ostream &out, const string& str)
{
    const char *ws = " \t\n\r";
    string::size_type start, end;

    start = 0;
    end = str.find_first_of(ws, start);

    while( end!=string::npos )
    {
	out << "    " << str.substr(start, end-start) << endl;
	start = str.find_first_not_of(ws, end);
	end = str.find_first_of(ws, start);
    }
}

void GUI::setup_for_drawing()
{
    ofstream log("glext.txt");

    string gl_extensions = (char *)glGetString(GL_EXTENSIONS);
    
    log << "OpenGL extensions" << endl
	<< "-----------------" << endl;
    dump_string(log, gl_extensions);
    log << endl << endl;


#ifdef HAVE_GL_WGLEXT_H
    PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB =
	(PFNWGLGETEXTENSIONSSTRINGARBPROC)
	wglGetProcAddress("wglGetExtensionsStringARB");

    if( !wglGetExtensionsStringARB )
    {
	log << "Couldn't find wglGetExtensionsStringARB." << endl;
	exit(-1);
    }
    else
    {
	string wgl_extensions = wglGetExtensionsStringARB(wglGetCurrentDC());

	log << "WGL extensions" << endl
	    << "--------------" << endl;
	dump_string(log, wgl_extensions);
    }
#endif

    exit(0);
}

int main(int argc, char **argv)
{
    gui.initialize(argc, argv);
    return gui.run();
}