Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixes for OpenGL on Haiku.
testgl now passes when this patch is used.

This patch was originally from Urias McCullough (umccullough).
  • Loading branch information
icculus committed Aug 4, 2011
1 parent a46e427 commit 397599f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/video/bwindow/SDL_BWin.h
Expand Up @@ -112,7 +112,7 @@ class SDL_BWin : public BDirectWindow
if ( SDL_GLView == NULL ) {
SDL_GLView = new BGLView(Bounds(), "SDL GLView",
B_FOLLOW_ALL_SIDES, (B_WILL_DRAW|B_FRAME_EVENTS),
gl_flags);
gl_flags|BGL_DOUBLE);
SDL_GLView->EnableDirectMode(true);
}
if ( the_view != SDL_GLView ) {
Expand All @@ -133,17 +133,17 @@ class SDL_BWin : public BDirectWindow
}
if ( the_view != SDL_View ) {
if ( the_view ) {
#if SDL_VIDEO_OPENGL
if ( the_view == SDL_GLView ) {
SDL_GLView->UnlockGL();
}
#endif
RemoveChild(the_view);
}
AddChild(SDL_View);
the_view = SDL_View;
}
}
#if SDL_VIDEO_OPENGL
if ( the_view == SDL_GLView ) {
SDL_GLView->UnlockGL();
}
#endif
Unlock();
return(retval);
}
Expand Down Expand Up @@ -191,8 +191,8 @@ class SDL_BWin : public BDirectWindow
#if SDL_VIDEO_OPENGL
virtual void SwapBuffers(void) {
SDL_GLView->UnlockGL();
SDL_GLView->LockGL();
SDL_GLView->SwapBuffers();
SDL_GLView->LockGL();
}
#endif
virtual BView *View(void) {
Expand All @@ -215,6 +215,11 @@ class SDL_BWin : public BDirectWindow
the application should respond to the quit request,
or ignore it as desired.
*/
#if SDL_VIDEO_OPENGL
if ( SDL_GLView != NULL ) {
SDL_GLView->EnableDirectMode(false);
}
#endif
return(false);
}
return(true); /* Close the app window */
Expand Down
17 changes: 17 additions & 0 deletions src/video/bwindow/SDL_sysevents.cc
Expand Up @@ -36,6 +36,7 @@ extern "C" {
#include "../../events/SDL_sysevents.h"
#include "../../events/SDL_events_c.h"
#include "SDL_sysevents_c.h"
#include "../SDL_cursor_c.h"

void BE_PumpEvents(_THIS)
{
Expand Down Expand Up @@ -203,11 +204,21 @@ void SDL_BWin::DispatchMessage(BMessage *msg, BHandler *target)
if (transit == B_EXITED_VIEW) {
if ( SDL_GetAppState() & SDL_APPMOUSEFOCUS ) {
SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
#if SDL_VIDEO_OPENGL
// for some reason, SDL_EraseCursor fails for OpenGL
if (this->the_view != this->SDL_GLView)
#endif
SDL_EraseCursor(SDL_VideoSurface);
be_app->SetCursor(B_HAND_CURSOR);
}
} else {
if ( !(SDL_GetAppState() & SDL_APPMOUSEFOCUS) ) {
SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
#if SDL_VIDEO_OPENGL
// for some reason, SDL_EraseCursor fails for OpenGL
if (this->the_view != this->SDL_GLView)
#endif
SDL_EraseCursor(SDL_VideoSurface);
SDL_SetCursor(NULL);
}

Expand Down Expand Up @@ -395,4 +406,10 @@ void SDL_BWin::DirectConnected(direct_buffer_info *info) {
default:
break;
}
#if SDL_VIDEO_OPENGL
// If it is a BGLView, it is apparently required to
// call DirectConnected() on it as well
if (this->the_view == this->SDL_GLView)
this->SDL_GLView->DirectConnected(info);
#endif
}

0 comments on commit 397599f

Please sign in to comment.