summaryrefslogtreecommitdiffstats
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
parent41ea1558786cade1c313cb86d6c50d8827b0a5f3 (diff)
downloadexternal_mesa3d-f17ddd4884cccdbd15e7a3bebaeec32de4b6658e.zip
external_mesa3d-f17ddd4884cccdbd15e7a3bebaeec32de4b6658e.tar.gz
external_mesa3d-f17ddd4884cccdbd15e7a3bebaeec32de4b6658e.tar.bz2
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.
-rw-r--r--progs/beos/GLInfo.cpp122
-rw-r--r--progs/beos/Makefile43
-rw-r--r--progs/beos/demo.cpp138
-rw-r--r--progs/beos/sample.cpp4
4 files changed, 207 insertions, 100 deletions
diff --git a/progs/beos/GLInfo.cpp b/progs/beos/GLInfo.cpp
new file mode 100644
index 0000000..b8788de
--- /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;
+}
diff --git a/progs/beos/Makefile b/progs/beos/Makefile
index 6fa6d8f..fae5416 100644
--- a/progs/beos/Makefile
+++ b/progs/beos/Makefile
@@ -1,42 +1,31 @@
-# $Id: Makefile,v 1.2 1999/09/17 00:55:21 brianp Exp $
+# progs/beos/Makefile
+
+TOP = ../..
+include $(TOP)/configs/current
# Makefile for BeOS demos
# Written by Brian Paul
# This file is in the public domain.
+#
+# Modified by Philippe Houdoin
+LDFLAGS += -soname=_APP_ $(APP_LIB_DEPS)
-
-CC = g++
-
-# Use Mesa:
-CFLAGS = -I../include -c -g
-LFLAGS = -L../lib -Xlinker -rpath ../lib -lbe -lGL
-
-# Use BeOS OpenGL:
-#CFLAGS = -I/boot/develop/headers/be/opengl -c -g
-#LFLAGS = -L../lib -Xlinker -rpath ../lib -lbe -lGL
-
-
-PROGRAMS = demo sample
-
-default: $(PROGRAMS)
-
+default: demo sample GLInfo
clean:
- rm -f demo sample
+ rm -f demo sample GLInfo
rm -f *.o
-
demo: demo.o
- $(CC) demo.o $(LFLAGS) -o $@
-
-demo.o: demo.cpp
- $(CC) $(CFLAGS) demo.cpp
-
+ $(LD) demo.o $(LDFLAGS) -o $@
sample: sample.o
- $(CC) sample.o $(LFLAGS) -o $@
+ $(LD) sample.o $(LDFLAGS) -o $@
+
+GTLInfo: GLInfo.o
+ $(LD) GLInfo.o $(LDFLAGS) -o $@
-sample.o: sample.cpp
- $(CC) $(CFLAGS) sample.cpp
+.cpp.o:
+ $(CC) -c $< $(CFLAGS) -o $@
diff --git a/progs/beos/demo.cpp b/progs/beos/demo.cpp
index c25eb93..6b0b957 100644
--- a/progs/beos/demo.cpp
+++ b/progs/beos/demo.cpp
@@ -1,7 +1,8 @@
-// $Id: demo.cpp,v 1.1 1999/08/19 00:55:40 jtg Exp $
+// $Id: demo.cpp,v 1.2 2004/08/14 09:59:16 phoudoin Exp $
// Simple BeOS GLView demo
// Written by Brian Paul
+// Changes by Philippe Houdoin
// This file is in the public domain.
@@ -11,19 +12,40 @@
#include <Window.h>
#include <GLView.h>
+class MyGL : public BGLView
+{
+public:
+ MyGL(BRect rect, char *name, ulong options);
+
+ virtual void AttachedToWindow();
+ virtual void Pulse();
+ virtual void FrameResized(float w, float h);
+
+private:
+ void Render();
+ void Reshape(float w, float h);
+ float mAngle;
+};
+
class MyWindow : public BWindow
{
public:
- MyWindow(BRect frame);
- virtual bool QuitRequested();
+ MyWindow(BRect frame);
+ virtual bool QuitRequested();
};
MyWindow::MyWindow(BRect frame)
: BWindow(frame, "demo", B_TITLED_WINDOW, B_NOT_ZOOMABLE)
{
- // no-op
+ // Make OpenGL view and put it in the window
+ BRect r = Bounds();
+ r.InsetBy(5, 5);
+
+ MyGL *gl = new MyGL(r, "GL", BGL_RGB | BGL_DOUBLE);
+ AddChild(gl);
+ SetPulseRate(1000000 / 30);
}
bool MyWindow::QuitRequested()
@@ -33,119 +55,91 @@ bool MyWindow::QuitRequested()
}
-class MyGL : public BGLView
-{
-public:
- MyGL(BRect rect, char *name, ulong options);
-
-// virtual void AttachedToWindow();
- virtual void Draw(BRect updateRect);
- virtual void Pulse();
- virtual void FrameResized(float w, float h);
-private:
- float mAngle;
-};
-
MyGL::MyGL(BRect rect, char *name, ulong options)
- : BGLView(rect, name, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP_BOTTOM, 0, options)
+ : BGLView(rect, name, B_FOLLOW_ALL_SIDES, B_PULSE_NEEDED, options)
{
- mAngle = 0.0;
+ mAngle = 0.0;
}
-#if 0
void MyGL::AttachedToWindow()
{
- BGLView::AttachedToWindow();
- LockGL();
- glClearColor(.7, .7, 0, 0);
- UnlockGL();
+ BGLView::AttachedToWindow();
+
+ LockGL();
+ glClearColor(0.7, 0.7, 0, 0);
+ Reshape(Bounds().Width(), Bounds().Height());
+ UnlockGL();
}
-#endif
void MyGL::FrameResized(float w, float h)
{
- BGLView::FrameResized(w, h);
+ BGLView::FrameResized(w, h);
- printf("FrameResized\n");
- LockGL();
- BGLView::FrameResized(w,h);
- glViewport(0, 0, (int) (w + 1), (int) (h + 1));
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glFrustum(-1, 1, -1, 1, 10, 30);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- glTranslatef(0, 0, -18);
- UnlockGL();
+ LockGL();
+ Reshape(w, h);
+ UnlockGL();
+
+ Render();
}
+void MyGL::Pulse()
+{
+ mAngle += 1.0;
+ Render();
+}
+
-void MyGL::Draw(BRect r)
+void MyGL::Render()
{
- printf("MyGL::Draw\n");
- BGLView::Draw(r);
LockGL();
+
glClear(GL_COLOR_BUFFER_BIT);
+
glPushMatrix();
- glRotatef(mAngle, 0, 0, 1);
+
+ glRotated(mAngle, 0, 0, 1);
glColor3f(0, 0, 1);
+
glBegin(GL_POLYGON);
glVertex2f(-1, -1);
glVertex2f( 1, -1);
glVertex2f( 1, 1);
glVertex2f(-1, 1);
glEnd();
+
+ glPopMatrix();
+
SwapBuffers();
+
UnlockGL();
}
-void MyGL::Pulse()
+void MyGL::Reshape(float w, float h)
{
- printf("pulse\n");
- BGLView::Pulse();
- mAngle += 1.0;
-
- LockGL();
- glClear(GL_COLOR_BUFFER_BIT);
- glPushMatrix();
- glRotatef(mAngle, 0, 0, 1);
- glColor3f(0, 0, 1);
- glBegin(GL_POLYGON);
- glVertex2f(-1, -1);
- glVertex2f( 1, -1);
- glVertex2f( 1, 1);
- glVertex2f(-1, 1);
- glEnd();
- SwapBuffers();
- UnlockGL();
+ glViewport(0, 0, (int) (w + 1), (int) (h + 1));
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glFrustum(-1, 1, -1, 1, 10, 30);
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ glTranslatef(0, 0, -18);
}
-
int main(int argc, char *argv[])
{
BApplication *app = new BApplication("application/demo");
// make top-level window
- int x = 500, y = 500;
- int w = 400, h = 400;
- MyWindow *win = new MyWindow(BRect(x, y, x + w, y + h));
- // win->Lock();
- // win->Unlock();
+ MyWindow *win = new MyWindow(BRect(100, 100, 500, 500));
win->Show();
- // Make OpenGL view and put it in the window
- MyGL *gl = new MyGL(BRect(5, 5, w-10, h-10), "GL", BGL_RGB | BGL_DOUBLE);
- // MyGL *gl = new MyGL(BRect(5, 5, w-10, h-10), "GL", BGL_RGB );
- win->AddChild(gl);
-
- printf("calling app->Run\n");
- app->Run();
+ app->Run();
delete app;
diff --git a/progs/beos/sample.cpp b/progs/beos/sample.cpp
index 7b8515b..a86a118 100644
--- a/progs/beos/sample.cpp
+++ b/progs/beos/sample.cpp
@@ -92,8 +92,10 @@ void SampleGLView::AttachedToWindow(void)
void SampleGLView::FrameResized(float newWidth, float newHeight)
{
+ BGLView::FrameResized(newWidth, newHeight);
+
LockGL();
- BGLView::FrameResized(width, height);
+
width = newWidth;
height = newHeight;