LinuxQuestions.org
Social Bookmarking all things Linux and Open Source
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

Tags used in this thread
Popular LQ Tags , , ,

Reply
 
Thread Tools
Old 08-04-2009, 06:43 AM   #1
yezu
LQ Newbie
 
Registered: Apr 2007
Location: Gdynia, Poland
Distribution: Fedora 10/11
Posts: 22
Thanked: 0
Possible screen resolutions in C/C++


[Log in to get rid of this advertisement]
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
yezu is offline  
Tag This Post , , ,
Reply With Quote
Old 08-04-2009, 07:40 AM   #2
dmail
Member
 
Registered: Oct 2005
Posts: 964
Thanked: 4
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..
dmail is offline     Reply With Quote
Old 08-04-2009, 08:09 AM   #3
yezu
LQ Newbie
 
Registered: Apr 2007
Location: Gdynia, Poland
Distribution: Fedora 10/11
Posts: 22
Thanked: 0

Original Poster
Thanks but SDL_GetVideoInfo is also useless as it only gives me the CURRENT resolution :/
yezu is offline     Reply With Quote
Old 08-04-2009, 08:20 AM   #4
dmail
Member
 
Registered: Oct 2005
Posts: 964
Thanked: 4
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
dmail is offline     Reply With Quote
Old 08-04-2009, 08:54 AM   #5
knudfl
Senior Member
 
Registered: Jan 2008
Location: Copenhagen, Denmark
Distribution: pclos2009.2, slack13, Debian Lenny (+30 others, for test only)
Posts: 2,912
Thanked: 268
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..
knudfl is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

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 07:31 PM.

Main Menu
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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration