Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - zorexx

Pages: 1 [2] 3 4 ... 8
16
SFML projects / Re: sfMod 1.1 - Play module files in SFML
« on: April 05, 2012, 07:27:14 am »
I'm finally done adapting sfMod to the latest SFML naming conventions.

I also added a new error handling system (the same one as sfTheora and sfMidi).

Dropped SFML 1.6 support as well, since SFML 2.0 will be released as a stable version soon.

See the changelog for the full list of changes.

17
SFML projects / Re: sfTheora 1.4 - Play videos in SFML
« on: April 05, 2012, 07:22:57 am »
So, I'm finally done adapting sfTheora to the latest SFML naming conventions (and, notice the name change  ;D).

I also added some new functions, like getDuration and getTime, as well as a new error handling system.
You can also now load videos by passing it as a parameter to the constructor. This is made possible thanks to the new error handling system.

Dropped SFML 1.6 support as well, since SFML 2.0 will be released as a stable version soon.

See the changelog for the full list of changes.

18
SFML projects / Re: SolidShaper + Box2D + SFML
« on: April 05, 2012, 07:10:04 am »
First: When I'm drawing a shape, what happens when things overlap?

The last shape drawn or selected will be at the top, use right click to select if you want to select anything below that, this will first select the topmost, then the one below that, and so on.

Second: Can I request a feature? Would it be possible to make a function that takes a set of points and draws a triangle strip? I tried to outline one of my sprites and it has a lot of concave sections.  Basically the function would take a list of points in the order they were drawn and figures out a triangle shape pattern.  I'm not sure how complicated that would be but it would be a perfect feature to outline sprites (the current way I have to draw it just right to get a proper outline). 

That's called triangulation.
It's possible to break polygons into triangles with triangulation, but not into triangle strip.
Since SolidShaper does not have any object-like feature to group shapes together, if I included a triangulation feature, it will break it down to triangles, but then you cannot move them as a set anymore, you'll end up moving each triangle individually.
With that in mind, I would suggest you implement the triangulation in your game itself instead.
I'm pretty sure Nexus's Thor library can do that, you may want to take a look at that:
http://en.sfml-dev.org/forums/index.php?topic=7329.0

On the other hand, if I do find a good way to implement triangulation (probably by introducing a grouping feature or so), I will definitely implement it.  ;)

19
Wow, I actually read that before I decided to not use exception, didn't realize that was you.  :P
Well, thanks for your opinion.  ;D

20
As already mentioned, exceptions are the wrong approach if every call that might throw is directly surrounded by a try-catch clause.

Yeap, which is why I said I will most probably switch over to exceptions if Laurent decides to do so with SFML.

Interestingly, new throws std::bad_alloc :)

Yeah, I'm aware of that.  :)
I was trying to relate to the consequences of not null-checking - an ugly crash, which is what happens if you don't check the video for errors.

It might however occur often that new users forget to check for errors, since it's not clear that a constructor needs to be followed by a hasError() call. Unlike a bool load() function, which is a more widespread idiom (and also used in SFML). So you'll see who reads the documentation ;)

I agree on this, too.
Of course, I'm not omitting the load function, there will still be a bool load() function, I'm just making it possible to load directly from constructor to give the user a choice to do so.

I'll probably put both ways of loading a video in the "short tutorial", which will be shown on the project page (like how it is right now). It's pretty much the only thing that qualifies as a documentation for the projects as of now, maybe I should write a proper documentation of all the features, which aren't many actually.

21
majority of the people (working with games) don't favor exceptions.
Is that true? I'd like to learn about the backgrounds, have you read that somewhere or is it rather your general impression?

I've read it in various places, you can google c++ exception handling in games.
The results, of course, consists of those who support that idea, and those who are against that idea.
And after reading those, especially the discussion-types (rather than articles), I find that most people seem to recommend against using it (for my situation).

Also, most libraries I've came across with don't use exceptions, so maybe there's a bit of general impression in my statement above as well.

SFML doesn't use exceptions (for now), but if it does (SFML 3?), I will probably change mine to use it too, I will explain why below.

I don't understand that, why does one need the heap?
For example, this code:
sftheora::Video testVid("video.ogg");
if (sftheora::hasError())
  // Handle error
 
Will have to translate into either 1 of these 3 if I decided to use exceptions:
try {
  sftheora::Video testVid("video.ogg");

  // Main loop << Forces user to put main loop here
}
catch (exception) {
  // Handle exception
}
 
or
sftheora::Video* testVid;

try {
  testVid = new sftheora::Video("test.ogg"); // Forces user to use heap
}
catch (exception) {
  // Handle exception
}

// Rest of code
 
or
sftheora::Video testVid;

try {
  testVid.load("test.ogg");
}
catch (exception) {
  // Handle exception
}
 

However, if Laurent decides to use exceptions for SFML, I will switch to it as well, since if that's the case, the user will probably have most of his (initialization) code in try-catch blocks anyway, so I'll just make use of that.

The problem with this approach is that you have objects which aren't operational. You can't rely on a valid object state, which makes ugly validity checks necessary. And you need to define semantics for an unloaded object -- what should video.play() do if it the video has not been loaded?

The additional issue with hasError() is, that it has global state and needs to be invoked directly after each constructor in order to find out which one failed. Same with getError(), it only reports the last error.

Currently, I leave the responsibility of checking whether the object is valid after loading it to the user.
Just like if creating an object on the heap, if you don't null-check it and it unexpectedly returns a null (probably due to bad allocation), the program will crash (ugly, indeed).
I follow that "rule" as well, if you don't check if it's valid after loading it, you risk having your program crashed.

Also, hasError() does not have a global state, the error string is just another (private) variable of each instance. It is different from std::cerr or sf::err(). It is more like an optional explanation of what went wrong, in addition to the boolean value.
While it only reports the last error, why would you need it to report any other previous errors?
In exceptions, you only get the exception once, and that's it, it's the same for this, just that you have to manually clear the error if you decide to continue using that same instance.

22
Currently, after thinking about it and doing some little research on exceptions (C++ exceptions, and also usage in games/real-time application), I'm leaning towards returning a boolean value now.

The 3 main reasons are the (slight) performance overhead, troubles with RAII, and majority of the people (working with games) don't favor exceptions.

About the RAII, just in case it may sound confusing, I meant that, if I were to allow everything to be loaded in the constructor (which will be made possible with the next version to make things even simpler than it already is), and decide to use exceptions at the same time, I will end up having to force the end-user to put everything that reference to the video in a try-catch block, or use the heap.

So for now, unless someone convinces me to do otherwise, I will return false in case of any error, and set an error string, which will be accessible with getError().
I will also provide another function, hasError(), to make things look cleaner, basically what hasError() does is just check if the error string is empty or not.
clearError() will allow the user to clear the error string in case if the user decides that there is no need to terminate the application or delete the instance, and will reuse the same instance.
This way, the constructor problem is automatically solved, call the constructor with the filename as a parameter, and check if the video is loaded properly later with hasError():D

Thanks for all your opinions and votes.  :)

23
Thanks for your opinions.

@eXpl0it3r: Is there any specific reason that you're not convinced by exceptions?


@Nexus: Regarding the exception issue, yes, that's the main benefit I was trying to explain (but failed to >.<).
Rather than having to make sure everything is alright after each load call or constructor, I can just throw them all into a try block and handle any exceptions in the catch block(s).

Thanks for your suggestion on sftheora, I'll add it to the first post, I guess if I were to choose sftheora, I might as well just change the project name to sfTheora to match sfMod and sfMidi.

24
Hello everyone,

Since SFML 2 will be released soon, and with the change in the naming convention, I thought this would be a good time to update all my 3 SFML projects - SFMLTheora, sfMod, and sfMidi.

Of course, I will have to change the code to reflect the changes in SFML 2, I will also change my naming convention to follow SFML2.

Aside from that, there are few changes I'm considering, mostly general stuffs which has nothing specific to any of the 3 libraries.


1. Exception handling:
I used to hate these try-catch stuffs since they were a hassle and can get really messy and meddlesome at times, but recently after programming in C# and Java, I find that they aren't that bad at all, and can be really handy at times.

Currently, the 3 libraries handle errors by simply returning false. I've definitely faced some design problems since constructors can't have a return value, but those were somewhat solved without much problem. (I did know that exceptions could easily solve my problem, but as I mentioned above, I didn't like exceptions at that time).

The drawback to this is that I can't get more info on the error (i.e. why it failed). While this may not be a problem for most case, I do think it will prove to be very useful for debugging purposes. (I debug by placing std::cout<<123 or std::cout<<"lol"; at suspicious places all this time  ;))

I'm not too sure about this, but with exceptions, the code on the user-end would probably look much cleaner and organized (at least I hope it will be).
However, it will also, at the same time, make your code longer:
Code: [Select]
if (!vid.Load("video.ogg"))
  return 1;
will become
Code: [Select]
try {
  vid.Load("video.ogg")
}
catch (exception ex) {
  // handle exception
}

So, tell me which do you prefer (and would like to see in the next version of the 3 libraries above, as well as any future SFML projects I may write) by voting above, and if possible, tell me your reasons, or at least say something about it.  :D


2. Namespace
Currently, the namespaces I use for each projects are their respective project names, SFMLTheora for SFMLTheora, sfMod for sfMod, sfMidi for sfMidi.

I've been thinking of changing SFMLTheora to something shorter, and might as well shorten the other 2 as well (or are they good enough as is?)

Here are what I currently have in mind:
- sfth for SFMLTheora
- sfmo for sfMod
- sfmi for sfMidi

Another alternative for sfMod and sfMidi would be sfmod and sfmidi respectively, which do you prefer?

Edit: Another suggestion by Nexus for the namespace of SFMLTheora: sftheora
If I decide to go with sftheora, I will most probably change the project name to sfTheora as well, to match the namespace and the other 2 libraries.

It would be great if I can hear some opinions on this as well, especially for sfmo and sfmi.

25
SFML projects / Re: SolidShaper + Box2D + SFML
« on: March 30, 2012, 02:30:22 pm »
Just a minor update on SSFile:

SSFile for Java and Python are released.

Downloads available on the project page: http://www.zorexxlkl.com/solidshaper

Edit:
SolidShaper 1.0.1 released.
This release contains several minor bugfixes and improvements.

26
SFML projects / Re: SolidShaper + Box2D + SFML
« on: March 27, 2012, 02:49:09 pm »
Cool, too bad I don't understand French.

Hope you'll like it (and find it useful).  :)

27
SFML projects / Re: SolidShaper + Box2D + SFML
« on: March 27, 2012, 04:26:37 am »
could I potentially use this to create/draw shapes for my game?

Sure! That's what it's made for.
Good luck on your game!  ;)

28
SFML website / Re: New forum
« on: March 25, 2012, 07:48:29 am »
Very nice indeed, good job. Looking forward to see the new theme.

One issue (well, not a big problem, just thought I should mention it): The favicon is missing.

Also, while you're at it, is it possible to allow embedding videos (like youtube)? I think it will be pretty useful.
How about trying this: http://custom.simplemachines.org/mods/index.php?mod=3268

29
SFML projects / Re: SolidShaper + Box2D + SFML
« on: March 25, 2012, 07:30:05 am »
Completed the sample.
Here's the latest video:


and the source code:
http://www.zorexxlkl.com/files/downloads/SSFBox2DTest-1.0.0.zip

Be warned though, the code isn't very tidy, if you want to use the codes, you'll probably have to modify it to suit your needs.

30
SFML projects / [WIP] SolidShaper + Box2D + SFML
« on: March 21, 2012, 04:55:20 pm »
Ahh, thanks for reporting.

Fixed it, will be available in the next version.

If you spot any other errors/problems (even minor ones), please let me know, thanks!  :D

Pages: 1 [2] 3 4 ... 8