From 50781cd3e87af0113596f3186dcd1cee570fe96b Mon Sep 17 00:00:00 2001 From: Nathan Heisey Date: Mon, 8 Aug 2011 17:00:38 +0000 Subject: [PATCH] Some video fixes --- src/video/bwindow/SDL_BWin.h | 11 ++++- src/video/bwindow/SDL_bframebuffer.cc | 13 ++++- src/video/bwindow/SDL_bopengl.cc | 71 +++++++++++++++++---------- 3 files changed, 68 insertions(+), 27 deletions(-) diff --git a/src/video/bwindow/SDL_BWin.h b/src/video/bwindow/SDL_BWin.h index a1afc86c9..3715033e5 100644 --- a/src/video/bwindow/SDL_BWin.h +++ b/src/video/bwindow/SDL_BWin.h @@ -156,7 +156,8 @@ class SDL_BWin:public BDirectWindow /* Determine if the pixel buffer is usable after this update */ _trash_window_buffer = _trash_window_buffer || ((info->buffer_state & B_BUFFER_RESIZED) - || (info->buffer_state & B_BUFFER_RESET)); + || (info->buffer_state & B_BUFFER_RESET) + || (info->driver_state == B_MODE_CHANGED)); LockBuffer(); switch(info->buffer_state & B_DIRECT_MODE_MASK) { @@ -193,7 +194,12 @@ class SDL_BWin:public BDirectWindow } #endif + + /* Call the base object directconnected */ + BDirectWindow::DirectConnected(info); + UnlockBuffer(); + } @@ -407,6 +413,9 @@ class SDL_BWin:public BDirectWindow bool BufferExists() { return _buffer_created; } bool BufferIsDirty() { return _buffer_dirty; } BBitmap *GetBitmap() { return _bitmap; } +#if SDL_VIDEO_OPENGL + BGLView *GetGLView() { return _SDL_GLView; } +#endif /* Setter methods */ void SetID(int32 id) { _id = id; } diff --git a/src/video/bwindow/SDL_bframebuffer.cc b/src/video/bwindow/SDL_bframebuffer.cc index 0ebeb7cbb..51a2772c7 100644 --- a/src/video/bwindow/SDL_bframebuffer.cc +++ b/src/video/bwindow/SDL_bframebuffer.cc @@ -62,12 +62,20 @@ int BE_CreateWindowFramebuffer(_THIS, SDL_Window * window, /* Create the new bitmap object */ BBitmap *bitmap = bwin->GetBitmap(); + if(bitmap) { delete bitmap; } bitmap = new BBitmap(bwin->Bounds(), (color_space)bmode.space, false, /* Views not accepted */ true); /* Contiguous memory required */ + + if(bitmap->InitCheck() != B_OK) { + SDL_SetError("Could not initialize back buffer!\n"); + return -1; + } + + bwin->SetBitmap(bitmap); /* Set the pixel pointer */ @@ -132,7 +140,7 @@ int32 BE_DrawThread(void *data) { int32 height = clips[i].bottom - clips[i].top + 1; bufferpx = bwin->GetBufferPx() + clips[i].top * bufferPitch + clips[i].left * BPP; - windowpx = (uint8*)bitmap->Bits(); + + windowpx = (uint8*)bitmap->Bits() + clips[i].top * windowPitch + clips[i].left * BPP - windowSub; @@ -143,11 +151,14 @@ int32 BE_DrawThread(void *data) { if(bwin->CanTrashWindowBuffer()) { goto escape; /* Break out before the buffer is killed */ } +// printf("memcpy(0x%x, 0x%x, %i) ", bufferpx, windowpx, width * BPP); memcpy(bufferpx, windowpx, width * BPP); bufferpx += bufferPitch; windowpx += windowPitch; } +// printf("\t-\t"); } +// printf("\n"); bwin->SetBufferDirty(false); escape: bwin->UnlockBuffer(); diff --git a/src/video/bwindow/SDL_bopengl.cc b/src/video/bwindow/SDL_bopengl.cc index 6fbc2682d..906e9542d 100644 --- a/src/video/bwindow/SDL_bopengl.cc +++ b/src/video/bwindow/SDL_bopengl.cc @@ -119,6 +119,52 @@ void *BE_GL_GetProcAddress(_THIS, const char *proc) } + + +void BE_GL_SwapWindow(_THIS, SDL_Window * window) { + _ToBeWin(window)->SwapBuffers(); +} + +int BE_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) { + _GetBeApp()->SetCurrentContext(((SDL_BWin*)context)->GetGLView()); + return 0; +} + + +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_RGB | BGL_DOUBLE); + return (SDL_GLContext)(bwin); +} + +void BE_GL_DeleteContext(_THIS, SDL_GLContext context) { + /* Currently, automatically unlocks the view */ + ((SDL_BWin*)context)->RemoveGLView(); +} + + +int BE_GL_SetSwapInterval(_THIS, int interval) { + printf(__FILE__": %d- swap interval set\n", __LINE__); + return 0; +} + +int BE_GL_GetSwapInterval(_THIS) { + printf(__FILE__": %d- swap interval requested\n", __LINE__); + return 0; +} + + +void BE_GL_UnloadLibrary(_THIS) { + printf(__FILE__": %d- Library unloaded\n", __LINE__); +} + + + + + + #if 0 /* Functions from 1.2 that do not appear to be used in 1.3 */ int BE_GL_GetAttribute(_THIS, SDL_GLattr attrib, int *value) @@ -182,38 +228,13 @@ void *BE_GL_GetProcAddress(_THIS, const char *proc) } #endif - void BE_GL_SwapWindow(_THIS, SDL_Window * window) { - _ToBeWin(window)->SwapBuffers(); - } -int BE_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) { - _GetBeApp()->SetCurrentContext((BGLView*)context); - return 0; -} -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 */ - return (SDL_GLContext)(_ToBeWin(window)->CreateGLView( - BGL_RGB | BGL_DOUBLE)); -} -void BE_GL_DeleteContext(_THIS, SDL_GLContext context) { - /* Currently, automatically unlocks the view */ -// _ToBeWin(window)->RemoveGLView(); FIXME: Need to get the bwindow somehow -} -int BE_GL_SetSwapInterval(_THIS, int interval) { -} -int BE_GL_GetSwapInterval(_THIS) { -} - - -void BE_GL_UnloadLibrary(_THIS) { -} #ifdef __cplusplus }