From 5cf1b0b434baf6594f44f172c00f1721d6fcc190 Mon Sep 17 00:00:00 2001 From: Jerome Duval Date: Wed, 20 Aug 2014 16:50:24 +0000 Subject: updated Haiku patch diff --git a/src/glewinfo.c b/src/glewinfo.c index 882654d..e6e3456 100644 --- a/src/glewinfo.c +++ b/src/glewinfo.c @@ -16373,7 +16373,7 @@ int main (int argc, char** argv) #elif defined(GLEW_EGL) #elif defined(_WIN32) fprintf(f, "Reporting capabilities of pixelformat %d\n", params.pixelformat); -#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX) +#elif !defined(__APPLE__) && !defined(__HAIKU__) || defined(GLEW_APPLE_GLX) fprintf(f, "Reporting capabilities of display %s, visual 0x%x\n", params.display == NULL ? getenv("DISPLAY") : params.display, params.visual); #endif diff --git a/src/glewinfo_haiku.cpp b/src/glewinfo_haiku.cpp new file mode 100644 index 0000000..3d32d00 --- /dev/null +++ b/src/glewinfo_haiku.cpp @@ -0,0 +1,93 @@ +/* + * glewinfo Haiku glue code + * Copyright 2013 Kacper Kasper + * All rights reserved. Distributed under the terms of the MIT license. + */ + +#include +#include +#include + +class GLEWInfoView : public BGLView { +public: + GLEWInfoView(BRect frame, uint32 type); + virtual void AttachedToWindow(void); + + void ContextInit() { LockGL(); } + void ContextDestroy() { UnlockGL(); } +}; + +GLEWInfoView::GLEWInfoView(BRect frame, uint32 type) + : BGLView(frame, "GLEWInfoView", B_FOLLOW_ALL_SIDES, 0, type) +{ +} + +void GLEWInfoView::AttachedToWindow(void) +{ + LockGL(); + BGLView::AttachedToWindow(); + UnlockGL(); +} + +class GLEWInfoWindow : public BWindow { +public: + GLEWInfoWindow(BRect frame, uint32 type); + virtual bool QuitRequested(); + +private: + GLEWInfoView *view; +}; + +GLEWInfoWindow::GLEWInfoWindow(BRect frame, uint32 type) + : BWindow(frame, "GLEWInfoWindow", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE) +{ + AddChild(view = new GLEWInfoView(Bounds(), type)); + view->ContextInit(); +} + +bool GLEWInfoWindow::QuitRequested() +{ + view->ContextDestroy(); + + view->RemoveSelf(); + + delete view; + + return true; +} + +class GLEWInfoApp : public BApplication +{ +public: + GLEWInfoApp(); + ~GLEWInfoApp(); + +private: + GLEWInfoWindow *window; +}; + +GLEWInfoApp::GLEWInfoApp() + : BApplication("application/x-vnd.glew-GLEWInfo") +{ + BRect rect = BRect(0, 0, 1, 1); + window = new GLEWInfoWindow(rect, BGL_RGB | BGL_DOUBLE); +} + +GLEWInfoApp::~GLEWInfoApp() +{ + window->Quit(); +} + +GLEWInfoApp *app; + +extern "C" GLboolean glewCreateContext () +{ + app = new GLEWInfoApp(); + + return GL_FALSE; +} + +extern "C" void glewDestroyContext () +{ + delete app; +} -- 2.14.2