⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sdl_sysvideo.cc

📁 SDL库 在进行视频显示程序spcaview安装时必须的库文件
💻 CC
📖 第 1 页 / 共 2 页
字号:
		bpp = screen->format->BitsPerPixel;		bscreen.GetMode(&mode);		if ( (bpp != ColorSpaceToBitsPerPixel(mode.space)) ||		     (width != mode.virtual_width) ||		     (height != mode.virtual_height)) {			if(BE_FindClosestFSMode(_this, width, height, bpp, &mode)) {				bscreen.SetMode(&mode);				/* This simply stops the next resize event from being				 * sent to the SDL handler.				 */				SDL_Win->InhibitResize();			} else {				fullscreen = 0;				SDL_Win->SetFullScreen(fullscreen);			}		}	}	if ( was_fullscreen && ! fullscreen ) {		bscreen.SetMode(&saved_mode);	}	if ( SDL_Win->Lock() ) {		int cx, cy;		if ( SDL_Win->Shown() ) {			needs_unlock = 1;			SDL_Win->Hide();		} else {			needs_unlock = 0;		}		/* This resizes the window and view area, but inhibits resizing		 * of the BBitmap due to the InhibitResize call above. Thus the		 * bitmap (pixel data) never changes.		 */		SDL_Win->ResizeTo(width, height);		bounds = bscreen.Frame();		/* Calculate offsets - used either to center window		 * (windowed mode) or to set drawing offsets (fullscreen mode)		 */		cx = (bounds.IntegerWidth() - width)/2;		cy = (bounds.IntegerHeight() - height)/2;		if ( fullscreen ) {			/* Set offset for drawing */			SDL_Win->SetXYOffset(cx, cy);		} else {			SDL_Win->SetXYOffset(0, 0);		}		if ( ! needs_unlock || was_fullscreen ) {			/* Center the window the first time */			SDL_Win->MoveTo(cx, cy);		}		SDL_Win->Show();				/* Unlock the window manually after the first Show() */		if ( needs_unlock ) {			SDL_Win->Unlock();		}	}	/* Set the fullscreen flag in the screen surface */	if ( fullscreen ) {		screen->flags |= SDL_FULLSCREEN;	} else {		screen->flags &= ~SDL_FULLSCREEN; 	}	return(1);}static int BE_ToggleFullScreen(_THIS, int fullscreen){	return BE_SetFullScreen(_this, _this->screen, fullscreen);}/* FIXME: check return values and cleanup here */SDL_Surface *BE_SetVideoMode(_THIS, SDL_Surface *current,				int width, int height, int bpp, Uint32 flags){	BScreen bscreen;	BBitmap *bbitmap;	BRect bounds;	Uint32 gl_flags = 0;	/* Only RGB works on r5 currently */	gl_flags = BGL_RGB;	if (_this->gl_config.double_buffer)		gl_flags |= BGL_DOUBLE;	else		gl_flags |= BGL_SINGLE;	if (_this->gl_config.alpha_size > 0 || bpp == 32)		gl_flags |= BGL_ALPHA;	if (_this->gl_config.depth_size > 0)		gl_flags |= BGL_DEPTH;	if (_this->gl_config.stencil_size > 0)		gl_flags |= BGL_STENCIL;	if (_this->gl_config.accum_red_size > 0		|| _this->gl_config.accum_green_size > 0		|| _this->gl_config.accum_blue_size > 0		|| _this->gl_config.accum_alpha_size > 0)		gl_flags |= BGL_ACCUM;	/* Create the view for this window, using found flags */	if ( SDL_Win->CreateView(flags, gl_flags) < 0 ) {		return(NULL);	}	current->flags = 0;		/* Clear flags */	current->w = width;	current->h = height;	SDL_Win->SetType(B_TITLED_WINDOW);	if ( flags & SDL_NOFRAME ) {		current->flags |= SDL_NOFRAME;		SDL_Win->SetLook(B_NO_BORDER_WINDOW_LOOK);	} else {		if ( (flags & SDL_RESIZABLE) && !(flags & SDL_OPENGL) )  {			current->flags |= SDL_RESIZABLE;			/* We don't want opaque resizing (TM). :-) */			SDL_Win->SetFlags(B_OUTLINE_RESIZE);		} else {			SDL_Win->SetFlags(B_NOT_RESIZABLE|B_NOT_ZOOMABLE);		}	}	if ( flags & SDL_OPENGL ) {		current->flags |= SDL_OPENGL;		current->pitch = 0;		current->pixels = NULL;		_this->UpdateRects = NULL;	} else {		/* Create the BBitmap framebuffer */		bounds.top = 0; bounds.left = 0;		bounds.right = width-1;		bounds.bottom = height-1;		bbitmap = new BBitmap(bounds, bscreen.ColorSpace());		if ( ! bbitmap->IsValid() ) {			SDL_SetError("Couldn't create screen bitmap");			delete bbitmap;			return(NULL);		}		current->pitch = bbitmap->BytesPerRow();		current->pixels = (void *)bbitmap->Bits();		SDL_Win->SetBitmap(bbitmap);		_this->UpdateRects = BE_NormalUpdate;	}	/* Set the correct fullscreen mode */	BE_SetFullScreen(_this, current, flags & SDL_FULLSCREEN ? 1 : 0);	/* We're done */	return(current);}/* Update the current mouse state and position */void BE_UpdateMouse(_THIS){	BPoint point;	uint32 buttons;	if ( SDL_Win->Lock() ) {		/* Get new input state, if still active */		if ( SDL_Win->IsActive() ) {			(SDL_Win->View())->GetMouse(&point, &buttons, true);		} else {			point.x = -1;			point.y = -1;		}		SDL_Win->Unlock();		if ( (point.x >= 0) && (point.x < SDL_VideoSurface->w) &&		     (point.y >= 0) && (point.y < SDL_VideoSurface->h) ) {			SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);			SDL_PrivateMouseMotion(0, 0,					(Sint16)point.x, (Sint16)point.y);		} else {			SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);		}	}}/* We don't actually allow hardware surfaces other than the main one */static int BE_AllocHWSurface(_THIS, SDL_Surface *surface){	return(-1);}static void BE_FreeHWSurface(_THIS, SDL_Surface *surface){	return;}static int BE_LockHWSurface(_THIS, SDL_Surface *surface){	return(0);}static void BE_UnlockHWSurface(_THIS, SDL_Surface *surface){	return;}static void BE_NormalUpdate(_THIS, int numrects, SDL_Rect *rects){	if ( SDL_Win->BeginDraw() ) {		int i;		for ( i=0; i<numrects; ++i ) {			BRect rect;			rect.top = rects[i].y;			rect.left = rects[i].x;			rect.bottom = rect.top+rects[i].h-1;			rect.right = rect.left+rects[i].w-1;			SDL_Win->DrawAsync(rect);		}		SDL_Win->EndDraw();	}}#if SDL_VIDEO_OPENGL/* Passing a NULL path means load pointers from the application */int BE_GL_LoadLibrary(_THIS, const char *path){	if (path == NULL) {		if (_this->gl_config.dll_handle == NULL) {			image_info info;			int32 cookie = 0;			while (get_next_image_info(0,&cookie,&info) == B_OK) {				void *location = NULL;				if (get_image_symbol((image_id)cookie,"glBegin",B_SYMBOL_TYPE_ANY,&location) == B_OK) {					_this->gl_config.dll_handle = (void*)cookie;					_this->gl_config.driver_loaded = 1;					SDL_strlcpy(_this->gl_config.driver_path, "libGL.so", SDL_arraysize(_this->gl_config.driver_path));				}			}		}	} else {		/*			FIXME None of BeOS libGL.so implementations have exported functions 			to load BGLView, which should be reloaded from new lib.			So for now just "load" linked libGL.so :(		*/		if (_this->gl_config.dll_handle == NULL) {			return BE_GL_LoadLibrary(_this, NULL);		}		/* Unload old first */		/*if (_this->gl_config.dll_handle != NULL) {*/			/* Do not try to unload application itself (if LoadLibrary was called before with NULL ;) */		/*	image_info info;			if (get_image_info((image_id)_this->gl_config.dll_handle, &info) == B_OK) {				if (info.type != B_APP_IMAGE) {					unload_add_on((image_id)_this->gl_config.dll_handle);				}			}					}		if ((_this->gl_config.dll_handle = (void*)load_add_on(path)) != (void*)B_ERROR) {			_this->gl_config.driver_loaded = 1;			SDL_strlcpy(_this->gl_config.driver_path, path, SDL_arraysize(_this->gl_config.driver_path));		}*/	}	if (_this->gl_config.dll_handle != NULL) {		return 0;	} else {		_this->gl_config.dll_handle = NULL;		_this->gl_config.driver_loaded = 0;		*_this->gl_config.driver_path = '\0';		return -1;	}}void* BE_GL_GetProcAddress(_THIS, const char *proc){	if (_this->gl_config.dll_handle != NULL) {		void *location = NULL;		status_t err;		if ((err = get_image_symbol((image_id)_this->gl_config.dll_handle, proc, B_SYMBOL_TYPE_ANY, &location)) == B_OK) {			return location;		} else {			SDL_SetError("Couldn't find OpenGL symbol");			return NULL;		}	} else {		SDL_SetError("OpenGL library not loaded");		return NULL;	}}int BE_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value){	/*		FIXME? Right now BE_GL_GetAttribute shouldn't be called between glBegin() and glEnd() - it doesn't use "cached" values	*/	switch (attrib)    {		case SDL_GL_RED_SIZE:			glGetIntegerv(GL_RED_BITS, (GLint*)value);			break;		case SDL_GL_GREEN_SIZE:			glGetIntegerv(GL_GREEN_BITS, (GLint*)value);			break;		case SDL_GL_BLUE_SIZE:			glGetIntegerv(GL_BLUE_BITS, (GLint*)value);			break;		case SDL_GL_ALPHA_SIZE:			glGetIntegerv(GL_ALPHA_BITS, (GLint*)value);			break;		case SDL_GL_DOUBLEBUFFER:			glGetBooleanv(GL_DOUBLEBUFFER, (GLboolean*)value);			break;		case SDL_GL_BUFFER_SIZE:			int v;			glGetIntegerv(GL_RED_BITS, (GLint*)&v);			*value = v;			glGetIntegerv(GL_GREEN_BITS, (GLint*)&v);			*value += v;			glGetIntegerv(GL_BLUE_BITS, (GLint*)&v);			*value += v;			glGetIntegerv(GL_ALPHA_BITS, (GLint*)&v);			*value += v;			break;		case SDL_GL_DEPTH_SIZE:			glGetIntegerv(GL_DEPTH_BITS, (GLint*)value); /* Mesa creates 16 only? r5 always 32 */			break;		case SDL_GL_STENCIL_SIZE:			glGetIntegerv(GL_STENCIL_BITS, (GLint*)value);			break;		case SDL_GL_ACCUM_RED_SIZE:			glGetIntegerv(GL_ACCUM_RED_BITS, (GLint*)value);			break;		case SDL_GL_ACCUM_GREEN_SIZE:			glGetIntegerv(GL_ACCUM_GREEN_BITS, (GLint*)value);			break;		case SDL_GL_ACCUM_BLUE_SIZE:			glGetIntegerv(GL_ACCUM_BLUE_BITS, (GLint*)value);			break;		case SDL_GL_ACCUM_ALPHA_SIZE:			glGetIntegerv(GL_ACCUM_ALPHA_BITS, (GLint*)value);			break;		case SDL_GL_STEREO:		case SDL_GL_MULTISAMPLEBUFFERS:		case SDL_GL_MULTISAMPLESAMPLES:		default:			*value=0;			return(-1);	}	return 0;}int BE_GL_MakeCurrent(_THIS){	/* FIXME: should we glview->unlock and then glview->lock()? */	return 0;}void BE_GL_SwapBuffers(_THIS){	SDL_Win->SwapBuffers();}#endif/* Is the system palette settable? */int BE_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors){	int i;	SDL_Palette *palette;	const color_map *cmap = BScreen().ColorMap();	/* Get the screen colormap */	palette = _this->screen->format->palette;	for ( i=0; i<256; ++i ) {		palette->colors[i].r = cmap->color_list[i].red;		palette->colors[i].g = cmap->color_list[i].green;		palette->colors[i].b = cmap->color_list[i].blue;	}	return(0);}void BE_VideoQuit(_THIS){	int i, j;	SDL_Win->Quit();	SDL_Win = NULL;	if ( SDL_BlankCursor != NULL ) {		BE_FreeWMCursor(_this, SDL_BlankCursor);		SDL_BlankCursor = NULL;	}	for ( i=0; i<NUM_MODELISTS; ++i ) {		if ( SDL_modelist[i] ) {			for ( j=0; SDL_modelist[i][j]; ++j ) {				SDL_free(SDL_modelist[i][j]);			}			SDL_free(SDL_modelist[i]);			SDL_modelist[i] = NULL;		}	}	/* Restore the original video mode */	if ( _this->screen ) {		if ( (_this->screen->flags&SDL_FULLSCREEN) == SDL_FULLSCREEN ) {			BScreen bscreen;			bscreen.SetMode(&saved_mode);		}		_this->screen->pixels = NULL;	}#if SDL_VIDEO_OPENGL	if (_this->gl_config.dll_handle != NULL)		unload_add_on((image_id)_this->gl_config.dll_handle);#endif	SDL_QuitBeApp();}}; /* Extern C */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -