Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Some video fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
antifinidictor committed Aug 8, 2011
1 parent cf38e91 commit 50781cd
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 27 deletions.
11 changes: 10 additions & 1 deletion src/video/bwindow/SDL_BWin.h
Expand Up @@ -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) {
Expand Down Expand Up @@ -193,7 +194,12 @@ class SDL_BWin:public BDirectWindow
}
#endif


/* Call the base object directconnected */
BDirectWindow::DirectConnected(info);

UnlockBuffer();

}


Expand Down Expand Up @@ -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; }
Expand Down
13 changes: 12 additions & 1 deletion src/video/bwindow/SDL_bframebuffer.cc
Expand Up @@ -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 */
Expand Down Expand Up @@ -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;

Expand All @@ -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();
Expand Down
71 changes: 46 additions & 25 deletions src/video/bwindow/SDL_bopengl.cc
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 50781cd

Please sign in to comment.