LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-27-2007, 04:02 AM   #1
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
screen resolution API


I have a QT-based app which has a full screen mode feature. QT's full screen feature works by resizing the application window to the size of the desktop (the virtual desktop if you are using one), and removing window borders. It's OK, but I'd really like a mechanism to be able to switch to other screen resolutions as well.

Does anyone know of an API which will let me:
  • Get a list of available resolutions
  • Switch to a new resolution
  • The kicker: Is cross platform (win/osx/linux/other *nix)

It's the last criteria which is the real killer. The app used to use SDL for the main application window (and as such used to have this functionality), but I would very much like to drop the dependency to SDL and instead use a much smaller library which just does screen resolution switching. SDL is also somewhat unsuitable because it can only switch between full screen and windowed mode at start time on OSX and Windows, and I would like to be able to make this switch at any time.
 
Old 10-27-2007, 08:18 AM   #2
dmail
Member
 
Registered: Oct 2005
Posts: 970

Rep: Reputation: Disabled
Quote:
SDL is also somewhat unsuitable because it can only switch between full screen and windowed mode at start time on OSX and Windows, and I would like to be able to make this switch at any time.
This is true as the SDL_WM_ToggleFullScreen does not work on these os's yet it is really easy to implement your own by tearing it down and rebuilding it.

Code:
// Toggles the window between full-screen and not
void Sdl_window::toggle_fullscreen()
{
	m_fullscreen = !m_fullscreen;

	if(! ( SDL_WM_ToggleFullScreen( m_surface ) )  )//doesnt work on windows.
	{   
		//that failed so lets try in code ourselves
		if( m_fullscreen )
		{
			m_video_flags |= SDL_FULLSCREEN;//or the bit mask
			//reset the videomode
			m_surface = SDL_SetVideoMode( m_full_w, m_full_h, m_bpp, m_video_flags );
		}
		else
		{	
			m_video_flags &= ~SDL_FULLSCREEN;//remove the bit mask
			//reset the videomode
			m_surface = SDL_SetVideoMode( m_rect.w, m_rect.h, m_bpp, m_video_flags );
		}

		if(!m_surface)//failed to get a surface
		{
			throw std::runtime_error(std::string("SDL Set Video mode failed. error: ") + SDL_GetError() );
		}
	}

}
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
change screen resolution of xdm login screen in suse linux anon104 Linux - Desktop 2 04-02-2007 09:26 AM
Changing screen brightness through api morph_ind Programming 2 10-10-2006 08:13 PM
How do i fix screen resolution / monitor choice while screen is pretty much unreadabl tinkerdog Fedora 2 09-08-2006 03:53 AM
default screen resolution smaller than max. resolution ?? Thoddy Linux - General 2 11-10-2005 01:33 AM
Unable to configure screen resolution for 15.2" LCD screen in Fedore Core 1 schu Linux - Newbie 3 01-02-2004 05:39 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:18 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration