summaryrefslogtreecommitdiff
path: root/progs/beos/GLInfo.cpp
diff options
context:
space:
mode:
authorPhilippe Houdoin <phoudoin@freedesktop.org>2004-08-14 09:59:16 +0000
committerPhilippe Houdoin <phoudoin@freedesktop.org>2004-08-14 09:59:16 +0000
commitf17ddd4884cccdbd15e7a3bebaeec32de4b6658e (patch)
treeb75b1cb7ff651ca4e683c9c49a216dcea1d97535 /progs/beos/GLInfo.cpp
parent41ea1558786cade1c313cb86d6c50d8827b0a5f3 (diff)
Fix demo.cpp, which wasn't working as expected.
Add a GLInfo app, a graphical tool displaying GL Info as a treeview. Usefull to see which OpenGL renderer you use and which extension(s) is supported. Convert the Makefile to be $(TOP)/configs/default-based.
Diffstat (limited to 'progs/beos/GLInfo.cpp')
-rw-r--r--progs/beos/GLInfo.cpp122
1 files changed, 122 insertions, 0 deletions
diff --git a/progs/beos/GLInfo.cpp b/progs/beos/GLInfo.cpp
new file mode 100644
index 0000000000..b8788decd2
--- /dev/null
+++ b/progs/beos/GLInfo.cpp
@@ -0,0 +1,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;
+}