Commit 90488d6c29d1895521cf5bb1cebb58f2dff5b0eb

Philipp Wiesemann 2017-06-17T22:30:28

haiku: Added support for some values set with SDL_GL_SetAttribute().

diff --git a/src/video/haiku/SDL_BWin.h b/src/video/haiku/SDL_BWin.h
index 2b15703..17fd253 100644
--- a/src/video/haiku/SDL_BWin.h
+++ b/src/video/haiku/SDL_BWin.h
@@ -72,6 +72,7 @@ class SDL_BWin:public BDirectWindow
 
 #if SDL_VIDEO_OPENGL
         _SDL_GLView = NULL;
+        _gl_type = 0;
 #endif
         _shown = false;
         _inhibit_resize = false;
@@ -133,6 +134,7 @@ class SDL_BWin:public BDirectWindow
                                      B_FOLLOW_ALL_SIDES,
                                      (B_WILL_DRAW | B_FRAME_EVENTS),
                                      gl_flags);
+            _gl_type = gl_flags;
         }
         AddChild(_SDL_GLView);
         _SDL_GLView->EnableDirectMode(true);
@@ -443,6 +445,7 @@ class SDL_BWin:public BDirectWindow
     BBitmap *GetBitmap() { return _bitmap; }
 #if SDL_VIDEO_OPENGL
     BGLView *GetGLView() { return _SDL_GLView; }
+    Uint32 GetGLType() { return _gl_type; }
 #endif
 
     /* Setter methods */
@@ -625,6 +628,7 @@ private:
     /* Members */
 #if SDL_VIDEO_OPENGL
     BGLView * _SDL_GLView;
+    Uint32 _gl_type;
 #endif
 
     int32 _last_buttons;
diff --git a/src/video/haiku/SDL_bopengl.cc b/src/video/haiku/SDL_bopengl.cc
index 3a5cb91..b2a53fe 100644
--- a/src/video/haiku/SDL_bopengl.cc
+++ b/src/video/haiku/SDL_bopengl.cc
@@ -35,8 +35,6 @@ extern "C" {
 #endif
 
 
-#define BGL_FLAGS BGL_RGB | BGL_DOUBLE
-
 static SDL_INLINE SDL_BWin *_ToBeWin(SDL_Window *window) {
     return ((SDL_BWin*)(window->driverdata));
 }
@@ -104,7 +102,28 @@ SDL_GLContext BE_GL_CreateContext(_THIS, SDL_Window * window) {
     /* FIXME: Not sure what flags should be included here; may want to have
        most of them */
     SDL_BWin *bwin = _ToBeWin(window);
-    bwin->CreateGLView(BGL_FLAGS);
+    Uint32 gl_flags = BGL_RGB;
+    if (_this->gl_config.alpha_size) {
+        gl_flags |= BGL_ALPHA;
+    }
+    if (_this->gl_config.depth_size) {
+        gl_flags |= BGL_DEPTH;
+    }
+    if (_this->gl_config.stencil_size) {
+        gl_flags |= BGL_STENCIL;
+    }
+    if (_this->gl_config.double_buffer) {
+        gl_flags |= BGL_DOUBLE;
+    } else {
+        gl_flags |= BGL_SINGLE;
+    }
+    if (_this->gl_config.accum_red_size ||
+            _this->gl_config.accum_green_size ||
+            _this->gl_config.accum_blue_size ||
+            _this->gl_config.accum_alpha_size) {
+        gl_flags |= BGL_ACCUM;
+    }
+    bwin->CreateGLView(gl_flags);
     return (SDL_GLContext)(bwin);
 }
 
@@ -140,7 +159,7 @@ void BE_GL_RebootContexts(_THIS) {
         if(bwin->GetGLView()) {
             bwin->LockLooper();
             bwin->RemoveGLView();
-            bwin->CreateGLView(BGL_FLAGS);
+            bwin->CreateGLView(bwin->GetGLType());
             bwin->UnlockLooper();
         }
         window = window->next;