[openbeos] Tracker bug and screen saver question
- From: Fredrik Ekdahl <fekdahl@xxxxxxxxx>
- To: openbeos@xxxxxxxxxxxxx
- Date: Wed, 17 Jan 2007 19:51:16 +0100
Since trac is unavailable at the moment I'll report the bug here
instead. As can be seen in the attached image, dragging files from
"Screen Savers" under /boot/home/ to the equivalent folder under
/boot/beos/ makes Tracker think that I'm trying to move the mime settings.
On to the screen saver question. My problem is that every screen saver I
write that uses OpenGL crashes.. :) I don't know if I'm doing anything
wrong or if there is a bug outside of my screen savers. I've attached a
small example saver. Can anyone spot any obvious errors? Should be
possible to temporarily replace the screen saver "Haiku" with this
source file and just make sure it links against libGL.so. All crashes
happens when exiting the savers, either by selecting another in
preferences or by moving the mouse to exit the test mode.
/Fredrik Ekdahl

#include <GL/gl.h>
#include <GLView.h>
#include <ScreenSaver.h>
#include <StringView.h>
#include <View.h>
class ScreenSaver : public BScreenSaver
{
public:
ScreenSaver(BMessage *archive, image_id id)
: BScreenSaver(archive, id) {};
~ScreenSaver();
void Draw(BView *view, int32 frame);
void StartConfig(BView *view);
status_t StartSaver(BView *view, bool preview);
private:
BGLView *fGLView;
};
BScreenSaver *instantiate_screen_saver(BMessage *msg, image_id image)
{
return new ScreenSaver(msg, image);
}
void
ScreenSaver::StartConfig(BView *view)
{
view->AddChild(new BStringView(BRect(20, 10, 200, 35), "", "OpenGL
screen saver test"));
}
status_t
ScreenSaver::StartSaver(BView *view, bool preview)
{
// set redraw delay in microseconds
SetTickSize(1000);
fGLView = new BGLView(view->Bounds(), "GLView", B_FOLLOW_ALL_SIDES, 0,
BGL_DOUBLE | BGL_DEPTH);
fGLView->LockGL();
glViewport(0, 0, (GLsizei)view->Bounds().Width(),
(GLsizei)view->Bounds().Height());
fGLView->UnlockGL();
view->AddChild(fGLView);
return B_OK;
}
ScreenSaver::~ScreenSaver()
{
delete fGLView;
}
void
ScreenSaver::Draw(BView *view, int32 frame)
{
fGLView->LockGL();
// set the background color to purple
glClearColor(1.0f, 0.0f, 1.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
// rotate the square round the z axis
glRotatef((float)frame/5.0f, 0.0f, 0.0f, 1.0f);
// draw the square
glBegin(GL_QUADS);
glColor3f(1.0f, 0.0f, 0.0f); glVertex2f(-0.6f, 0.8f);
glColor3f(1.0f, 1.0f, 0.0f); glVertex2f( 0.6f, 0.8f);
glColor3f(0.0f, 1.0f, 0.0f); glVertex2f( 0.6f, -0.8f);
glColor3f(0.0f, 0.0f, 1.0f); glVertex2f(-0.6f, -0.8f);
glEnd();
fGLView->UnlockGL();
fGLView->SwapBuffers();
}
Other related posts: