Syllable Forum Index Syllable
Syllable Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

SDL screen resolution

 
Post new topic   Reply to topic    Syllable Forum Index -> Syllable Desktop
View previous topic :: View next topic  
Author Message
gameblabla



Joined: 27 Jul 2015
Posts: 8

PostPosted: Mon Aug 03, 2015 11:19 am    Post subject: Reply with quote

Actually, i only had to install the developer's pack, which has libSDL and some other stuff.
Now i can properly some of my games but i have one more question before i leave :

How can you get the current screen resolution on Syllable ?

I tried with SDL_GetVideoInfo(); but it crashes !
I tried with a fixed resolution and it works just fine.
I also tried to set the resolution 0 so that SDL will fill the screen but this does not on Syllable and it crashes too...

What i'm basically doing is to scale the game to fill up the screen, kind of like it was fullscreen. (Syllable does not seem to support fullscreen resolution with SDL but it does support windows with no borders, SDL_NOFRAME)

Any idea ?

Here's what my code looks like :

const SDL_VideoInfo* info = SDL_GetVideoInfo(); //<-- calls SDL_GetVideoInfo();

screen_scale.w_display = info->current_w;
screen_scale.h_display = info->current_h;

real_screen = SDL_SetVideoMode(screen_scale.w_display, screen_scale.h_display, depth, SDL_SWSURFACE | SDL_NOFRAME);

screen_scale.w_scale = screen_scale.w_display / width;
screen_scale.h_scale = screen_scale.h_display / height;

screen_scale.w_scale_size = screen_scale.w_scale * width;
screen_scale.h_scale_size = screen_scale.h_scale * height;

screen_position.x = (screen_scale.w_display - screen_scale.w_scale_size)/2;
screen_position.y = (screen_scale.h_display - screen_scale.h_scale_size)/2;

class->Screen = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, depth, 0,0,0,0);
Back to top
View user's profile Send private message
Kaj
The Knights of Syllable


Joined: 14 Sep 2007
Posts: 2201
Location: Friesland

PostPosted: Mon Aug 03, 2015 11:34 am    Post subject: Reply with quote

The SDL function should work for getting the resolution.

There's another SDL function for setting full screen, if I remember correctly. On Syllable it's implemented with a window that covers the screen. You're always in the desktop environment, so you're not dealing with the screen directly.
Back to top
View user's profile Send private message Visit poster's website
gameblabla



Joined: 27 Jul 2015
Posts: 8

PostPosted: Tue Aug 04, 2015 5:56 pm    Post subject: Reply with quote

[quote="Kaj"]The SDL function should work for getting the resolution.[/quote]
Except it doesn't, it returns 0 with the code i've shown you above.

[quote]
There's another SDL function for setting full screen, if I remember correctly. On Syllable it's implemented with a window that covers the screen. You're always in the desktop environment, so you're not dealing with the screen directly.[/quote]
I would like to know that function, because i have no idea what it could be...

Is there another way, even if it is specific to Syllable, to get the current resolution of the screen in pixels ? Thanks
Back to top
View user's profile Send private message
Kaj
The Knights of Syllable


Joined: 14 Sep 2007
Posts: 2201
Location: Friesland

PostPosted: Tue Aug 04, 2015 7:06 pm    Post subject: Reply with quote

I'm only familiar with SDL programming in the SDL and OpenGL bindings I made for Red/System:

http://red.esperconsultancy.nl/Red-SDL
http://red.esperconsultancy.nl/Red-OpenGL/dir?ci=trunk&name=platforms

In the examples there are the small PeterPaint paint program I made and a few OpenGL examples. I use SDL_SetVideoMode there. I haven't used SDL_GetVideoInfo.

You're usually supposed to call SDL_SetVideoMode before calling SDL_GetVideoInfo, though. If you call SDL_SetVideoMode like you do with the window size of SDL_GetVideoInfo, and without specifying full screen, you haven't specified a window size at all.

SDL_SetVideoMode has an additional mode mask for full screen. As far as I know, this is the way you're supposed to do it. The SDL headers don't say anything about using size 0. They mention depth 0, but that means current depth, so if anything, size 0 may mean unchanged size. SDL_FULLSCREEN implies SDL_NOFRAME, so you don't need that. SDL also has an SDL_WM_ToggleFullScreen function that you can use before SDL_SetVideoMode, but I'm not sure Syllable supports it.

Of course Syllable has native APIs for managing resolutions, but they're in C++, and SDL wouldn't know what you are doing. If you are writing an SDL program, you need to manage resolutions through SDL.
Back to top
View user's profile Send private message Visit poster's website
gameblabla



Joined: 27 Jul 2015
Posts: 8

PostPosted: Wed Aug 05, 2015 12:27 pm    Post subject: SDL Reply with quote

Let's recap :

SDL_FULLSCREEN is supposed to imply SDL_NOFRAME, except that on Syllable,
it doesn't do anything.
SDL_NOFRAME works properly on the other hand.
I found a way Syllable-specific way to get the current resol
SDL_GetInfo does not work properly on Syllable OS either and it returns 0.
Setting 0 to SetVideoMode, instead of using the current screen resolution, set the resolution to 0 and as a result, returns an error.


>> Of course Syllable has native APIs for managing resolutions, but they're in C++, and
>> SDL wouldn't know what you are doing. If you are writing an SDL program, you need >> to manage resolutions through SDL
That's not a problem, we can just store it in a variable.
This is how my function looks like now :

os::Desktop cDesktop;
os::IPoint point = cDesktop.GetResolution();

screen_scale.w_display = point.x;
screen_scale.h_display = point.y;

Unfortunely, this means that i have to compile this function with g++ so it makes building the game a bit more complicated but i eventually found a way.
So i'm now using Syllable's libraries to get the current resolution, good.

However, when i tried to link the object files, it complains about
"undefined reference to os::Desktop::GetResolution"...

Obviously, i need to link with Syllable's own system libraries but how are they called ?
-latheos ?

Thanks
Back to top
View user's profile Send private message
Kaj
The Knights of Syllable


Joined: 14 Sep 2007
Posts: 2201
Location: Friesland

PostPosted: Wed Aug 05, 2015 2:23 pm    Post subject: Reply with quote

It's -lsyllable

Have you read our development tutorial?

I suspect you're using SDL in non-standard ways. Many SDL programs have been compiled on Syllable. They usually only need small adjustments or none at all.
Back to top
View user's profile Send private message Visit poster's website
gameblabla



Joined: 27 Jul 2015
Posts: 8

PostPosted: Thu Aug 06, 2015 9:19 am    Post subject: Reply with quote

Ok, thanks kaj.
Now my game is upscaled fullscreen, unlike most of the SDL applications on Syllable.
Yes, i guess i'm using it in a non-standard way but that was the only way i could do it on Syllable OS unfortunely...
I could do the lazy way and make it run on a small window but i didn't want that...

I'm encountering another (annoying) bug though...
Does Syllable OS support relative paths like "./data" ?
It does not seem to, because i had to convert the images into C arrays to make them work.
Perhaps it only supports non-relative paths like "/boot/resources/tailtale/data" ?
Back to top
View user's profile Send private message
Kaj
The Knights of Syllable


Joined: 14 Sep 2007
Posts: 2201
Location: Friesland

PostPosted: Thu Aug 06, 2015 9:49 am    Post subject: Reply with quote

Syllable is highly POSIX compliant. We're using a lot of standard software and we've never had problems with relative paths. It's hard to say more without seeing your exact code.

If you want to see for yourself, there are binaries for the above Red/System SDL examples here:

http://red.esperconsultancy.nl/Red-test/dir?ci=trunk&name=Syllable/RedSystem

The paint program and the sound player take a command line argument, so you can test with relative paths. Sample files are also in there.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Syllable Forum Index -> Syllable Desktop All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group