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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
// Small app to display GL infos
#include <stdio.h>
#include <string.h>
#include <Application.h>
#include <Window.h>
#include <OutlineListView.h>
#include <ScrollView.h>
#include <GLView.h>
#include <String.h>
#include <GL/gl.h>
class GLInfoWindow : public BWindow
{
public:
GLInfoWindow(BRect frame);
virtual bool QuitRequested() { be_app->PostMessage(B_QUIT_REQUESTED); return true; }
private:
BGLView *gl;
BOutlineListView *list;
BScrollView *scroller;
};
class GLInfoApp : public BApplication
{
public:
GLInfoApp();
private:
GLInfoWindow *window;
};
GLInfoApp::GLInfoApp()
: BApplication("application/x-vnd.OBOS-GLInfo")
{
window = new GLInfoWindow(BRect(50, 50, 350, 350));
}
GLInfoWindow::GLInfoWindow(BRect frame)
: BWindow(frame, "OpenGL Info", B_TITLED_WINDOW, 0)
{
BRect r = Bounds();
char *s;
BString l;
// Add a outline list view
r.right -= B_V_SCROLL_BAR_WIDTH;
list = new BOutlineListView(r, "GLInfoList", B_SINGLE_SELECTION_LIST, B_FOLLOW_ALL_SIDES);
scroller = new BScrollView("GLInfoListScroller", list, B_FOLLOW_ALL_SIDES,
B_WILL_DRAW | B_FRAME_EVENTS, false, true);
gl = new BGLView(r, "opengl", B_FOLLOW_ALL_SIDES, 0, BGL_RGB | BGL_DOUBLE);
gl->Hide();
AddChild(gl);
AddChild(scroller);
Show();
LockLooper();
// gl->LockGL();
s = (char *) glGetString(GL_RENDERER);
if (!s)
goto error;
list->AddItem(new BStringItem(s));
s = (char *) glGetString(GL_VENDOR);
if (s) {
l = ""; l << "Vendor Name: " << s;
list->AddItem(new BStringItem(l.String(), 1));
}
s = (char *) glGetString(GL_VERSION);
if (s) {
l = ""; l << "Version: " << s;
list->AddItem(new BStringItem(l.String(), 1));
}
s = (char *) glGetString(GL_RENDERER);
if (s) {
l = ""; l << "Renderer Name: " << s;
list->AddItem(new BStringItem(l.String(), 1));
}
s = (char *) glGetString(GL_EXTENSIONS);
if (s) {
list->AddItem(new BStringItem("OpenGL Extensions", 1));
while (*s) {
char extname[255];
int n = strcspn(s, " ");
strncpy(extname, s, n);
extname[n] = 0;
list->AddItem(new BStringItem(extname, 2));
if (! s[n])
break;
s += (n + 1); // next !
}
}
// gl->UnlockGL();
error:
UnlockLooper();
}
int main(int argc, char *argv[])
{
GLInfoApp *app = new GLInfoApp;
app->Run();
delete app;
return 0;
}
|