Getting the system resolution

Hi,

Is there any way of knowing the system resolution automaticly inside
SDL?

For example, if we are running the app in windows or osx, know which
resolution is being used in the desktop.

Cheers,

Nuno

Hello Nuno,

Saturday, December 2, 2006, 3:39:53 PM, you wrote:

Hi,

Is there any way of knowing the system resolution automaticly inside
SDL?

For example, if we are running the app in windows or osx, know which
resolution is being used in the desktop.

Call SDL_GetVideoMode() before you call SDL_SetVideoMode(), and the
SDL_VideoInfo structure will contain the desktop resolution.–
Best regards,
Peter mailto:@Peter_Mulholland

Hi,

I’m looking to that structure and i don’t see those fields:

typedef struct{
Uint32 hw_available:1;
Uint32 wm_available:1;
Uint32 blit_hw:1;
Uint32 blit_hw_CC:1;
Uint32 blit_hw_A:1;
Uint32 blit_sw:1;
Uint32 blit_sw_CC:1;
Uint32 blit_sw_A:1;
Uint32 blit_fill;
Uint32 video_mem;
SDL_PixelFormat *vfmt;
} SDL_VideoInfo;

Which one is it?

And about the function. Did you mean SDL_GetVideoInfo()

Thx,

Best regards,

NunoEm Dec 2, 2006, ?s 3:49 PM, Peter Mulholland escreveu:

Call SDL_GetVideoMode() before you call SDL_SetVideoMode(), and the
SDL_VideoInfo structure will contain the desktop resolution.

I believe its a new enough addition, you may need a newer version of SDL.On 12/2/06, Nuno Santos wrote:

Hi,

I’m looking to that structure and i don’t see those fields:

typedef struct{
Uint32 hw_available:1;
Uint32 wm_available:1;
Uint32 blit_hw:1;
Uint32 blit_hw_CC:1;
Uint32 blit_hw_A:1;
Uint32 blit_sw:1;
Uint32 blit_sw_CC:1;
Uint32 blit_sw_A:1;
Uint32 blit_fill;
Uint32 video_mem;
SDL_PixelFormat *vfmt;
} SDL_VideoInfo;

Which one is it?

And about the function. Did you mean SDL_GetVideoInfo()

Thx,

Best regards,

Nuno

Em Dec 2, 2006, ?s 3:49 PM, Peter Mulholland escreveu:

Call SDL_GetVideoMode() before you call SDL_SetVideoMode(), and the

SDL_VideoInfo structure will contain the desktop resolution.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

I have the latest version installed. Maybe the documentian is older…

How can i see if my version has the needed field?Em Dec 2, 2006, ?s 10:46 PM, Brian escreveu:

I believe its a new enough addition, you may need a newer version
of SDL.

On 12/2/06, Nuno Santos <@Nuno_Santos> wrote:

Hi,

I’m looking to that structure and i don’t see those fields:

typedef struct{
Uint32 hw_available:1;
Uint32 wm_available:1;
Uint32 blit_hw:1;
Uint32 blit_hw_CC:1;
Uint32 blit_hw_A:1;
Uint32 blit_sw:1;
Uint32 blit_sw_CC:1;
Uint32 blit_sw_A:1;
Uint32 blit_fill;
Uint32 video_mem;
SDL_PixelFormat *vfmt;
} SDL_VideoInfo;

Which one is it?

And about the function. Did you mean SDL_GetVideoInfo()

Thx,

Best regards,

Nuno

Em Dec 2, 2006, ?s 3:49 PM, Peter Mulholland escreveu:

Call SDL_GetVideoMode() before you call SDL_SetVideoMode(), and the

SDL_VideoInfo structure will contain the desktop resolution.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Hello Nuno,

Saturday, December 2, 2006, 10:58:08 PM, you wrote:

I have the latest version installed. Maybe the documentian is older…

Documentation is newer - I looked it up on the Wiki.

How can i see if my version has the needed field?

It’s in SDL 1.2.11 at least, so you don’t have the latest version
installed. You are looking for the current_w and current_h fields in
the SDL_VideoInfo struct.–
Best regards,
Peter mailto:@Peter_Mulholland

Maybe this is what you’re looking for?

#include <stdio.h>
#include <stdlib.h>

#include <SDL.h>
#include <SDL_syswm.h>

int main(void)
{
int w, h, x11screen;
const SDL_VideoInfo *info;
SDL_PixelFormat *vfmt;
SDL_SysWMinfo winfo;

if (SDL_Init(SDL_INIT_VIDEO))
{
printf("\nCan’t initialize SDL\n\n");
return 1;
}

info = SDL_GetVideoInfo();

printf("\n\nhw avail: %d", info->hw_available);
printf("\nwm avail: %d", info->wm_available);
printf("\nblit hw: %d", info->blit_hw);
printf("\nvideo memory %d", info->video_mem);

if (info->vfmt)
{
vfmt = info->vfmt;
printf("\nBits per pixel %d", vfmt->BitsPerPixel);
printf("\nBytes per pixel %d", vfmt->BytesPerPixel);
}

SDL_VERSION(&winfo.version);

if (SDL_GetWMInfo(&winfo) > 0)
{
if (winfo.subsystem == SDL_SYSWM_X11)
{
x11screen = DefaultScreen(winfo.info.x11.display);
w = DisplayWidth(winfo.info.x11.display, x11screen);
h = DisplayHeight(winfo.info.x11.display, x11screen);
printf("\nScreen width %d, height %d", w, h);
}
else
printf("\n\nNOT X11!");
}
else
printf("\n\nCan’t get window manager info!");

printf("\n\n");

SDL_Quit();
return 0;
}On Sat December 2 2006 13:27, Nuno Santos wrote:

I’m looking to that structure and i don’t see those fields:

I have errors.

I think i don’t have the right version. My version is 1.2.11.

I have the following errors:

error: ‘SDL_SysWMinfo’ has no member named 'subsystem’
error: ‘SDL_SYSWM_X11’ undeclared (first use in this function)
error: ‘SDL_SysWMinfo’ has no member named ‘info’

Thx,

NunoEm Dec 2, 2006, ?s 11:25 PM, Jeff escreveu:

On Sat December 2 2006 13:27, Nuno Santos wrote:

I’m looking to that structure and i don’t see those fields:

Maybe this is what you’re looking for?

#include <stdio.h>
#include <stdlib.h>

#include <SDL.h>
#include <SDL_syswm.h>

int main(void)
{
int w, h, x11screen;
const SDL_VideoInfo *info;
SDL_PixelFormat *vfmt;
SDL_SysWMinfo winfo;

if (SDL_Init(SDL_INIT_VIDEO))
{
printf("\nCan’t initialize SDL\n\n");
return 1;
}

info = SDL_GetVideoInfo();

printf("\n\nhw avail: %d", info->hw_available);
printf("\nwm avail: %d", info->wm_available);
printf("\nblit hw: %d", info->blit_hw);
printf("\nvideo memory %d", info->video_mem);

if (info->vfmt)
{
vfmt = info->vfmt;
printf("\nBits per pixel %d", vfmt->BitsPerPixel);
printf("\nBytes per pixel %d", vfmt->BytesPerPixel);
}

SDL_VERSION(&winfo.version);

if (SDL_GetWMInfo(&winfo) > 0)
{
if (winfo.subsystem == SDL_SYSWM_X11)
{
x11screen = DefaultScreen(winfo.info.x11.display);
w = DisplayWidth(winfo.info.x11.display, x11screen);
h = DisplayHeight(winfo.info.x11.display, x11screen);
printf("\nScreen width %d, height %d", w, h);
}
else
printf("\n\nNOT X11!");
}
else
printf("\n\nCan’t get window manager info!");

printf("\n\n");

SDL_Quit();
return 0;
}


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Hello Nuno,

Sunday, December 3, 2006, 8:44:03 PM, you wrote:

I have errors.

I think i don’t have the right version. My version is 1.2.11.

You cannot have 1.2.11 if you don’t have current_w and current_h fields
in the SDL_VideoInfo struct. If you are working on Linux, and using
your distribution’s packaged version which says it is 1.2.11, it is
lying - remove it and install from a source build. Ideally, you should
check out the version from SVN and use this.

If you are using Windows, I just checked the SDL-devel-1.2.11-VC6.zip
and SDL-devel-1.2.11-mingw32.tar.gz archives - they both have the
SDL_video.h that defines current_w and current_h as well.

I have the following errors:

error: ‘SDL_SysWMinfo’ has no member named 'subsystem’
error: ‘SDL_SYSWM_X11’ undeclared (first use in this function)
error: ‘SDL_SysWMinfo’ has no member named ‘info’

This will only work on Linux/BSD/any X11 system, and isn’t portable.–
Best regards,
Peter mailto:@Peter_Mulholland

Hi,

I’m working wih the sdl latest stable compiled source.

I’m working with OSX, so i won’t be able to get this, right?

Cheers,

NunoEm Dec 3, 2006, ?s 10:29 PM, Peter Mulholland escreveu:

Hello Nuno,

Sunday, December 3, 2006, 8:44:03 PM, you wrote:

I have errors.

I think i don’t have the right version. My version is 1.2.11.

You cannot have 1.2.11 if you don’t have current_w and current_h
fields
in the SDL_VideoInfo struct. If you are working on Linux, and using
your distribution’s packaged version which says it is 1.2.11, it is
lying - remove it and install from a source build. Ideally, you should
check out the version from SVN and use this.

If you are using Windows, I just checked the SDL-devel-1.2.11-VC6.zip
and SDL-devel-1.2.11-mingw32.tar.gz archives - they both have the
SDL_video.h that defines current_w and current_h as well.

I have the following errors:

error: ‘SDL_SysWMinfo’ has no member named 'subsystem’
error: ‘SDL_SYSWM_X11’ undeclared (first use in this function)
error: ‘SDL_SysWMinfo’ has no member named ‘info’

This will only work on Linux/BSD/any X11 system, and isn’t portable.


Best regards,
Peter mailto:darkmatter at freeuk.com


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Hello Nuno,

Monday, December 4, 2006, 12:42:03 AM, you wrote:

Hi,

I’m working wih the sdl latest stable compiled source.

Does this mean you built your own, or you downloaded
http://www.libsdl.org/release/SDL-devel-1.2.11-extras.dmg ?

I’m working with OSX, so i won’t be able to get this, right?

You can get the absolute latest SDL from Subversion under OS X, but it
means installing a Subversion client, using it from Terminal, then
building your own SDL using Xcode.–
Best regards,
Peter mailto:@Peter_Mulholland

Hi Peter,

No. I build myself the latest stable sources (1.2.11)

Do i have advantages in building the svn shot?

Best regards,

Nuno

Peter Mulholland escreveu:> Hello Nuno,

Monday, December 4, 2006, 12:42:03 AM, you wrote:

Hi,

I’m working wih the sdl latest stable compiled source.

Does this mean you built your own, or you downloaded
http://www.libsdl.org/release/SDL-devel-1.2.11-extras.dmg ?

I’m working with OSX, so i won’t be able to get this, right?

You can get the absolute latest SDL from Subversion under OS X, but it
means installing a Subversion client, using it from Terminal, then
building your own SDL using Xcode.

I have SDL 1.2.11 on osx which I got from darwinports and it has
current_w and current_h at lines 164-165 of
/opt/local/include/SDL/SDL_video.hOn 04/12/06, Nuno Santos wrote:

Hi Peter,

No. I build myself the latest stable sources (1.2.11)

Do i have advantages in building the svn shot?

Best regards,

Nuno

Peter Mulholland escreveu:

Hello Nuno,

Monday, December 4, 2006, 12:42:03 AM, you wrote:

Hi,

I’m working wih the sdl latest stable compiled source.

Does this mean you built your own, or you downloaded
http://www.libsdl.org/release/SDL-devel-1.2.11-extras.dmg ?

I’m working with OSX, so i won’t be able to get this, right?

You can get the absolute latest SDL from Subversion under OS X, but it
means installing a Subversion client, using it from Terminal, then
building your own SDL using Xcode.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Hi Artem,

I have found it on my sources as well.

I also discovered that what was being linked was the framework.

Well, but its kind of useless now since i cant make it work on OSX.

With this story of the framework linking, i deleted all the
frameworks (SDL and SDL ttf) to link against the built sources.

I have SDL ttf installed just like SDL and Xcode is not finding SDL
ttf lib file.

Its says that its referenced by a certain file that doesnt not exist,
but the file exists! :S

Does any one has a tip for this problem?

Thx,

Best regards,

Nuno SantosEm Dec 5, 2006, ?s 12:04 AM, Artem Baguinski escreveu:

I have SDL 1.2.11 on osx which I got from darwinports and it has
current_w and current_h at lines 164-165 of
/opt/local/include/SDL/SDL_video.h

On 04/12/06, Nuno Santos <@Nuno_Santos> wrote:

Hi Peter,

No. I build myself the latest stable sources (1.2.11)

Do i have advantages in building the svn shot?

Best regards,

Nuno

Peter Mulholland escreveu:

Hello Nuno,

Monday, December 4, 2006, 12:42:03 AM, you wrote:

Hi,

I’m working wih the sdl latest stable compiled source.

Does this mean you built your own, or you downloaded
http://www.libsdl.org/release/SDL-devel-1.2.11-extras.dmg ?

I’m working with OSX, so i won’t be able to get this, right?

You can get the absolute latest SDL from Subversion under OS X,
but it
means installing a Subversion client, using it from Terminal, then
building your own SDL using Xcode.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Hello Nuno,

Tuesday, December 5, 2006, 9:20:19 AM, you wrote:

Hi Artem,

I have found it on my sources as well.

I also discovered that what was being linked was the framework.

Well, but its kind of useless now since i cant make it work on OSX.

With this story of the framework linking, i deleted all the
frameworks (SDL and SDL ttf) to link against the built sources.

I have SDL ttf installed just like SDL and Xcode is not finding SDL
ttf lib file.

Its says that its referenced by a certain file that doesnt not exist,
but the file exists! :S

Does any one has a tip for this problem?

First off, the versions of SDL etc you installed, did you build your
own frameworks, or did you build them from Terminal using ./configure
and make ?

If you are using frameworks, make sure you have SDL.framework etc in
ONE PLACE ONLY and make sure this is the copy you want to use. I
normally use my Home folders Library/Frameworks/ for this.

Finally, if you use frameworks, they expect all headers to be referred
to by #include <FrameworkName/header.h>, so for SDL this would be
#include <SDL/SDL.h>. The problem with this, is the standard headers
don’t adhere to that. The fix is either a) manually adding the path to
the frameworks Headers folder, or b) correcting the headers in the
Framework to follow this.–
Best regards,
Peter mailto:@Peter_Mulholland

Hi,

No. I built my own sources and i’m including them in a standard way,
but curiosly i can only get things that use SDL_tff with frameworks.

I’m doing something wrong for sure.Em Dec 5, 2006, ?s 10:08 AM, Peter Mulholland escreveu:

Hello Nuno,

Tuesday, December 5, 2006, 9:20:19 AM, you wrote:

Hi Artem,

I have found it on my sources as well.

I also discovered that what was being linked was the framework.

Well, but its kind of useless now since i cant make it work on OSX.

With this story of the framework linking, i deleted all the
frameworks (SDL and SDL ttf) to link against the built sources.

I have SDL ttf installed just like SDL and Xcode is not finding SDL
ttf lib file.

Its says that its referenced by a certain file that doesnt not exist,
but the file exists! :S

Does any one has a tip for this problem?

First off, the versions of SDL etc you installed, did you build your
own frameworks, or did you build them from Terminal using ./configure
and make ?

If you are using frameworks, make sure you have SDL.framework etc in
ONE PLACE ONLY and make sure this is the copy you want to use. I
normally use my Home folders Library/Frameworks/ for this.

Finally, if you use frameworks, they expect all headers to be referred
to by #include <FrameworkName/header.h>, so for SDL this would be
#include <SDL/SDL.h>. The problem with this, is the standard headers
don’t adhere to that. The fix is either a) manually adding the path to
the frameworks Headers folder, or b) correcting the headers in the
Framework to follow this.


Best regards,
Peter mailto:darkmatter at freeuk.com


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl