static rfbBool resize(rfbClient* client) {
	static char first=TRUE;
#ifdef SDL_ASYNCBLIT
	int flags=SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_HWACCEL;
#else
	int flags=SDL_HWSURFACE|SDL_HWACCEL;
#endif
	int width=client->width,height=client->height,
		depth=client->format.bitsPerPixel;
	client->updateRect.x = client->updateRect.y = 0;
	client->updateRect.w = width; client->updateRect.h = height;
	rfbBool okay=SDL_VideoModeOK(width,height,depth,flags);
	if(!okay)
		for(depth=24;!okay && depth>4;depth/=2)
			okay=SDL_VideoModeOK(width,height,depth,flags);
	if(okay) {
		SDL_Surface* sdl=SDL_SetVideoMode(width,height,depth,flags);
		rfbClientSetClientData(client, SDL_Init, sdl);
		client->width = sdl->pitch / (depth / 8);
		client->frameBuffer=sdl->pixels;
		if(first || depth!=client->format.bitsPerPixel) {
			first=FALSE;
			client->format.bitsPerPixel=depth;
			client->format.redShift=sdl->format->Rshift;
			client->format.greenShift=sdl->format->Gshift;
			client->format.blueShift=sdl->format->Bshift;
			client->format.redMax=sdl->format->Rmask>>client->format.redShift;
			client->format.greenMax=sdl->format->Gmask>>client->format.greenShift;
			client->format.blueMax=sdl->format->Bmask>>client->format.blueShift;
			SetFormatAndEncodings(client);
		}
	} else {
示例#2
0
	Image* RenderBackendSDL::createMainScreen(unsigned int width, unsigned int height, unsigned char bitsPerPixel, bool fs, const std::string& title, const std::string& icon) {
		Uint32 flags = 0;
		if (fs) {
			flags |= SDL_FULLSCREEN;
		}

		if(icon != "") {
			SDL_Surface *img = IMG_Load(icon.c_str());
			if(img != NULL) {
				SDL_WM_SetIcon(img, 0);
			}
		}

		SDL_Surface* screen = NULL;

		if( 0 == bitsPerPixel ) {
			/// autodetect best mode
			unsigned char possibleBitsPerPixel[] = {16, 24, 32, 0};
			int i = 0;
			while( true ) {
				bitsPerPixel = possibleBitsPerPixel[i];
				if( !bitsPerPixel ) {
					// Last try, sometimes VideoModeOK seems to lie.
					// Try bpp=0
					screen = SDL_SetVideoMode(width, height, bitsPerPixel, flags);
					if( !screen ) {
						throw SDLException("Videomode not available");
					}
					break;
				}
				bitsPerPixel = SDL_VideoModeOK(width, height, bitsPerPixel, flags);
				if ( bitsPerPixel ) {
					screen = SDL_SetVideoMode(width, height, bitsPerPixel, flags);
					if( screen ) {
						break;
					}
				}
				++i;
			}
		} else {
			if ( !SDL_VideoModeOK(width, height, bitsPerPixel, flags) ) {
				throw SDLException("Videomode not available");
			}
			screen = SDL_SetVideoMode(width, height, bitsPerPixel, flags);
		}
		FL_LOG(_log, LMsg("RenderBackendSDL")
			<< "Videomode " << width << "x" << height
			<< " at " << int(screen->format->BitsPerPixel) << " bpp");

		SDL_WM_SetCaption(title.c_str(), NULL);

		if (!screen) {
			throw SDLException(SDL_GetError());
		}

		m_screen = new SDLImage(screen);
		return m_screen;
	}
int		create_and_open_screen(int sizex, int sizey, int bpp, int mode)
{
  static bool	first = true;
  static bool	dofree = false;

#ifndef WIN32
  set_sdl_env();
#endif
  if (dofree == true)
    {
      dofree = false;
      SDL_FreeSurface(gfx->buff);
    }
  if (first == true)
    {
      if (!(gfx = (t_gfx*)malloc(sizeof(*gfx))))
	{
	  printf("Out of memory.\n");
	  exit(42);
	}
      gfx->videoinfo = (SDL_VideoInfo *)SDL_GetVideoInfo();
      first = false;
    }
  gfx->win = (t_display*)xmalloc(sizeof(*(gfx->win)));  
#ifdef GRAPHICS_DEBUG
  fprintf(fd_log, "Checking mode %dx%d@%dbpp.\n", sizex, sizey, bpp);
#endif
  gfx->bpp = SDL_VideoModeOK(sizex, sizey, bpp, mode);
  if(!gfx->bpp)
    {
#ifdef GRAPHICS_DEBUG
      fprintf(fd_log, "Mode not available, trying another..\n");
#endif
      gfx->bpp = SDL_VideoModeOK(sizex, sizey, bpp, SDL_ANYFORMAT);
      if (!gfx->bpp)
	return (-1);
	  if (!(gfx->main = SDL_SetVideoMode(sizex, sizey, bpp, mode | SDL_GLSDL)))
	    return (-1);
    }
  else if (!(gfx->main = SDL_SetVideoMode(sizex, sizey, bpp, mode | SDL_GLSDL)))
    return (-1);
  gfx->win->sdlMainScreen = gfx->main;
  gfx->win->text = NULL;
  SDL_WM_SetCaption("Freewar", "fw.ico");
  gfx->buff = xSDL_DisplayFormatAlpha(gfx->main);
  init_gfx();
  if (init_fonts())
    return (-1);
  dofree = true;
  return (0);
}
示例#4
0
文件: vj-sdl.c 项目: c0ntrol/veejay
/*
static	int	wm_fullscreen(int action, Display *disp, Window *win) {
#endif
	XEvent xev;
	xev.xclient.type = ClientMessage;
	xev.xclient.serial = 0;
	xev.xclient.send_event = True;
	xev.xclient.message_type = XInternAtom( disp, 
					"_NET_WM_STATE", False );
	xev.xclient.window = win;
	xev.xclient.format = 32;
	xev.xclient.data.1[0] = action;
	xev.xclient.data.1[1] = XInternAtom( disp,
					"_NET_WM_STATE_FULLSCREEN",False );
	xev.xclient.data.1[2] = 0;
	xev.xclient.data.1[3] = 0;
	xev.xclient.data.1[4] = 0;
		
	if( !XSendEvent( disp, DefaultRootWindow( disp ), False,
				SubstructureRedirectMask |
				SubstructureNotifyMask, &xev ) )
	{
		veejay_msg(0, "WM Fullscreen state failed");
		return 0;
	}
	return 1;
}
*/
static void vj_sdl_move( vj_sdl *vjsdl , int display_wid, int display_hei, int scaled_width, int scaled_height, int x, int y )
{
	//@ sw_scale_width is misleading ; it lets SDL use the BES 
	if (scaled_width)
		vjsdl->sw_scale_width = scaled_width;
	if (scaled_height)
		vjsdl->sw_scale_height = scaled_height;

	int my_bpp = SDL_VideoModeOK( display_wid, display_hei,24, vjsdl->flags[1] );
	if(!my_bpp)
	{
		veejay_msg(VEEJAY_MSG_DEBUG, "Requested depth not supported");
		return;
	}

	vjsdl->screen = SDL_SetVideoMode( display_wid, display_hei,my_bpp,vjsdl->flags[1]);

	vjsdl->rectangle.x = x;
	vjsdl->rectangle.y = y;
	vjsdl->rectangle.w = scaled_width;
	vjsdl->rectangle.h = scaled_height;


	veejay_msg(VEEJAY_MSG_INFO, "Changed video window to size %d x %d (%dx%d+%dx%d)", display_wid, display_hei,
			scaled_width,scaled_height,x,y);
}
示例#5
0
static void GetVideoModes()
{
	SDL_Rect **modes = SDL_CALL SDL_ListModes(NULL, SDL_SWSURFACE | SDL_FULLSCREEN);
	if (modes == NULL) usererror("sdl: no modes available");

	_all_modes = (SDL_CALL SDL_ListModes(NULL, SDL_SWSURFACE | (_fullscreen ? SDL_FULLSCREEN : 0)) == (void*)-1);
	if (modes == (void*)-1) {
		int n = 0;
		for (uint i = 0; i < lengthof(_default_resolutions); i++) {
			if (SDL_CALL SDL_VideoModeOK(_default_resolutions[i].width, _default_resolutions[i].height, 8, SDL_FULLSCREEN) != 0) {
				_resolutions[n] = _default_resolutions[i];
				if (++n == lengthof(_resolutions)) break;
			}
		}
		_num_resolutions = n;
	} else {
		int n = 0;
		for (int i = 0; modes[i]; i++) {
			uint w = modes[i]->w;
			uint h = modes[i]->h;
			int j;
			for (j = 0; j < n; j++) {
				if (_resolutions[j].width == w && _resolutions[j].height == h) break;
			}

			if (j == n) {
				_resolutions[j].width  = w;
				_resolutions[j].height = h;
				if (++n == lengthof(_resolutions)) break;
			}
		}
		_num_resolutions = n;
		SortResolutions(_num_resolutions);
	}
}
示例#6
0
GF_Err SDLVid_SetFullScreen(GF_VideoOutput *dr, u32 bFullScreenOn, u32 *screen_width, u32 *screen_height)
{
	u32 bpp, pref_bpp;
	SDLVID();

	if (ctx->fullscreen==bFullScreenOn) return GF_OK;

	/*lock to get sure the event queue is not processed under X*/
	gf_mx_p(ctx->evt_mx);
	ctx->fullscreen = bFullScreenOn;

	pref_bpp = bpp = ctx->screen->format->BitsPerPixel;

	if (ctx->fullscreen) {
		u32 flags;
		Bool switch_res = 0;
		const char *sOpt = gf_modules_get_option((GF_BaseInterface *)dr, "Video", "SwitchResolution");
		if (sOpt && !stricmp(sOpt, "yes")) switch_res = 1;
		if (!dr->max_screen_width || !dr->max_screen_height) switch_res = 1;

		flags = (ctx->output_3d_type==1) ? SDL_GL_FULLSCREEN_FLAGS : SDL_FULLSCREEN_FLAGS;
		ctx->store_width = *screen_width;
		ctx->store_height = *screen_height;
		if (switch_res) {
			u32 i;
			ctx->fs_width = *screen_width;
			ctx->fs_height = *screen_height;
			for(i=0; i<nb_video_modes; i++) {
				if (ctx->fs_width<=video_modes[2*i] && ctx->fs_height<=video_modes[2*i + 1]) {
					if ((pref_bpp = SDL_VideoModeOK(video_modes[2*i], video_modes[2*i+1], bpp, flags))) {
						ctx->fs_width = video_modes[2*i];
						ctx->fs_height = video_modes[2*i + 1];
						break;
					}
				}
			}
		} else {
			ctx->fs_width = dr->max_screen_width;
			ctx->fs_height = dr->max_screen_height;
		}
		ctx->screen = SDL_SetVideoMode(ctx->fs_width, ctx->fs_height, pref_bpp, flags);
		/*we switched bpp, clean all objects*/
		if (bpp != pref_bpp) SDLVid_DestroyObjects(ctx);
		*screen_width = ctx->fs_width;
		*screen_height = ctx->fs_height;
		/*GL has changed*/
		if (ctx->output_3d_type==1) {
			GF_Event evt;
			evt.type = GF_EVENT_VIDEO_SETUP;
			dr->on_event(dr->evt_cbk_hdl, &evt);
		}
	} else {
		SDLVid_ResizeWindow(dr, ctx->store_width, ctx->store_height);
		*screen_width = ctx->store_width;
		*screen_height = ctx->store_height;
	}
	gf_mx_v(ctx->evt_mx);
	if (!ctx->screen) return GF_IO_ERR;
	return GF_OK;
}
示例#7
0
文件: main.c 项目: miguis16/Pacman
void setup(){
	SDL_Surface *imagenCargada;
	int bpp,i;
	
	if(SDL_Init (SDL_INIT_VIDEO) < 0) {
		fprintf(stderr,"No se pudo inicializar el sistema de video\n"
				"El error devuelto fue %s\n",SDL_GetError());
		exit(1);
	}
	
	bpp = SDL_VideoModeOK (WIDTH_SCREEN,HEIGHT_SCREEN, 16, 0);

	if(bpp == 0){
		fprintf(stderr,"Error: No se pudo establecer el video\n");
		exit (1);
	}
	
	screen = SDL_SetVideoMode(WIDTH_SCREEN, HEIGHT_SCREEN, bpp, 0);
	
	for(i = 0; i < TOTAL_IMAGENES ; i++){
		imagenCargada = IMG_Load (imagesNames[i]);
		if(imagenCargada == NULL){
			fprintf(stderr,"Error al cargar : %s\n",SDL_GetError());
			exit(1);
		}
		else{
			SDL_SetColorKey (imagenCargada, SDL_SRCCOLORKEY,0xff00ff); // Establecer transparencia	
			images[i] = imagenCargada;
		}
	}	
}
bool SDLDraw::isDisplayModeAvailable(int width, int height, int bpp)
{
    if(SDL_VideoModeOK(width, height, bpp, 0 /*SDL_FULLSCREEN | SDL_DOUBLEBUF | SDL_HWSURFACE*/))
        return true;

    return false;
}
示例#9
0
文件: vj-sdl.c 项目: c0ntrol/veejay
void vj_sdl_resize( vj_sdl *vjsdl , int scaled_width, int scaled_height, int fs )
{
	//@ sw_scale_width is misleading ; it lets SDL use the BES 
	if (scaled_width)
		vjsdl->sw_scale_width = scaled_width;
	if (scaled_height)
		vjsdl->sw_scale_height = scaled_height;

	int my_bpp = SDL_VideoModeOK( vjsdl->sw_scale_width, vjsdl->sw_scale_height,24,	
				vjsdl->flags[fs] );
	if(!my_bpp)
	{
		veejay_msg(VEEJAY_MSG_DEBUG, "Requested depth not supported");
		return;
	}

	vjsdl->screen = SDL_SetVideoMode( vjsdl->sw_scale_width, vjsdl->sw_scale_height,my_bpp,
				vjsdl->flags[fs]);

	vjsdl->rectangle.x = 0;
	vjsdl->rectangle.y = 0;
	vjsdl->rectangle.w = scaled_width;
	vjsdl->rectangle.h = scaled_height;


	veejay_msg(VEEJAY_MSG_INFO, "Changed video window to size %d x %d",
			vjsdl->sw_scale_width,vjsdl->sw_scale_height);
}
示例#10
0
static void find_resolution() {
	SDL_Rect **modes;
	int i,bestw,besth,wantedw,wantedh;
	wantedw=TCOD_ctx.fullscreen_width>TCOD_ctx.root->w*TCOD_ctx.font_width?TCOD_ctx.fullscreen_width:TCOD_ctx.root->w*TCOD_ctx.font_width;
	wantedh=TCOD_ctx.fullscreen_height>TCOD_ctx.root->h*TCOD_ctx.font_height?TCOD_ctx.fullscreen_height:TCOD_ctx.root->h*TCOD_ctx.font_height;
	TCOD_ctx.actual_fullscreen_width=wantedw;
	TCOD_ctx.actual_fullscreen_height=wantedh;
	modes=SDL_ListModes(NULL, SDL_FULLSCREEN);

	bestw=99999;
	besth=99999;
	if(modes != (SDL_Rect **)0 && modes != (SDL_Rect **)-1){
		for(i=0;modes[i];++i) {
			if (modes[i]->w >= wantedw && modes[i]->w <= bestw
				&& modes[i]->h >= wantedh && modes[i]->h <= besth
				&& SDL_VideoModeOK(modes[i]->w, modes[i]->h, 32, SDL_FULLSCREEN)) {
				bestw=modes[i]->w;
				besth=modes[i]->h;
			}
		}
	}
	if ( bestw != 99999) {
		TCOD_ctx.actual_fullscreen_width=bestw;
		TCOD_ctx.actual_fullscreen_height=besth;
	}
}
示例#11
0
static void find_resolution() {
	SDL_Rect **modes;
	int i,bestw,besth,wantedw,wantedh;
	wantedw=fullscreen_width>consoleWidth*fontWidth?fullscreen_width:consoleWidth*fontWidth;
	wantedh=fullscreen_height>consoleHeight*fontHeight?fullscreen_height:consoleHeight*fontHeight;
	actual_fullscreen_width=wantedw;
	actual_fullscreen_height=wantedh;
	modes=SDL_ListModes(NULL, SDL_FULLSCREEN);

	bestw=99999;
	besth=99999;
	if(modes != (SDL_Rect **)0 && modes != (SDL_Rect **)-1){
		for(i=0;modes[i];++i) {
			if (modes[i]->w >= wantedw && modes[i]->w <= bestw
				&& modes[i]->h >= wantedh && modes[i]->h <= besth
				&& SDL_VideoModeOK(modes[i]->w, modes[i]->h, 32, SDL_FULLSCREEN)) {
				bestw=modes[i]->w;
				besth=modes[i]->h;
			}
		}
	}
	if ( bestw != 99999) {
		actual_fullscreen_width=bestw;
		actual_fullscreen_height=besth;
	}
	//printf ("resolution : %dx%d =>%dx%d\n",wantedw,wantedh,bestw,besth);
}
示例#12
0
/** Constructor.
 * @param width width of image
 * @param height height of image
 * @param title window title
 */
ImageDisplay::ImageDisplay(unsigned int width, unsigned int height, const char *title)
{
	SDLKeeper::init(SDL_INIT_VIDEO);
	if (title)
		SDL_WM_SetCaption(title, NULL);

	_width  = width;
	_height = height;

	int bpp  = SDL_VideoModeOK(_width, _height, 16, SDL_ANYFORMAT);
	_surface = SDL_SetVideoMode(width, height, bpp, /* flags */ SDL_HWSURFACE | SDL_ANYFORMAT);
	if (!_surface) {
		throw Exception("SDL: cannot create surface");
	}

	// SDL_UYVY_OVERLAY
	_overlay = SDL_CreateYUVOverlay(width, height, SDL_UYVY_OVERLAY, _surface);
	if (!_overlay) {
		throw Exception("Cannot create overlay");
	}

	_rect = new SDL_Rect;

	_rect->x = 0;
	_rect->y = 0;
	_rect->w = _width;
	_rect->h = _height;
}
示例#13
0
void build_video_mode_array()
{
	int i;
	int flags;

	if (full_screen)
		flags=SDL_OPENGL|SDL_FULLSCREEN;
	else
		flags=SDL_OPENGL;

	for(i = 0; i < video_modes_count; i++)
	{
		video_modes[i].flags.selected = 0;
		video_modes[i].flags.supported = 0;


		if(bpp == video_modes[i].bpp 
#ifdef WINDOWS
			|| full_screen
#endif
			) 
		{
			if (SDL_VideoModeOK(video_modes[i].width, video_modes[i].height, video_modes[i].bpp, flags))
				video_modes[i].flags.supported = 1;
		}

	}
	if (video_mode > 0)
		video_modes[video_mode-1].flags.selected=1;
}
示例#14
0
文件: opengl.c 项目: Dinth/naev
/**
 * @brief Creates the OpenGL window.
 *
 *    @return 0 on success.
 */
static int gl_createWindow( unsigned int flags )
{
   int depth;

   /* Test the setup - aim for 32. */
   gl_screen.depth = 32;
   depth = SDL_VideoModeOK( SCREEN_W, SCREEN_H, gl_screen.depth, flags);
   if (depth == 0)
      WARN("Video Mode %dx%d @ %d bpp not supported"
           "   going to try to create it anyways...",
            SCREEN_W, SCREEN_H, gl_screen.depth );
   if (depth != gl_screen.depth)
      DEBUG("Depth %d bpp unavailable, will use %d bpp", gl_screen.depth, depth);
   gl_screen.depth = depth;

   /* Actually creating the screen. */
   if (SDL_SetVideoMode( SCREEN_W, SCREEN_H, gl_screen.depth, flags)==NULL) {
      /* Try again possibly disabling FSAA. */
      if (conf.fsaa > 1) {
         LOG("Unable to create OpenGL window: Trying without FSAA.");
         SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
         SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
      }
      if (SDL_SetVideoMode( SCREEN_W, SCREEN_H, gl_screen.depth, flags)==NULL) {
         ERR("Unable to create OpenGL window: %s", SDL_GetError());
         return -1;
      }
   }
   gl_screen.rw = SCREEN_W;
   gl_screen.rh = SCREEN_H;
   gl_activated = 1; /* Opengl is now activated. */

   return 0;
}
示例#15
0
int can_init_scaler( unsigned int new_scaler, bool fullscreen )
{
	if (new_scaler >= scalers_count)
	return false;

	int w = scalers[new_scaler].width,
	h = scalers[new_scaler].height;
	int flags = SDL_SWSURFACE | SDL_HWPALETTE | (fullscreen ? SDL_FULLSCREEN : 0);

	// test each bitdepth
	for (uint bpp = 32; bpp > 0; bpp -= 8)
	{
		uint temp_bpp = SDL_VideoModeOK(w, h, bpp, flags);

		if ((temp_bpp == 32 && scalers[new_scaler].scaler32) ||
				(temp_bpp == 16 && scalers[new_scaler].scaler16) ||
				(temp_bpp == 8 && scalers[new_scaler].scaler8 ))
		{
			return temp_bpp;
		}
		else if (temp_bpp == 24 && scalers[new_scaler].scaler32)
		{
			// scalers don't support 24 bpp because it's a pain
			// so let SDL handle the conversion
			return 32;
		}
	}

	return 0;
}
示例#16
0
bool OglSdlSurface()
{
  Uint32 surfaceFlags;

  if (NULL != vidSurface)
    {
      SDL_FreeSurface(vidSurface);
      vidSurface = NULL;
#ifdef VOODOOSAFESWITCHING
      SDL_QuitSubSystem(SDL_INIT_VIDEO);
      SDL_InitSubSystem(SDL_INIT_VIDEO);
#endif
    }

  if (cv_fullscreen.value)
    surfaceFlags = SDL_OPENGL|SDL_FULLSCREEN;
  else
    surfaceFlags = SDL_OPENGL;

  // We want at least 1 bit (???) for R, G, and B, and at least 16 bits for depth buffer.
  SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 1);
  SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 1);
  SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 1);
  SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);

  int cbpp = SDL_VideoModeOK(vid.width, vid.height, vid.BitsPerPixel, surfaceFlags);
  if (cbpp < 16)
    return false;
  if ((vidSurface = SDL_SetVideoMode(vid.width, vid.height, cbpp, surfaceFlags)) == NULL)
    return false;

  CONS_Printf("HWRend::Startup(): %dx%d %d bits\n", vid.width, vid.height, cbpp);

  return true;
}
示例#17
0
/*
================
VID_ValidMode
================
*/
static qboolean VID_ValidMode (int width, int height, int bpp, qboolean fullscreen)
{
	Uint32 flags = DEFAULT_SDL_FLAGS;

	if (width < 320)
		return false;

	if (height < 200)
		return false;

	if (fullscreen)
		flags |= SDL_FULLSCREEN;

	bpp = SDL_VideoModeOK(width, height, bpp, flags);

	switch (bpp)
	{
	case 16:
	case 24:
	case 32:
		break;
	default:
		return false;
	}

	return true;
}
示例#18
0
/*
================
VID_SetMode
================
*/
static int VID_SetMode (int width, int height, int bpp, qboolean fullscreen)
{
	int		temp;
	Uint32	flags = DEFAULT_SDL_FLAGS;
	char		caption[50];

	if (fullscreen)
		flags |= SDL_FULLSCREEN;

	// so Con_Printfs don't mess us up by forcing vid and snd updates
	temp = scr_disabled_for_loading;
	scr_disabled_for_loading = true;

	CDAudio_Pause ();
	BGM_Pause ();

	//
	// swap control (the "before SDL_SetVideoMode" part)
	//
	gl_swap_control = true;
	if (SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, (vid_vsync.value) ? 1 : 0) == -1)
		gl_swap_control = false;

	bpp = SDL_VideoModeOK(width, height, bpp, flags);

	draw_context = SDL_SetVideoMode(width, height, bpp, flags);
	if (!draw_context)
		Sys_Error ("Couldn't set video mode");

	q_snprintf(caption, sizeof(caption), "QuakeSpasm %1.2f.%d", (float)FITZQUAKE_VERSION, QUAKESPASM_VER_PATCH);
	SDL_WM_SetCaption(caption, caption);

	vid.width = draw_context->w;
	vid.height = draw_context->h;
	vid.conwidth = vid.width & 0xFFFFFFF8;
	vid.conheight = vid.conwidth * vid.height / vid.width;
	vid.numpages = 2;

	modestate = draw_context->flags & SDL_FULLSCREEN ? MS_FULLSCREEN : MS_WINDOWED;

	CDAudio_Resume ();
	BGM_Resume ();
	scr_disabled_for_loading = temp;

// fix the leftover Alt from any Alt-Tab or the like that switched us away
	ClearAllStates ();

	Con_SafePrintf ("Video mode %dx%dx%d initialized\n",
				draw_context->w,
				draw_context->h,
				draw_context->format->BitsPerPixel);

	vid.recalc_refdef = 1;

// no pending changes
	vid_changed = false;

	return true;
}
示例#19
0
/* Mattias Engdegard <*****@*****.**> */
SDL_Surface * set_video_mode (unsigned flags) {
	/* Prefer 16bpp, but also prefer native modes to emulated 16bpp. */

	int depth;

	depth = SDL_VideoModeOK (760, 480, 16, flags);
	return depth ? SDL_SetVideoMode (760, 480, depth, flags) : NULL;
}
示例#20
0
/**
**  Check if a resolution is valid
**
**  @param w  Width
**  @param h  Height
*/
int VideoValidResolution(int w, int h)
{
#ifdef USE_MAEMO
	if (w != 800 || h != 480) {
		return 0;
	}
#endif
	return SDL_VideoModeOK(w, h, TheScreen->format->BitsPerPixel, TheScreen->flags);
}
示例#21
0
文件: resolution.cpp 项目: kerlw/Dawn
bool Resolution::checkResolution( Resolution checkRes )
{
	Uint32 flags = SDL_OPENGL;
	if ( checkRes.fullscreen ) {
		flags |= SDL_FULLSCREEN;
	}
	int suggestedBpp = SDL_VideoModeOK( checkRes.width, checkRes.height, checkRes.bpp, flags );
	return suggestedBpp != 0;
}
示例#22
0
文件: sdlgl.c 项目: paud/d2x-xl
int OglVideoModeOK (int w, int h)
{
int nColorBits = SDL_VideoModeOK (w, h, FindArg ("-gl_16bpp") ? 16 : 32, SDL_VIDEO_FLAGS);
LogErr ("SDL suggests %d bits/pixel\n", nColorBits);
if (!nColorBits)
	return 0;
gameStates.ogl.nColorBits = nColorBits;
return 1;
}
示例#23
0
bool yuv_check_video_mode(struct graphics_data *graphics,
 int width, int height, int depth, bool fullscreen, bool resize)
{
#if SDL_VERSION_ATLEAST(2,0,0)
  return true;
#else
  return SDL_VideoModeOK(width, height, 32,
   sdl_flags(depth, fullscreen, resize) | SDL_ANYFORMAT);
#endif
}
示例#24
0
bool gl_check_video_mode(struct graphics_data *graphics, int width, int height,
 int depth, bool fullscreen, bool resize)
{
#if SDL_VERSION_ATLEAST(2,0,0)
  return true;
#else
  return SDL_VideoModeOK(width, height, depth,
   GL_STRIP_FLAGS(sdl_flags(depth, fullscreen, resize)));
#endif
}
示例#25
0
bool VideoManager::isModeAvailable(int w, int h, int bpp, bool fullscreen,
		int* true_bpp) {
	Uint32 flags = SDL_OPENGL;
	if (fullscreen)
		flags = flags | SDL_FULLSCREEN;
	int r = SDL_VideoModeOK(w, h, bpp, flags);
	if (true_bpp)
		*true_bpp = r;
	return (r != 0);
}
示例#26
0
文件: main.cpp 项目: UlisesB/Kibus
void setup (void) {
	SDL_Surface *carga;
	int g, bpp;
	
	if (SDL_Init(SDL_INIT_VIDEO) < 0) {
		fprintf (stderr,
			"Error: No se pudo inicializar el sistema de video\n"
			"El error devuelto por SDL es:\n"
			"%s\n", SDL_GetError());
		exit (1);
	}
	bpp = SDL_VideoModeOK ((IMAGENES_DIMENSION * PANTALLA_ANCHO) + IMAGENES_DIMENSION + 2, IMAGENES_DIMENSION * PANTALLA_ALTO, 16, 0);
	
	if (bpp == 0) {
		fprintf (stderr, "Error: No se pudo establecer el modo de video\n");
		exit (1);
	}
	
	screen = SDL_SetVideoMode ((IMAGENES_DIMENSION * PANTALLA_ANCHO) + IMAGENES_DIMENSION + 2, IMAGENES_DIMENSION * PANTALLA_ALTO, bpp, 0);
	
	for (g = 0; g < NUM_IMGS; g++) {
		carga = IMG_Load (images_names [g]);
		
		if (carga == NULL) {
			fprintf (stderr, "Error al cargar la imagen %s\n", images_names [g]);
			SDL_Quit ();
			exit (1);
		}
		
		images[g] = carga;
	}
	
	use_sound = 1;
	if (SDL_InitSubSystem (SDL_INIT_AUDIO) < 0) {
        fprintf (stderr, "Fallo al inicializar el audio, continuando...\n");
        use_sound = 0;
    }
    
    if (use_sound) {
        if (Mix_OpenAudio (22050, AUDIO_S16, 2, 4096) < 0) {
            fprintf (stderr, "Fallo al inicializar el mezclador, continuando...\n");
            use_sound = 0;
        }
    }

    if (use_sound) {
        mus_fondo = Mix_LoadMUS (MUS_MAPA_1);
        
        if (mus_fondo == NULL) {
            fprintf (stderr, "Fallo la musica de fondo %s\n", MUS_MAPA_1);
            SDL_Quit ();
            exit (1);
        }
    }
}
示例#27
0
文件: mrb_sdl.c 项目: Qard/mruby-sdl
static mrb_value mrb_sdl_video_mode_ok (mrb_state *mrb, mrb_value self) {
  mrb_int width;
  mrb_int height;
  mrb_int depth;
  mrb_int flags;
  mrb_get_args(mrb, "|i", &width);
  mrb_get_args(mrb, "|i", &height);
  mrb_get_args(mrb, "|i", &depth);
  mrb_get_args(mrb, "|i", &flags);
  return mrb_fixnum_value(SDL_VideoModeOK(width, height, depth, flags));
}
示例#28
0
/**
 * @brief Constructor.
 */
VideoManager::VideoManager(bool disable_window):
  disable_window(disable_window), screen_surface(NULL) {

  // initialize the window
  IniFile ini("quest.dat", IniFile::READ);
  ini.set_group("info");
  std::string title_bar = ini.get_string_value("title_bar"); // get the window title bar text (language-independent)
  SDL_WM_SetCaption(title_bar.c_str(), NULL);
  putenv((char*) "SDL_VIDEO_CENTERED=center");
  putenv((char*) "SDL_NOMOUSE");

  // detect what widescreen resolution is supported (16:10 or 15:10)

  for (int i = 0; i < NB_MODES; i++) {
    mode_sizes[i] = default_mode_sizes[i];
  }
  int flags = surface_flags | SDL_FULLSCREEN;
  if (SDL_VideoModeOK(768, 480, 32, flags)) {
    mode_sizes[FULLSCREEN_WIDE].set_size(768, 480);
    mode_sizes[FULLSCREEN_SCALE2X_WIDE].set_size(768, 480);
    dst_position_wide.set_xy((768 - SOLARUS_SCREEN_WIDTH * 2) / 2, 0);
  }
  else if (SDL_VideoModeOK(720, 480, 32, flags)) {
    mode_sizes[FULLSCREEN_WIDE].set_size(720, 480);
    mode_sizes[FULLSCREEN_SCALE2X_WIDE].set_size(720, 480);
    dst_position_wide.set_xy((720 - SOLARUS_SCREEN_WIDTH * 2) / 2, 0);
  }

  /* debug (see the fullscreen video modes supported)
     SDL_Rect **rects = SDL_ListModes(NULL, flags);
     while (*rects != NULL) {
     std::cout << "mode " << (*rects)->w << " x " << (*rects)->h << std::endl;
     rects++;
     }
     */

  set_initial_video_mode();
}
示例#29
0
文件: gr.c 项目: CDarrow/DXX-Retro
int gr_check_mode(u_int32_t mode)
{
	unsigned int w, h;

	w=SM_W(mode);
	h=SM_H(mode);

	if (sdl_no_modeswitch == 0) {
		return SDL_VideoModeOK(w, h, GameArg.DbgBpp, sdl_video_flags);
	} else {
		// just tell the caller that any mode is valid...
		return 32;
	}
}
示例#30
0
void Control::setup(SDL_Color* bkgrnd) {
	int success;
	success = SDL_Init(SDL_INIT_VIDEO);
	running = (success==0);
	
	if (!running)
		cout << "ERROR: Initialization failed!" << endl;
	else {
		success = SDL_VideoModeOK(winWidth, winHeight, 8, 
								SDL_SWSURFACE|SDL_RESIZABLE);
		running = (success>0);
	}
	
	if (!running)
		cout << "ERROR: Requested resolution and video " <<
				"modes are not supported." << endl;
	else {
		screen = SDL_SetVideoMode(winWidth, winHeight, 8,
								SDL_SWSURFACE|SDL_RESIZABLE);
		SDL_WM_SetCaption(gameTitle.c_str(), gameTitle.c_str());
		
		// Uncomment these two lines when we find a suitable icon
		//SDL_Surface *icon = SDL_LoadBMP("filename.bmp");
		//SDL_WM_SetIcon(icon, NULL);
		
		if (screen!=NULL)
			running = true;
		else {
			running = false;
			cout << "ERROR: Video mode did not set properly." << endl;
		}
	}
	
	if (!bkgrnd) {
		background = new SDL_Color;
		background->r = RGBMAX;
		background->g = RGBMAX;
		background->b = RGBMAX;
	}
	else background = bkgrnd;
	
	if (running) {
		SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 
					background->r, background->g, background->b));
		SDL_UpdateRect(screen, 0,0,0,0);
		SDL_FillRect(screen, player->getShape(), player->mapColor(screen));
		SDL_UpdateRects(screen, 1, player->getShape());
	}
}