1 // Small app to display GL infos
6 #include <Application.h>
8 #include <OutlineListView.h>
9 #include <ScrollView.h>
23 class GLInfoWindow
: public BWindow
26 GLInfoWindow(BRect frame
);
27 virtual bool QuitRequested() { be_app
->PostMessage(B_QUIT_REQUESTED
); return true; }
31 BOutlineListView
*list
;
32 BScrollView
*scroller
;
36 class GLInfoApp
: public BApplication
45 GLInfoApp::GLInfoApp()
46 : BApplication("application/x-vnd.OBOS-GLInfo")
48 window
= new GLInfoWindow(BRect(50, 50, 350, 350));
51 GLInfoWindow::GLInfoWindow(BRect frame
)
52 : BWindow(frame
, "OpenGL Info", B_TITLED_WINDOW
, 0)
58 // Add a outline list view
59 r
.right
-= B_V_SCROLL_BAR_WIDTH
;
60 list
= new BOutlineListView(r
, "GLInfoList", B_SINGLE_SELECTION_LIST
, B_FOLLOW_ALL_SIDES
);
61 scroller
= new BScrollView("GLInfoListScroller", list
, B_FOLLOW_ALL_SIDES
,
62 B_WILL_DRAW
| B_FRAME_EVENTS
, false, true);
64 gl
= new BGLView(r
, "opengl", B_FOLLOW_ALL_SIDES
, 0, BGL_RGB
| BGL_DOUBLE
);
75 list
->AddItem(new BStringItem("OpenGL", 0));
77 s
= (char *) glGetString(GL_VENDOR
);
79 l
= ""; l
<< "Vendor Name: " << s
;
80 list
->AddItem(new BStringItem(l
.String(), 1));
83 s
= (char *) glGetString(GL_VERSION
);
85 l
= ""; l
<< "Version: " << s
;
86 list
->AddItem(new BStringItem(l
.String(), 1));
89 s
= (char *) glGetString(GL_RENDERER
);
91 l
= ""; l
<< "Renderer Name: " << s
;
92 list
->AddItem(new BStringItem(l
.String(), 1));
95 s
= (char *) glGetString(GL_EXTENSIONS
);
97 list
->AddItem(new BStringItem("Extensions", 1));
100 int n
= strcspn(s
, " ");
101 strncpy(extname
, s
, n
);
103 list
->AddItem(new BStringItem(extname
, 2));
106 s
+= (n
+ 1); // next !
110 list
->AddItem(new BStringItem("GLU", 0));
111 s
= (char *) gluGetString(GLU_VERSION
);
113 l
= ""; l
<< "Version: " << s
;
114 list
->AddItem(new BStringItem(l
.String(), 1));
117 s
= (char *) gluGetString(GLU_EXTENSIONS
);
119 list
->AddItem(new BStringItem("Extensions", 1));
122 int n
= strcspn(s
, " ");
123 strncpy(extname
, s
, n
);
125 list
->AddItem(new BStringItem(extname
, 2));
128 s
+= (n
+ 1); // next !
133 list
->AddItem(new BStringItem("GLUT", 0));
134 l
= "API version: "; l
<< GLUT_API_VERSION
;
135 list
->AddItem(new BStringItem(l
.String(), 1));
145 int main(int argc
, char *argv
[])
147 GLInfoApp
*app
= new GLInfoApp
;