LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 08-04-2009, 06:43 AM   #1
yezu
LQ Newbie
 
Registered: Apr 2007
Location: Gdynia, Poland
Distribution: Fedora 10/11
Posts: 22

Rep: Reputation: 15
Possible screen resolutions in C/C++


Hi!
I am writing a game in OpenGL and I have encountered a problem.
I cannot find a way to get all possible screen resolutions.

SDL is not much of help unfortunately as SDL_ListModes tells me that "all resolutions are supported" which is pretty much useless :/

I have been looking for the xrandr code, and I found it a bit overwhelming :/

Can anyone help me find a solution, or at least provide some hints?

thanks
 
Old 08-04-2009, 07:40 AM   #2
dmail
Member
 
Registered: Oct 2005
Posts: 970

Rep: Reputation: Disabled
SDL_GetVideoInfo
Quote:
If it is called before SDL_SetVideoMode, the vfmt member of the returned structure will contain the pixel format of the best video mode.
... This read-only structure is returned by SDL_GetVideoInfo. It contains information on either the best available mode if called before SDL_SetVideoMode or the current video mode if called after SDL_SetVideoMode.

Last edited by dmail; 08-04-2009 at 07:45 AM.
 
Old 08-04-2009, 08:09 AM   #3
yezu
LQ Newbie
 
Registered: Apr 2007
Location: Gdynia, Poland
Distribution: Fedora 10/11
Posts: 22

Original Poster
Rep: Reputation: 15
Thanks but SDL_GetVideoInfo is also useless as it only gives me the CURRENT resolution :/
 
Old 08-04-2009, 08:20 AM   #4
dmail
Member
 
Registered: Oct 2005
Posts: 970

Rep: Reputation: Disabled
Code:
std::list<LVD::Renderer::Resoultion> create_mode_list()
{
	SDL_PixelFormat format;
	SDL_Rect **modes;
	std::list<Resoultion_entry> mode_list;
	int loops(0);
	int bpp(0);
	do
	{
		//format.BitsPerPixel seems to get zeroed out on my windows box
		switch(loops)
		{
			case 0://32 bpp
				format.BitsPerPixel = 32;
				bpp = 32;
				break;
			case 1://24 bpp
				format.BitsPerPixel = 24;
				bpp = 24;
				break;
			case 2://16 bpp
				format.BitsPerPixel = 16;
				bpp = 16;
				break;
		}

		//get available fullscreen/hardware modes
		modes=SDL::SDL_ListModes(&format, SDL_FULLSCREEN);
		if(modes)
		{
			for(int i=0;modes[i];++i)
			{
				LVD::Renderer::Resoultion entry(modes[i]->w,modes[i]->h, bpp/*format.BitsPerPixel*/, 0);
				mode_list.push_back(entry);
			}
		}
	}while(++loops != 3);
	return mode_list;
}

Last edited by dmail; 08-04-2009 at 08:23 AM. Reason: fixed tab spacing
 
Old 08-04-2009, 08:54 AM   #5
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2014.08, Slack14.1 DebWheezy, +50+ other Linux OS, for test only.
Posts: 14,284

Rep: Reputation: 2664Reputation: 2664Reputation: 2664Reputation: 2664Reputation: 2664Reputation: 2664Reputation: 2664Reputation: 2664Reputation: 2664Reputation: 2664Reputation: 2664
Do you mean
640x480, 800x600, 1024x768, 1152x864, 1280x768, 1280x960, 1280x1024
like the settings in 'gl-117' ?
http://www.heptargon.de/gl-117/gl-117.html
(( gl-117-1.3.2-src/src/conf.cpp ))
.....
Other OpenGL game with res. settings : Emilia Pinball
http://pinball.sourceforge.net/
.....

Last edited by knudfl; 08-04-2009 at 08:58 AM.
 
  


Reply

Tags
c++, resolution, screen, x11


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Clone Screen Independant Screen Resolutions F M J Linux - Desktop 0 07-24-2007 02:38 PM
Different screen resolutions in X jhipkiss Debian 1 07-31-2006 04:56 PM
Not all screen resolutions available no way Ubuntu 2 02-05-2006 09:05 PM
Screen Resolutions satanic_linux Slackware 7 05-20-2004 09:01 AM
changing screen resolutions dtheorem Linux - Software 1 10-07-2003 01:46 PM


All times are GMT -5. The time now is 11:02 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration