Should I modify SFML???
Moderator: PC Supremacists
- THe Floating Brain
- Chaos Rift Junior
- Posts: 284
- Joined: Tue Dec 28, 2010 7:22 pm
- Current Project: RTS possible Third Person shooter engine.
- Favorite Gaming Platforms: PC, Wii, Xbox 360, GAME CUBE!!!!!!!!!!!!!!!!!!!!!!
- Programming Language of Choice: C/C++, Python 3, C#
- Location: U.S
Should I modify SFML???
Okay so I finally think I have a rough idea of vectors and I wrote these functions
(Calculates a vector)
http://pastebin.com/h6KqWVKu
("Lightning" is the version of my engine)
(Moves a object along a vector)
http://pastebin.com/3dXv5WfQ
Problem being... despite all the long double variables I put the movement of a object along a vector is inaccurate (just slightly). The reason is that when I pass the "GotoX", and "GotoY" variables (from my function above) into SFML's .Move function the data is corrupted because .Move takes float variables instead of long double variables. So I am wondering if I should go through the trouble of changing SFML's .Move function to take long double's instead of float and possibly other functions and also compromise SFML's performance?
P.s Language = C++
P.s.s I know I sometimes have a hard time getting my point across so if any clarification is needed let me know
(Calculates a vector)
http://pastebin.com/h6KqWVKu
("Lightning" is the version of my engine)
(Moves a object along a vector)
http://pastebin.com/3dXv5WfQ
Problem being... despite all the long double variables I put the movement of a object along a vector is inaccurate (just slightly). The reason is that when I pass the "GotoX", and "GotoY" variables (from my function above) into SFML's .Move function the data is corrupted because .Move takes float variables instead of long double variables. So I am wondering if I should go through the trouble of changing SFML's .Move function to take long double's instead of float and possibly other functions and also compromise SFML's performance?
P.s Language = C++
P.s.s I know I sometimes have a hard time getting my point across so if any clarification is needed let me know
"Why did we say we were going to say we were going to change the world tomorrow yesterday? Maybe you can." - Myself
- GroundUpEngine
- Chaos Rift Devotee
- Posts: 835
- Joined: Sun Nov 08, 2009 2:01 pm
- Current Project: mixture
- Favorite Gaming Platforms: PC
- Programming Language of Choice: C++
- Location: UK
Re: Should I modify SFML???
Sometimes we should keep it simple, if you wanna use the SFML API as is.. just use float (up to 7 digits i believe, which is not bad) variables for your maths
- Ginto8
- ES Beta Backer
- Posts: 1064
- Joined: Tue Jan 06, 2009 4:12 pm
- Programming Language of Choice: C/C++, Java
Re: Should I modify SFML???
... The fact that you're using long doubles when floats are all you need (and, more to the point, you're using an api that focuses on floats) proves that you are not yet at the level where you'd be capable of modifying SFML, disregarding that it really shouldn't be necessary at all.
It may interest you to know that SFML uses OpenGL for a backend, and OpenGL, although you can pass it doubles, converts everything to floats internally, so there really isn't much point anyway.
It may interest you to know that SFML uses OpenGL for a backend, and OpenGL, although you can pass it doubles, converts everything to floats internally, so there really isn't much point anyway.
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
- GroundUpEngine
- Chaos Rift Devotee
- Posts: 835
- Joined: Sun Nov 08, 2009 2:01 pm
- Current Project: mixture
- Favorite Gaming Platforms: PC
- Programming Language of Choice: C++
- Location: UK
Re: Should I modify SFML???
I was about to address that! Good point.Ginto8 wrote:It may interest you to know that SFML uses OpenGL for a backend, and OpenGL, although you can pass it doubles, converts everything to floats internally, so there really isn't much point anyway.
- THe Floating Brain
- Chaos Rift Junior
- Posts: 284
- Joined: Tue Dec 28, 2010 7:22 pm
- Current Project: RTS possible Third Person shooter engine.
- Favorite Gaming Platforms: PC, Wii, Xbox 360, GAME CUBE!!!!!!!!!!!!!!!!!!!!!!
- Programming Language of Choice: C/C++, Python 3, C#
- Location: U.S
Re: Should I modify SFML???
I know how (change the function args in the source and in bolth copies of the headers in VC++ and in C: if any warnings come up according to that also change them to long doubles)Ginto8 wrote:... The fact that you're using long doubles when floats are all you need (and, more to the point, you're using an api that focuses on floats) proves that you are not yet at the level where you'd be capable of modifying SFML,
(I did know that SFML used openGL) So it realy doesent matter 0.0. Thing is though it is even less acurate when I dont use doubles so I am not sure what to do. Poeple told me that my vector calculation function is correct. :/ Not sure were to go here.Ginto8 wrote:It may interest you to know that SFML uses OpenGL for a backend, and OpenGL, although you can pass it doubles, converts everything to floats internally, so there really isn't much point anyway.
+1GroundUpEngine wrote:I was about to address that! Good point.
actually its 6GroundUpEngine wrote:just use float (up to 7 digits i believe,
"Why did we say we were going to say we were going to change the world tomorrow yesterday? Maybe you can." - Myself
-
- Chaos Rift Demigod
- Posts: 991
- Joined: Thu Nov 13, 2008 3:16 pm
- Current Project: Elysian Shadows
- Favorite Gaming Platforms: Amiga, PSOne, NDS
- Programming Language of Choice: C++
- Location: Sweden
Re: Should I modify SFML???
There is a good reason using floats for movement, it's a lot smoother. If you need to run an if statement where your x/y variables reaches 300, use typecasting:
Don't bother changing SFML, the effort is not worth it by far, there would hardly be improvement and you're not considering events where floats are necessary.
Edit: Actually typecasting doesn't round nicely, use this instead:
Code: Select all
if( (int)playerX )
Edit: Actually typecasting doesn't round nicely, use this instead:
Code: Select all
(int) floor( f + 0.5f );
Last edited by pritam on Sun Feb 06, 2011 9:40 pm, edited 1 time in total.
- THe Floating Brain
- Chaos Rift Junior
- Posts: 284
- Joined: Tue Dec 28, 2010 7:22 pm
- Current Project: RTS possible Third Person shooter engine.
- Favorite Gaming Platforms: PC, Wii, Xbox 360, GAME CUBE!!!!!!!!!!!!!!!!!!!!!!
- Programming Language of Choice: C/C++, Python 3, C#
- Location: U.S
Re: Should I modify SFML???
But if it never equils the desired position that wont work.
"Why did we say we were going to say we were going to change the world tomorrow yesterday? Maybe you can." - Myself
-
- Chaos Rift Demigod
- Posts: 991
- Joined: Thu Nov 13, 2008 3:16 pm
- Current Project: Elysian Shadows
- Favorite Gaming Platforms: Amiga, PSOne, NDS
- Programming Language of Choice: C++
- Location: Sweden
Re: Should I modify SFML???
Well, that's entirely up to you, use other operators.THe Floating Brain wrote:But if it never equils the desired position that wont work.
-
- Chaos Rift Cool Newbie
- Posts: 70
- Joined: Mon Dec 13, 2010 10:55 pm
Re: Should I modify SFML???
Hold on, let me get this straight. You want to change an entire API that is revolved around the float data type, because you want to use long doubles instead?
Also, Pritam's got it right. If you really desire a whole 300 constant value, just floor/ceil the thing. SFML's amazing; don't go breaking it because you're too lazy to change a long double to a float. :P
Also, Pritam's got it right. If you really desire a whole 300 constant value, just floor/ceil the thing. SFML's amazing; don't go breaking it because you're too lazy to change a long double to a float. :P
-- Jesse Guarascia
I like C/++, SDL, SFML, OpenGL and Lua. If you don't like those, then gtfo my sig pl0x (jk trollololololol)
I like C/++, SDL, SFML, OpenGL and Lua. If you don't like those, then gtfo my sig pl0x (jk trollololololol)
- GroundUpEngine
- Chaos Rift Devotee
- Posts: 835
- Joined: Sun Nov 08, 2009 2:01 pm
- Current Project: mixture
- Favorite Gaming Platforms: PC
- Programming Language of Choice: C++
- Location: UK
Re: Should I modify SFML???
THe Floating Brainquote wrote:actually its 6GroundUpEngine wrote:just use float (up to 7 digits i believe,
Code: Select all
float lol = 1.234567;
+1JesseGuarascia wrote:
- MrDeathNote
- ES Beta Backer
- Posts: 594
- Joined: Sun Oct 11, 2009 9:57 am
- Current Project: cocos2d-x project
- Favorite Gaming Platforms: SNES, Sega Megadrive, XBox 360
- Programming Language of Choice: C/++
- Location: Belfast, Ireland
- Contact:
Re: Should I modify SFML???
lol.GroundUpEngine wrote:THe Floating Brainquote wrote:actually its 6GroundUpEngine wrote:just use float (up to 7 digits i believe,Code: Select all
float lol = 1.234567;
+2JesseGuarascia wrote:
This is a really odd thread, I find it really hard to believe that you're actually considering changing the SFML API for no good reason, a float should be more than enough to work with. If the values aren't being set right then you're doing something wrong. But the short answer to "Should I modify SFML???" is NO!!
http://www.youtube.com/user/MrDeathNote1988
"C makes it easy to shoot yourself in the foot. C++ makes it
harder, but when you do, it blows away your whole leg." - Bjarne Stroustrup
"C makes it easy to shoot yourself in the foot. C++ makes it
harder, but when you do, it blows away your whole leg." - Bjarne Stroustrup
- xiphirx
- Chaos Rift Junior
- Posts: 324
- Joined: Mon Mar 22, 2010 3:15 pm
- Current Project: ******** (Unkown for the time being)
- Favorite Gaming Platforms: PC
- Programming Language of Choice: C++
- Contact:
Re: Should I modify SFML???
I'm really confused....
How big are your input values? Do you know what the range of a long is?...
Why do you need a long double? float is fine...
Curious to see what that does... and why you couldn't just write the Pythagorean theorem out instead of having an odd function for it.
This is where your values are messed up, I think...
Just to note, it looks like you don't have a good grasp on vectors. If you did, you would have probably used SFML's own vector2f class :P
How big are your input values? Do you know what the range of a long is?...
Code: Select all
//Calculate Magnitude.//
GotoX -= Object.GetPosition().x;
GotoY -= Object.GetPosition().y;
long double Magnitude;
Code: Select all
Magn(GotoX, GotoY, Magnitude);
Code: Select all
//Go The Desired Speed.//
GotoX *= Speed;
GotoY *= Speed;
Just to note, it looks like you don't have a good grasp on vectors. If you did, you would have probably used SFML's own vector2f class :P
StarCraft II Zerg Strategy, open to all levels of players!
Looking for paid work :< Contact me if you are interested in creating a website, need a web design, or anything else you think I'm capable of
Looking for paid work :< Contact me if you are interested in creating a website, need a web design, or anything else you think I'm capable of
Re: Should I modify SFML???
xiphirx wrote:If you did, you would have probably used SFML's own vector2f class :P
So...You want to fuck with SFML's source because you want to use a double over a float?
- Falco Girgis
- Elysian Shadows Team
- Posts: 10294
- Joined: Thu May 20, 2004 2:04 pm
- Current Project: Elysian Shadows
- Favorite Gaming Platforms: Dreamcast, SNES, NES
- Programming Language of Choice: C/++
- Location: Studio Vorbis, AL
- Contact:
Re: Should I modify SFML???
Honestly, why in fuck's name would you be using doubles? Why would you EVER need that kind of precision? That's only for exact numbers and scientific calculations.THe Floating Brain wrote:Okay so I finally think I have a rough idea of vectors and I wrote these functions
(Calculates a vector)
http://pastebin.com/h6KqWVKu
("Lightning" is the version of my engine)
(Moves a object along a vector)
http://pastebin.com/3dXv5WfQ
Problem being... despite all the long double variables I put the movement of a object along a vector is inaccurate (just slightly). The reason is that when I pass the "GotoX", and "GotoY" variables (from my function above) into SFML's .Move function the data is corrupted because .Move takes float variables instead of long double variables. So I am wondering if I should go through the trouble of changing SFML's .Move function to take long double's instead of float and possibly other functions and also compromise SFML's performance?
P.s Language = C++
P.s.s I know I sometimes have a hard time getting my point across so if any clarification is needed let me know
And keep in mind that there is not a 1-to-1 relationship between an IEEE 32-bit single precision float (the variable you know as "float") and an integer. How many bytes are used to represent both? Float = 4 bytes. Integer = 4 bytes. They are literally the same size. They are literally both only capable of holding a permutation of their number of bits. So you are going to be missing some "exact" values that exist in an integer with a float. That's how it works.
You have no IDEA what the performance implications of using doubles usually is. Modern GPUs are only NOW starting to hardware accelerate doubles. A lot of the time the routines are written completely and software for GIGANTIC performance drops (because there's no support for the IEEE 64-bit float in hardware). We don't EVER use double precision floats in game development...
- THe Floating Brain
- Chaos Rift Junior
- Posts: 284
- Joined: Tue Dec 28, 2010 7:22 pm
- Current Project: RTS possible Third Person shooter engine.
- Favorite Gaming Platforms: PC, Wii, Xbox 360, GAME CUBE!!!!!!!!!!!!!!!!!!!!!!
- Programming Language of Choice: C/C++, Python 3, C#
- Location: U.S
Re: Should I modify SFML???
God I feel realy embaressed
Damn C++ book lied to meGyroVorbis wrote: Honestly, why in fuck's name would you be using doubles? Why would you EVER need that kind of precision? That's only for exact numbers and scientific calculations.
And keep in mind that there is not a 1-to-1 relationship between an IEEE 32-bit single precision float (the variable you know as "float") and an integer. How many bytes are used to represent both? Float = 4 bytes. Integer = 4 bytes. They are literally the same size. They are literally both only capable of holding a permutation of their number of bits.
Not any more I did though beacuse I am apparently a terrible programmerN64vSNES wrote:So...You want to fuck with SFML's source because you want to use a double over a float?
19 digets.xiphirx wrote:I'm really confused....
How big are your input values? Do you know what the range of a long is?...
Why do you think that?xiphirx wrote:This is where your values are messed up, I think...Code: Select all
//Go The Desired Speed.// GotoX *= Speed; GotoY *= Speed;
hence...xiphirx wrote: Just to note, it looks like you don't have a good grasp on vectors. If you did, you would have probably used SFML's own vector2f class :P
Okay so I finally think I have a rough idea of vectors and I wrote these functions
"Why did we say we were going to say we were going to change the world tomorrow yesterday? Maybe you can." - Myself