LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 08-04-2009, 05: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, 06: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 06:45 AM.
 
Old 08-04-2009, 07: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, 07: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 07:23 AM. Reason: fixed tab spacing
 
Old 08-04-2009, 07:54 AM   #5
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,513

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
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 07:58 AM.
 
  


Reply

Tags
c++, resolution, screen, x11



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 01:38 PM
Different screen resolutions in X jhipkiss Debian 1 07-31-2006 03:56 PM
Not all screen resolutions available no way Ubuntu 2 02-05-2006 08:05 PM
Screen Resolutions satanic_linux Slackware 7 05-20-2004 08:01 AM
changing screen resolutions dtheorem Linux - Software 1 10-07-2003 12:46 PM

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

All times are GMT -5. The time now is 01:41 AM.

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