FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

SDL_VideoInfo

 
Post new topic   Reply to topic     Forum Index -> Derelict
View previous topic :: View next topic  
Author Message
mutable



Joined: 22 Jun 2010
Posts: 87

PostPosted: Sun Oct 09, 2011 4:33 am    Post subject: SDL_VideoInfo Reply with quote

I would get some informations about the current and best VideoInfo.
So I found this site: http://wiki.delphigl.com/index.php/SDL_VideoInfo
But i found in "Derelict/sdl_types" only this structure:
Code:

struct SDL_VideoInfo
{
    Uint32 flags;
    Uint32 video_mem;
    SDL_PixelFormat* vfmt;
    int current_w;
    int current_h;
}


How can i get the other flags which are describe on the site above?[/code]
Back to top
View user's profile Send private message
aldacron



Joined: 05 May 2004
Posts: 1322
Location: Seoul, South Korea

PostPosted: Sun Oct 09, 2011 6:09 am    Post subject: Re: SDL_VideoInfo Reply with quote

mutable wrote:

How can i get the other flags which are describe on the site above?


The flags you want are implemented as a bitfield on the C side. D does not support bitfields natively. Therefore, the 'flags' member you see in the Derelict implementation represents each of those flags. I've considered adding some getter functions to do some bit manipulation and return the appropriate values, but the problem is that there's no guarantee about bitfield ordering across platforms and compilers (though, I think in practice, it's all the same). So I decided to leave it to the user.

In other words, the values you want are all contained in the flags member. You just have to figure out which bits you need to pull out of it to get the information you need.
_________________
The One With D | The One With Aldacron | D Bits
Back to top
View user's profile Send private message Send e-mail
mutable



Joined: 22 Jun 2010
Posts: 87

PostPosted: Sun Oct 09, 2011 8:00 am    Post subject: Reply with quote

So it's up to me to figure out which bits i need and it is differ from OS to OS? So if i implement a solution on windows, i must figure out for myself, how it's implemented on Mac or Linux?
Back to top
View user's profile Send private message
aldacron



Joined: 05 May 2004
Posts: 1322
Location: Seoul, South Korea

PostPosted: Sun Oct 09, 2011 11:00 pm    Post subject: Reply with quote

mutable wrote:
So it's up to me to figure out which bits i need and it is differ from OS to OS? So if i implement a solution on windows, i must figure out for myself, how it's implemented on Mac or Linux?


Not necessarily. As long as the SDL binaries were compiled with the same compiler (like GCC), and the CPUs on each system have the same endianess, then you can be fairly certain of the ordering. It's not the operating system that's the issue, but the compilers available and the processors. And I've heard that, in practice, bitfield ordering is generally the same on the major compilers. I can't be sure of that, though, without major testing that I don't have the time or resources to do. And the C standard leaves it undefined. For those reasons, I don't think I should implement it in Derelict. See this StackOverflow post for more info.

With some careful consideration, it's probably possible to figure out a way to determine the ordering at runtime, but I don't think these particular flags are used enough to warrant that right now. And IIRC, the bitfield in this struct will go (or has gone) away in SDL 1.3.

If you want to be 100% sure, then you can distribute the SDL binaries with your app on each platform. That way you can guarantee bitfield ordering as long as the binaries aren't swapped out by the user. However, it's probably safe to work it out on your system and just assume it works until it blows up in the wild. But you do need to account for endianess if you plan to support Big Endian platforms.
_________________
The One With D | The One With Aldacron | D Bits
Back to top
View user's profile Send private message Send e-mail
mutable



Joined: 22 Jun 2010
Posts: 87

PostPosted: Mon Oct 10, 2011 2:29 am    Post subject: Reply with quote

Ok, if it will go away in the comming SDL Version i can disclaim too.
Furthermore it sounds like a huge work to figure out which bits are right for which data. But thanks for the reply. Smile
Back to top
View user's profile Send private message
mutable



Joined: 22 Jun 2010
Posts: 87

PostPosted: Mon Oct 10, 2011 3:18 pm    Post subject: Reply with quote

Me again.
It is possible, that the SDL Macros SDL_putenv or SDL_envars not in Derelict?
Back to top
View user's profile Send private message
aldacron



Joined: 05 May 2004
Posts: 1322
Location: Seoul, South Korea

PostPosted: Tue Oct 11, 2011 5:30 am    Post subject: Reply with quote

mutable wrote:
Me again.
It is possible, that the SDL Macros SDL_putenv or SDL_envars not in Derelict?


SDL_putenv exists on the C side for cross-platform compatibility. It's part of SDL_stdinc.h, which provides defines for a large number of C standard library and posix functions. In D, we don't have to worry about that, and I'm not about to add all of that to Derelict since it's already all part of Phobos.

As for SDL_envvars, it is listed in the old SDL wiki, but only as a category. There is no SDL_envvars (with either one or two v's) implemented in the headers. The environment variables listed on the Wiki page are not constants, but are the string values you need to pass to getenv or putenv.
_________________
The One With D | The One With Aldacron | D Bits
Back to top
View user's profile Send private message Send e-mail
ponce



Joined: 12 Nov 2009
Posts: 55

PostPosted: Tue Oct 18, 2011 5:24 pm    Post subject: Reply with quote

mutable wrote:
Ok, if it will go away in the comming SDL Version i can disclaim too.
Furthermore it sounds like a huge work to figure out which bits are right for which data. But thanks for the reply. Smile

Don't sweat too much over that, such flags here are stuck to 2, regardless of the screen surface (I don't know what order is meant by the bitfield too ). Confused
_________________
@p0unce | gamesfrommars
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Derelict 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