Ejemplo n.º 1
0
bool CVideoMode::SetFullscreen(bool fullscreen)
{
	// This might get called before initialisation by psDisplayError;
	// if so then silently fail
	if (!m_IsInitialised)
		return false;

	// Check whether this is actually a change
	if (fullscreen == m_IsFullscreen)
		return true;

	if (!m_IsFullscreen)
	{
		// Windowed -> fullscreen:

		int w = 0, h = 0;

		// If a fullscreen size was configured, use that; else use the desktop size; else use a default
		if (m_ConfigFullscreen)
		{
			w = m_ConfigW;
			h = m_ConfigH;
		}
		if (w == 0 || h == 0)
		{
			w = m_PreferredW;
			h = m_PreferredH;
		}
		if (w == 0 || h == 0)
		{
			w = DEFAULT_FULLSCREEN_W;
			h = DEFAULT_FULLSCREEN_H;
		}

		int bpp = GetBestBPP();

		if (!SetVideoMode(w, h, bpp, fullscreen))
			return false;

		UpdateRenderer(m_CurrentW, m_CurrentH);

		return true;
	}
	else
	{
		// Fullscreen -> windowed:

		// Go back to whatever the previous window size was
		int w = m_WindowedW, h = m_WindowedH;

		int bpp = GetBestBPP();

		if (!SetVideoMode(w, h, bpp, fullscreen))
			return false;

		UpdateRenderer(w, h);

		return true;
	}
}
Ejemplo n.º 2
0
void HumanClientApp::Reinitialize() {
    bool fullscreen = GetOptionsDB().Get<bool>("fullscreen");
    bool fake_mode_change = GetOptionsDB().Get<bool>("fake-mode-change");
    std::pair<int, int> size = GetWindowWidthHeight();

    bool fullscreen_transition = Fullscreen() != fullscreen;
    GG::X old_width = AppWidth();
    GG::Y old_height = AppHeight();

    SetVideoMode(GG::X(size.first), GG::Y(size.second), fullscreen, fake_mode_change);
    if (fullscreen_transition) {
        FullscreenSwitchSignal(fullscreen); // after video mode is changed but before DoLayout() calls
    } else if (fullscreen &&
               (old_width != size.first || old_height != size.second) &&
               GetOptionsDB().Get<bool>("UI.auto-reposition-windows"))
    {
        // Reposition windows if in fullscreen mode... handled here instead of
        // HandleWindowResize() because the prev. fullscreen resolution is only
        // available here.
        RepositionWindowsSignal();
    }

    // HandleWindowResize is already called via this signal sent from
    // SDLGUI::HandleSystemEvents() when in windowed mode.  This sends the
    // signal (and hence calls HandleWindowResize()) when in fullscreen mode,
    // making the signal more consistent...
    if (fullscreen) {
        WindowResizedSignal(GG::X(size.first), GG::Y(size.second));
    }
}
Ejemplo n.º 3
0
void SState::ToggleFullscreen()
{
    m_bFullscreen = !m_bFullscreen;

    bool bPaletted = ( gamescreen->format->BitsPerPixel <= 8 );
    SDL_Color aoPalette[256];
    int iNumColors = 0;

    if ( bPaletted )
    {
        iNumColors = gamescreen->format->palette->ncolors;
        if ( iNumColors > 256 ) iNumColors = 256;
        for ( int i=0; i<iNumColors; ++i )
        {
            aoPalette[i].r = gamescreen->format->palette->colors[i].r;
            aoPalette[i].g = gamescreen->format->palette->colors[i].g;
            aoPalette[i].b = gamescreen->format->palette->colors[i].b;
            aoPalette[i].unused = 0;
        }
    }

    SetVideoMode( gamescreen->w > 640, m_bFullscreen );

    if ( bPaletted )
    {
        SDL_SetPalette( gamescreen, SDL_LOGPAL | SDL_PHYSPAL, aoPalette, 0, iNumColors );
    }
}
Ejemplo n.º 4
0
static void ApplyWindowResize(unsigned int w, unsigned int h)
{
    screen_mode_t *mode;

    // Find the biggest screen mode that will fall within these
    // dimensions, falling back to the smallest mode possible if
    // none is found.

    mode = I_FindScreenMode(w, h);

    if (mode == NULL)
    {
        mode = I_FindScreenMode(SCREENWIDTH, SCREENHEIGHT);
    }

    // Reset mode to resize window.

    printf("Resize to %ix%i\n", mode->width, mode->height);
    SetVideoMode(mode, mode->width, mode->height);

    // Save settings.

    screen_width = mode->width;
    screen_height = mode->height;
}
Ejemplo n.º 5
0
/* Sets up the fullscreen video mode. */
static int UpdateVideoFullscreen(void)
{
	VIDEOMODE_MODE_t display_mode = CurrentDisplayMode();
#if SUPPORTS_ROTATE_VIDEOMODE
	int rotate = VIDEOMODE_rotate90 && (PLATFORM_SupportsVideomode(display_mode, TRUE, TRUE)
	                                    || PLATFORM_SupportsVideomode(display_mode, FALSE, TRUE));
#else
	int rotate = FALSE;
#endif
	unsigned int out_w, out_h;
	double mult_w, mult_h;
	VIDEOMODE_resolution_t *res_for_mode = ResolutionForMode(display_mode, rotate);
	VIDEOMODE_resolution_t res;
	if (res_for_mode == NULL)
		return FALSE;

	res = *res_for_mode;
	if (rotate)
		RotateResolution(&res);

	GetOutArea(&out_w, &out_h, display_mode);
	UpdateCustomStretch();
	ComputeVideoArea(&res, res_for_mode, display_mode, out_w, out_h, &mult_w, &mult_h, rotate);
	CropVideoArea(&res, &out_w, &out_h, mult_w, mult_h);
	SetVideoMode(&res, display_mode, out_w, out_h, FALSE, rotate);
	return TRUE;
}
Ejemplo n.º 6
0
Monitor::~Monitor() {
    if (GetCurrentVideoMode() != mOriginalVideoMode)
        SetVideoMode(mOriginalVideoMode);
#if defined(FastOSLinux)
    XRRFreeCrtcInfo((XRRCrtcInfo*)mXRRCrtcInfo);
#endif
}
Ejemplo n.º 7
0
void HumanClientApp::Reinitialize() {
    bool fullscreen = GetOptionsDB().Get<bool>("fullscreen");
    bool fake_mode_change = GetOptionsDB().Get<bool>("fake-mode-change");
    std::pair<int, int> size = GetWindowWidthHeight();
    SetVideoMode(GG::X (size.first), GG::Y (size.second), fullscreen, fake_mode_change);
    HandleWindowResize (GG::X (size.first), GG::Y (size.second));
}
Ejemplo n.º 8
0
void Flea3Camera::Configure(Config& config) {
  // Video Mode
  SetVideoMode(config.video_mode, config.format7_mode, config.pixel_format,
               config.width, config.height);

  // Update CameraInfo here after video mode is changed
  camera_info_ = GetCameraInfo(camera_);

  // Frame Rate
  SetFrameRate(config.fps);

  // Raw Bayer
  SetRawBayerOutput(config.raw_bayer_output);

  // White Balance
  SetWhiteBalanceRedBlue(config.white_balance, config.auto_white_balance,
                         config.wb_red, config.wb_blue);

  // Exposure
  SetExposure(config.exposure, config.auto_exposure, config.exposure_value);
  SetShutter(config.auto_shutter, config.shutter_ms);
  SetGain(config.auto_gain, config.gain_db);

  SetBrightness(config.brightness);
  SetGamma(config.gamma);

  // Strobe
  SetStrobe(config.strobe_control, config.strobe_polarity);
  // Trigger
  SetTrigger(config.trigger_source, config.trigger_polarity);

  // Save this config
  config_ = config;
}
Ejemplo n.º 9
0
short InitGraph(short mode=DEFAULT_MODE)
{   if(fVGA) return 0;
    fVGA=1;
    SetVideoMode(mode);
    VideoMem = new BYTE[dX*dY];
    memset(keyPressed,0,128);
    return 1;
}
Ejemplo n.º 10
0
int DriverInitialize(void) {
	if (soundo)
		soundo = InitSound();

	SetVideoMode(fullscreen);
	InitInputStuff();			/* Initialize DInput interfaces. */
	return 1;
}
Ejemplo n.º 11
0
XnStatus LinkOniMapStream::Init()
{
	XnStatus nRetVal = XN_STATUS_OK;

	nRetVal = LinkOniStream::Init();
	XN_IS_STATUS_OK(nRetVal);

	nRetVal = FillSupportedVideoModes();
	XN_IS_STATUS_OK(nRetVal);

	// read video mode
	XnChar videoModeSection[255];
	sprintf(videoModeSection, "%s.VideoMode", m_configSection);
	OniVideoMode videoMode;
	GetVideoMode(&videoMode);

	// override with streams default values
	GetDefaultVideoMode(&videoMode);

	// override with INI config
	XnInt32 temp32;
	if (XN_STATUS_OK == xnOSReadIntFromINI(m_configFile, videoModeSection, "XResolution", &temp32))
	{
		videoMode.resolutionX = (int)temp32;
	}
	if (XN_STATUS_OK == xnOSReadIntFromINI(m_configFile, videoModeSection, "YResolution", &temp32))
	{
		videoMode.resolutionY = (int)temp32;
	}
	if (XN_STATUS_OK == xnOSReadIntFromINI(m_configFile, videoModeSection, "FPS", &temp32))
	{
		videoMode.fps = (int)temp32;
	}
	if (XN_STATUS_OK == xnOSReadIntFromINI(m_configFile, videoModeSection, "PixelFormat", &temp32))
	{
		videoMode.pixelFormat = (OniPixelFormat)temp32;
	}

	nRetVal = SetVideoMode(&videoMode);
	XN_IS_STATUS_OK(nRetVal);

	nRetVal = setIntPropertyFromINI("LinkPixelFormat", LINK_PROP_PIXEL_FORMAT);
	XN_IS_STATUS_OK(nRetVal);

	nRetVal = setIntPropertyFromINI("Compression", LINK_PROP_COMPRESSION);
	XN_IS_STATUS_OK(nRetVal);

	OniBool bMirror = TRUE;
	if (XN_STATUS_OK == xnOSReadIntFromINI(m_configFile, m_configSection, "Mirror", &temp32))
	{
		bMirror = (temp32 == 1);
	}

	nRetVal = SetMirror(bMirror);
	XN_IS_STATUS_OK(nRetVal);

	return (XN_STATUS_OK);
}
Ejemplo n.º 12
0
OniStatus LinkOniMapStream::setProperty(int propertyId, const void* data, int dataSize)
{
	XnStatus nRetVal = XN_STATUS_ERROR;

	switch(propertyId)
	{
		case ONI_STREAM_PROPERTY_VIDEO_MODE:
			EXACT_PROP_SIZE(dataSize, OniVideoMode);
			nRetVal = SetVideoMode((OniVideoMode*)data);
			XN_IS_STATUS_OK_RET(nRetVal, ONI_STATUS_ERROR);
			break;
		
		case ONI_STREAM_PROPERTY_MIRRORING:
			EXACT_PROP_SIZE(dataSize, OniBool);
			nRetVal = SetMirror(*(OniBool*)data);
			XN_IS_STATUS_OK_RET(nRetVal, ONI_STATUS_ERROR);
			break;
		
		case ONI_STREAM_PROPERTY_CROPPING:
			EXACT_PROP_SIZE(dataSize, OniCropping);
			nRetVal = SetCropping(*(OniCropping*)data);
			XN_IS_STATUS_OK_RET(nRetVal, ONI_STATUS_ERROR);
			break;

		case LINK_PROP_PIXEL_FORMAT:
			{
				ENSURE_PROP_SIZE(dataSize, XnLinkPixelFormat);
				XnFwStreamVideoMode mode = m_pInputStream->GetVideoMode();
				mode.m_nPixelFormat = *(XnFwPixelFormat*)data;
				nRetVal = m_pInputStream->SetVideoMode(mode);
				XN_IS_STATUS_OK_RET(nRetVal, ONI_STATUS_ERROR);
				break;
			}

		case LINK_PROP_COMPRESSION:
			{
				ENSURE_PROP_SIZE(dataSize, XnLinkCompressionType);
				XnFwStreamVideoMode mode = m_pInputStream->GetVideoMode();
				mode.m_nCompression = *(XnFwCompressionType*)data;
				nRetVal = m_pInputStream->SetVideoMode(mode);
				XN_IS_STATUS_OK_RET(nRetVal, ONI_STATUS_ERROR);
				break;
			}

		case PS_PROPERTY_GAIN:
			{
				ENSURE_PROP_SIZE(dataSize, XnUInt16);
				nRetVal = m_pInputStream->SetGain(*(XnUInt16*)data);
				XN_IS_STATUS_OK_RET(nRetVal, ONI_STATUS_ERROR);
				break;
			}

		default:
			return LinkOniStream::setProperty(propertyId, data, dataSize);
	}

	return ONI_STATUS_OK;
}
status_t
ArchFBArmOmap3::SetDefaultMode()
{
    CALLED();

    return SetVideoMode(gKernelArgs.frame_buffer.width,
                        gKernelArgs.frame_buffer.height,
                        gKernelArgs.frame_buffer.depth);
}
Ejemplo n.º 14
0
int InitGraph(void)
{   if(fVGA) return 0;
    fVGA=1;
    VideoMem=(char*)MK_FP(0xA000,0);
    int j=0;
    for(long i=0;i<64000L;i+=320) s320[j++]=i;
    SetVideoMode(0x13);
    return 1;
}
Ejemplo n.º 15
0
boolean ChangeVideoModeIfNeeded(boolean fullscreen)
{
#if defined(TARGET_SDL)
  if ((fullscreen && !video.fullscreen_enabled && video.fullscreen_available)||
      (!fullscreen && video.fullscreen_enabled))
    fullscreen = SetVideoMode(fullscreen);
#endif

  return fullscreen;
}
Ejemplo n.º 16
0
// Инициализация библиотеки эмулятора
void InitEGraph()
{
char pcCaption[80];
if (strlen(szVideoDriver)!=0)
  {
  strcpy(pcCaption, "SDL_VIDEODRIVER=");
  strcat(pcCaption,szVideoDriver);
  putenv(pcCaption);
  }
if (strlen(szAudioDriver)!=0)
  {
  strcpy(pcCaption, "SDL_AUDIODRIVER=");
  strcat(pcCaption,szAudioDriver);
  putenv(pcCaption);
  }
//putenv("SDL_VIDEODRIVER=windib");
//putenv("SDL_AUDIODRIVER=waveout");
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER);
if (!bMute)
  bMute=SDL_InitSubSystem(SDL_INIT_AUDIO);

char pcDrvName[20];
strcpy(pcCaption, "Emu80/SDL v. 3.14 development (video: ");
SDL_VideoDriverName(pcDrvName, 20);
strcat(pcCaption,pcDrvName);
if (!bMute)
  {
  strcat(pcCaption,", audio: ");
  SDL_AudioDriverName(pcDrvName, 20);
  strcat(pcCaption,pcDrvName);
  }
strcat(pcCaption,"), F10 - menu");

//SDL_WM_SetCaption("Emu80 / SDL", 0);
SDL_WM_SetCaption(pcCaption, 0);

atexit(SDL_Quit);

//semDraw=SDL_CreateSemaphore(1);

/*sfScreen = SDL_SetVideoMode(640, 480, 8,
                            SDL_HWSURFACE |
                            SDL_HWPALETTE);*/
pcScreenBuf=new char[160*64];
ClearScreen();
LoadFonts();

SetVideoMode(vmText30);
//ChangeResolution();

//SDL_ShowCursor(SDL_DISABLE);
ClearScreen();

InitAudio();
}
Ejemplo n.º 17
0
static int SetVideoMode (lua_State * L)
{
	int width = static_cast<int>(lua_tonumber(L, 1));
	int height = static_cast<int>(lua_tonumber(L, 2));
	int bpp = static_cast<int>(lua_tonumber(L, 3));
	SDL_bool bFullScreen = static_cast<SDL_bool>(lua_toboolean(L, 4));

	SetVideoMode(width, height, bpp, bFullScreen);

	return 0;
}
Ejemplo n.º 18
0
CScreen::CScreen(Uint32 W, Uint32 H, Uint32 BPP, Uint32 Flags)
{
	uiWidth  = W;
	uiHeight = H;
	uiBPP 	 = BPP;
	uiFlags	 = Flags;

	GetFlags();
	SetVideoMode();
	Clear();
}
Ejemplo n.º 19
0
RString RageDisplay_D3D::Init( const VideoModeParams &p, bool /* bAllowUnacceleratedRenderer */ )
{
	GraphicsWindow::Initialize( true );

	LOG->Trace( "RageDisplay_D3D::RageDisplay_D3D()" );
	LOG->MapLog("renderer", "Current renderer: Direct3D");

	g_pd3d = Direct3DCreate9(D3D_SDK_VERSION);
	if(!g_pd3d)
	{
		LOG->Trace( "Direct3DCreate9 failed" );
		return D3D_NOT_INSTALLED.GetValue();
	}

	if( FAILED( g_pd3d->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &g_DeviceCaps) ) )
		return HARDWARE_ACCELERATION_NOT_AVAILABLE.GetValue();
			

	D3DADAPTER_IDENTIFIER9	identifier;
	g_pd3d->GetAdapterIdentifier( D3DADAPTER_DEFAULT, 0, &identifier );

	LOG->Trace( 
		"Driver: %s\n"
		"Description: %s\n"
		"Max texture size: %d\n"
		"Alpha in palette: %s\n",
		identifier.Driver, 
		identifier.Description,
		g_DeviceCaps.MaxTextureWidth,
		(g_DeviceCaps.TextureCaps & D3DPTEXTURECAPS_ALPHAPALETTE) ? "yes" : "no" );

	LOG->Trace( "This display adaptor supports the following modes:" );
	D3DDISPLAYMODE mode;

	UINT modeCount = g_pd3d->GetAdapterModeCount(D3DADAPTER_DEFAULT, g_DefaultAdapterFormat);

	for( UINT u=0; u < modeCount; u++ )
		if( SUCCEEDED( g_pd3d->EnumAdapterModes( D3DADAPTER_DEFAULT, g_DefaultAdapterFormat, u, &mode ) ) )
			LOG->Trace( "  %ux%u %uHz, format %d", mode.Width, mode.Height, mode.RefreshRate, mode.Format );

	g_PaletteIndex.clear();
	for( int i = 0; i < 256; ++i )
		g_PaletteIndex.push_back(i);

	// Save the original desktop format.
	g_pd3d->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &g_DesktopMode );

	/* Up until now, all we've done is set up g_pd3d and do some queries. Now,
	 * actually initialize the window. Do this after as many error conditions as
	 * possible, because if we have to shut it down again we'll flash a window briefly. */
	bool bIgnore = false;
	return SetVideoMode( p, bIgnore );
}
Ejemplo n.º 20
0
void CSDL_ApplicationBase::ToggleFullscreen() {
    m_nScreenFlags ^= SDL_FULLSCREEN;
    m_bIsFullscreen = (m_nScreenFlags & SDL_FULLSCREEN) ? false : true;

    if( SetVideoMode(m_nScreenWidth, m_nScreenHeight, m_nScreenBPP, m_nScreenFlags) ) {
        if( m_bIsOpenGL ) {
            // TODO: reaquire open gl context, reload textures and states :(
        }
    } else {
        MsgBox("Unable to toggle fullscreen");
    }

}
Ejemplo n.º 21
0
CScreen::CScreen(Uint32 W, Uint32 H, Uint32 BPP, Uint32 Flags, const char* CC_p_Title)
{
	uiWidth  = W;
	uiHeight = H;
	uiBPP 	 = BPP;
	uiFlags	 = Flags;

	SDL_WM_SetCaption(CC_p_Title, 0);

	GetFlags();
	SetVideoMode();
	Clear();
}
Ejemplo n.º 22
0
IMAQdxError Camera::Start() {
	// create an image
	printf("Opening camera %s\n", camInfo[camera].InterfaceName);
	imaqError = IMAQdxOpenCamera(camInfo[camera].InterfaceName,
			IMAQdxCameraControlModeController, &session);
	if (imaqError != IMAQdxErrorSuccess) {
		printf("IMAQdxOpenCamera error: %x\n", imaqError);
		session = ULONG_MAX;
		return imaqError;
	}
	// imaqError = Camera::SetMode();
	if (strstr(camInfo[camera].ModelName, "LifeCam") != nullptr)
		SetVideoMode(416, 240, 15, false);
	else if (strstr(camInfo[camera].ModelName, "Logitech Webcam") != nullptr)
		SetVideoMode(640, 360, 24, false);
	else {
		if (!SetVideoMode(800, 600, 10, false)) // Genuis wide angle camera, low frame rate
			SetVideoMode(320, 240, 15, false); // default to a widely supported mode
	}
	if (imaqError != IMAQdxErrorSuccess) {
		return imaqError;
	}
	imaqError = IMAQdxConfigureGrab(session);
	if (imaqError != IMAQdxErrorSuccess) {
		printf("IMAQdxOpenCamera error: %x\n", imaqError);
		return imaqError;
	}
	// start to acquire images
	IMAQdxStartAcquisition(session);
	if (imaqError != IMAQdxErrorSuccess) {
		printf("IMAQdxOpenCamera error: %x\n", imaqError);
		return imaqError;
	}

	frame = imaqCreateImage(IMAQ_IMAGE_RGB, 0);
	printf("Camera Opened for %s #: %lu, frame=%x\n",
			camInfo[camera].InterfaceName, session, (unsigned int) frame);
	return imaqError;
}
Ejemplo n.º 23
0
View::View( unsigned short w, unsigned short h, short bpp,
            unsigned long flags ) {
  sfont = lfont = NULL;
  sys_icons = NULL;
  s_surface = NULL;

  SetVideoMode( w, h, bpp, flags );
  if ( !s_surface ) return;

  x = y = 0;
  allow_updates = true;
  filter = NULL;
}
Ejemplo n.º 24
0
int glutCreateWindow (const char *title)
{
   if(Initialized == 0) {
      int argc = 0;
      char *argv[] = {NULL};
      glutInit(&argc, argv);
   }

   if(Context)
      return 0;

   if(DisplayMode & GLUT_INDEX)
      VarInfo.bits_per_pixel = 8;
   else
      if(VarInfo.bits_per_pixel == 8)
	 VarInfo.bits_per_pixel = 32;
    
   if (DesiredDepth)
      VarInfo.bits_per_pixel = DesiredDepth;

   VarInfo.xoffset = 0;
   VarInfo.yoffset = 0;
   VarInfo.nonstd = 0;
   VarInfo.vmode &= ~FB_VMODE_YWRAP; /* turn off scrolling */

   SetVideoMode();
   CreateVisual();
   CreateBuffer();

   if(!(Context = glFBDevCreateContext(Visual, NULL))) {
      sprintf(exiterror, "Failure to create Context\n");
      exit(0);
   }

   if(!glFBDevMakeCurrent( Context, Buffer, Buffer )) {
      sprintf(exiterror, "Failure to Make Current\n");
      exit(0);
   }

   InitializeCursor();
   InitializeMenus();

   glutSetWindowTitle(title);

   signal(SIGWINCH, SignalWinch);

   Visible = 1;
   VisibleSwitch = 1;
   Redisplay = 1;
   return 1;
}
	OniStatus setProperty(int propertyId, const void* data, int dataSize)
	{
		if (propertyId == ONI_STREAM_PROPERTY_VIDEO_MODE)
		{
			if (dataSize != sizeof(OniVideoMode))
			{
				printf("Unexpected size: %d != %d\n", dataSize, (int)sizeof(OniVideoMode));
				return ONI_STATUS_ERROR;
			}
			return SetVideoMode((OniVideoMode*)data);
		}

		return ONI_STATUS_NOT_IMPLEMENTED;
	}
Ejemplo n.º 26
0
void glutReshapeWindow(int width, int height)
{
   if(GameMode)
      return;

   if(!ParseFBModes(width, width, height, height, 0, MAX_VSYNC))
      return;

   signal(SIGWINCH, SIG_IGN);

   SetVideoMode();
   signal(SIGWINCH, SignalWinch);
   Resized = 1;
}
Ejemplo n.º 27
0
short InitGraph(short mode=SVGA256_320x200)
{   if(fVGA) return 0;
    fVGA=1;
    SetVideoMode(mode);
    if(mode==SVGA256_320x200)
    {
        int j=0;
        for(long i=0; i<64000L; i+=320) s320[j++]=i;
        VideoMem = vga_getgraphmem();
    }
    else
        VideoMem = NULL;
    return 1;
}
Ejemplo n.º 28
0
bool CVideoMode::SetVideoMode(int w, int h, int bpp, bool fullscreen)
{
	Uint32 flags = SDL_OPENGL;
	if (fullscreen)
		flags |= SDL_FULLSCREEN;
	else
		flags |= SDL_RESIZABLE;

	SDL_Surface* screen = SDL_SetVideoMode(w, h, bpp, flags);

	if (!screen)
	{
		// If fullscreen fails, try windowed mode
		if (fullscreen)
		{
			LOGWARNING(L"Failed to set the video mode to fullscreen for the chosen resolution "
				L"%dx%d:%d (\"%hs\"), falling back to windowed mode",
				w, h, bpp, SDL_GetError());
			// Using default size for the window for now, as the attempted setting
			// could be as large, or larger than the screen size.
			return SetVideoMode(DEFAULT_WINDOW_W, DEFAULT_WINDOW_H, bpp, false);		
		}
		else
		{
			LOGERROR(L"SetVideoMode failed: %dx%d:%d %d (\"%hs\")",
				w, h, bpp, fullscreen ? 1 : 0, SDL_GetError());
			return false;
		}
	}

	if (fullscreen)
		SDL_WM_GrabInput(SDL_GRAB_ON);
	else
		SDL_WM_GrabInput(SDL_GRAB_OFF);

	m_IsFullscreen = fullscreen;

	// Grab the current video settings
	m_CurrentW = screen->w;
	m_CurrentH = screen->h;
	m_CurrentBPP = screen->format->BitsPerPixel;

	g_xres = m_CurrentW;
	g_yres = m_CurrentH;

	return true;
}
Ejemplo n.º 29
0
int video_set_mode(s_videomodes videomodes)
{
	stored_videomodes = videomodes;
	yuv_mode = 0;

	if(videomodes.hRes==0 && videomodes.vRes==0)
	{
		Term_Gfx();
		return 0;
	}

	videomodes = setupPreBlitProcessing(videomodes);

	// 8-bit color should be transparently converted to 32-bit
	assert(videomodes.pixel == 2 || videomodes.pixel == 4);

	// try OpenGL initialization first
	if(savedata.usegl[savedata.fullscreen] && video_gl_set_mode(videomodes)) return 1;
	else opengl = 0;

	if(!SetVideoMode(videomodes.hRes * videomodes.hScale,
	                 videomodes.vRes * videomodes.vScale,
	                 videomodes.pixel * 8, false))
	{
		return 0;
	}

	if(savedata.glfilter[savedata.fullscreen] ||
	   (videomodes.hScale == 1 && videomodes.vScale == 1 && !savedata.fullscreen))
		SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "nearest");
	else
		SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");

	texture = SDL_CreateTexture(renderer,
	                            pixelformats[videomodes.pixel-1],
	                            SDL_TEXTUREACCESS_STREAMING,
	                            videomodes.hRes, videomodes.vRes);

	SDL_ShowCursor(SDL_DISABLE);
	SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND);
	video_stretch(savedata.stretch);
#ifdef GCW0
SDL_RenderSetScale(renderer, 0.5, 0.5);
#endif
	return 1;
}
Ejemplo n.º 30
0
// creates the MSGL window and it's OpenGL contexts
bool C3dView::Create ( int x, int y, bool fullScreen, bool resizeable, bool caption )
{
	if (!SDL_WasInit(SDL_INIT_VIDEO))
	{
		if ( SDL_Init(SDL_INIT_VIDEO ) < 0 ) //|SDL_INIT_JOYSTICK
			return false;
	}
	m_bInited = true;

	m_iWinX = x;
	m_iWinY = y;
	if (!SetVideoMode(x,y,fullScreen,resizeable,caption))
		return false;

	InitGL(x,y);

	return true;
}