Some video fixes
authorNathan Heisey <nathanheisey@gmail.com>
Mon, 08 Aug 2011 17:00:38 +0000
changeset 593401531d8d1e01
parent 5933 5f8a7ebc88e5
child 5935 d52ded852194
Some video fixes
src/video/bwindow/SDL_BWin.h
src/video/bwindow/SDL_bframebuffer.cc
src/video/bwindow/SDL_bopengl.cc
     1.1 --- a/src/video/bwindow/SDL_BWin.h	Wed Aug 03 06:22:33 2011 +0000
     1.2 +++ b/src/video/bwindow/SDL_BWin.h	Mon Aug 08 17:00:38 2011 +0000
     1.3 @@ -156,7 +156,8 @@
     1.4  		/* Determine if the pixel buffer is usable after this update */
     1.5  		_trash_window_buffer =		_trash_window_buffer
     1.6  								|| ((info->buffer_state & B_BUFFER_RESIZED)
     1.7 -    							|| (info->buffer_state & B_BUFFER_RESET));
     1.8 +    							|| (info->buffer_state & B_BUFFER_RESET)
     1.9 +    							|| (info->driver_state == B_MODE_CHANGED));
    1.10      	LockBuffer();
    1.11  
    1.12      	switch(info->buffer_state & B_DIRECT_MODE_MASK) {
    1.13 @@ -193,7 +194,12 @@
    1.14  		}
    1.15  #endif
    1.16      	
    1.17 +    	
    1.18 +    	/* Call the base object directconnected */
    1.19 +    	BDirectWindow::DirectConnected(info);
    1.20 +    	
    1.21      	UnlockBuffer();
    1.22 +    	
    1.23      }
    1.24      
    1.25      
    1.26 @@ -407,6 +413,9 @@
    1.27  	bool BufferExists() { return _buffer_created; }
    1.28  	bool BufferIsDirty() { return _buffer_dirty; }
    1.29  	BBitmap *GetBitmap() { return _bitmap; }
    1.30 +#if SDL_VIDEO_OPENGL
    1.31 +	BGLView *GetGLView() { return _SDL_GLView; }
    1.32 +#endif
    1.33  	
    1.34  	/* Setter methods */
    1.35  	void SetID(int32 id) { _id = id; }
     2.1 --- a/src/video/bwindow/SDL_bframebuffer.cc	Wed Aug 03 06:22:33 2011 +0000
     2.2 +++ b/src/video/bwindow/SDL_bframebuffer.cc	Mon Aug 08 17:00:38 2011 +0000
     2.3 @@ -62,12 +62,20 @@
     2.4  
     2.5  	/* Create the new bitmap object */
     2.6  	BBitmap *bitmap = bwin->GetBitmap();
     2.7 +
     2.8  	if(bitmap) {
     2.9  		delete bitmap;
    2.10  	}
    2.11  	bitmap = new BBitmap(bwin->Bounds(), (color_space)bmode.space,
    2.12  			false,	/* Views not accepted */
    2.13  			true);	/* Contiguous memory required */
    2.14 +			
    2.15 +	if(bitmap->InitCheck() != B_OK) {
    2.16 +		SDL_SetError("Could not initialize back buffer!\n");
    2.17 +		return -1;
    2.18 +	}
    2.19 +
    2.20 +
    2.21  	bwin->SetBitmap(bitmap);
    2.22  	
    2.23  	/* Set the pixel pointer */
    2.24 @@ -132,7 +140,7 @@
    2.25  				int32 height = clips[i].bottom - clips[i].top + 1;
    2.26  				bufferpx = bwin->GetBufferPx() + 
    2.27  					clips[i].top * bufferPitch + clips[i].left * BPP;
    2.28 -				windowpx = (uint8*)bitmap->Bits(); + 
    2.29 +				windowpx = (uint8*)bitmap->Bits() + 
    2.30  					clips[i].top * windowPitch + clips[i].left * BPP -
    2.31  					windowSub;
    2.32  
    2.33 @@ -143,11 +151,14 @@
    2.34  					if(bwin->CanTrashWindowBuffer()) {
    2.35  						goto escape;	/* Break out before the buffer is killed */
    2.36  					}
    2.37 +//					printf("memcpy(0x%x, 0x%x, %i) ", bufferpx, windowpx, width * BPP);
    2.38  					memcpy(bufferpx, windowpx, width * BPP);
    2.39  					bufferpx += bufferPitch;
    2.40  					windowpx += windowPitch;
    2.41  				}
    2.42 +//				printf("\t-\t");
    2.43  			}
    2.44 +//			printf("\n");
    2.45  			bwin->SetBufferDirty(false);
    2.46  escape:
    2.47  			bwin->UnlockBuffer();
     3.1 --- a/src/video/bwindow/SDL_bopengl.cc	Wed Aug 03 06:22:33 2011 +0000
     3.2 +++ b/src/video/bwindow/SDL_bopengl.cc	Mon Aug 08 17:00:38 2011 +0000
     3.3 @@ -119,6 +119,52 @@
     3.4  }
     3.5  
     3.6  
     3.7 +
     3.8 +
     3.9 +void BE_GL_SwapWindow(_THIS, SDL_Window * window) {
    3.10 +    _ToBeWin(window)->SwapBuffers();
    3.11 +}
    3.12 +
    3.13 +int BE_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) {
    3.14 +	_GetBeApp()->SetCurrentContext(((SDL_BWin*)context)->GetGLView());
    3.15 +	return 0;
    3.16 +}
    3.17 +
    3.18 +
    3.19 +SDL_GLContext BE_GL_CreateContext(_THIS, SDL_Window * window) {
    3.20 +	/* FIXME: Not sure what flags should be included here; may want to have
    3.21 +	   most of them */
    3.22 +	SDL_BWin *bwin = _ToBeWin(window);
    3.23 +	bwin->CreateGLView(BGL_RGB | BGL_DOUBLE);
    3.24 +	return (SDL_GLContext)(bwin);
    3.25 +}
    3.26 +
    3.27 +void BE_GL_DeleteContext(_THIS, SDL_GLContext context) {
    3.28 +	/* Currently, automatically unlocks the view */
    3.29 +	((SDL_BWin*)context)->RemoveGLView();
    3.30 +}
    3.31 +
    3.32 +
    3.33 +int BE_GL_SetSwapInterval(_THIS, int interval) {
    3.34 +	printf(__FILE__": %d- swap interval set\n", __LINE__);
    3.35 +	return 0;
    3.36 +}
    3.37 +
    3.38 +int BE_GL_GetSwapInterval(_THIS) {
    3.39 +	printf(__FILE__": %d- swap interval requested\n", __LINE__);
    3.40 +	return 0;
    3.41 +}
    3.42 +
    3.43 +
    3.44 +void BE_GL_UnloadLibrary(_THIS) {
    3.45 +	printf(__FILE__": %d- Library unloaded\n", __LINE__);
    3.46 +}
    3.47 +
    3.48 +
    3.49 +
    3.50 +
    3.51 +
    3.52 +
    3.53  #if 0 /* Functions from 1.2 that do not appear to be used in 1.3 */
    3.54  
    3.55      int BE_GL_GetAttribute(_THIS, SDL_GLattr attrib, int *value)
    3.56 @@ -182,38 +228,13 @@
    3.57      }
    3.58  
    3.59  #endif
    3.60 -    void BE_GL_SwapWindow(_THIS, SDL_Window * window) {
    3.61 -        _ToBeWin(window)->SwapBuffers();
    3.62 -    }
    3.63  
    3.64 -int BE_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) {
    3.65 -	_GetBeApp()->SetCurrentContext((BGLView*)context);
    3.66 -	return 0;
    3.67 -}
    3.68  
    3.69  
    3.70 -SDL_GLContext BE_GL_CreateContext(_THIS, SDL_Window * window) {
    3.71 -	/* FIXME: Not sure what flags should be included here; may want to have
    3.72 -	   most of them */
    3.73 -	return (SDL_GLContext)(_ToBeWin(window)->CreateGLView(
    3.74 -		BGL_RGB | BGL_DOUBLE));
    3.75 -}
    3.76  
    3.77 -void BE_GL_DeleteContext(_THIS, SDL_GLContext context) {
    3.78 -	/* Currently, automatically unlocks the view */
    3.79 -//	_ToBeWin(window)->RemoveGLView();	FIXME: Need to get the bwindow somehow
    3.80 -}
    3.81  
    3.82  
    3.83 -int BE_GL_SetSwapInterval(_THIS, int interval) {
    3.84 -}
    3.85  
    3.86 -int BE_GL_GetSwapInterval(_THIS) {
    3.87 -}
    3.88 -
    3.89 -
    3.90 -void BE_GL_UnloadLibrary(_THIS) {
    3.91 -}
    3.92  
    3.93  #ifdef __cplusplus
    3.94  }