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

Author Topic: Groogy's Game Engine  (Read 28826 times)

0 Members and 1 Guest are viewing this topic.

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Groogy's Game Engine
« Reply #15 on: June 27, 2011, 07:42:07 pm »
Quote from: "Nexus"
By the way, why don't you use a proper smart pointer instead of that ugly SAFE_DELETE?


Because I don't want a smart pointer :P
I use reference counting where reference counting is needed. For example I reference count resources, not singletons. I reference count... well that is about it :)

Everything else is RAII based.

NOTE: Even my resources is half loosed on reference counting. They are not removed if they hit 0 references. They are removed only if the memory is needed.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Groogy's Game Engine
« Reply #16 on: June 27, 2011, 07:45:40 pm »
Quote from: "Groogy"
I use reference counting where reference counting is needed. For example I reference count resources, not singletons. I reference count... well that is about it :)
I didn't mean you should use a reference counted smart pointer. But something like std::auto_ptr, boost::scoped_ptr or std::unique_ptr. Everything is better than such an unsafe and ugly macro, even plain delete.

Quote from: "Groogy"
Everything else is RAII based.
Well, I see no reason why you can't use RAII here. Manually initializing and destroying something before/after it is used is quite annoying and reminds me of C libraries ;)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Groogy's Game Engine
« Reply #17 on: June 27, 2011, 07:58:40 pm »
Quote from: "Nexus"
Quote from: "Groogy"
I use reference counting where reference counting is needed. For example I reference count resources, not singletons. I reference count... well that is about it :)
I didn't mean you should use a reference counted smart pointer. But something like std::auto_ptr, boost::scoped_ptr or std::unique_ptr. Everything is better than such an unsafe and ugly macro, even plain delete.

How would you do it then? The pointer exists in a global scope because of it being static. So no matter what smart pointer class I use, that object will never be destroyed. If I manually destroy the smart pointer then I'm back to square one but with an even uglier indirection.

I want there to be a Create and Release functionality as it's defined in the actual pattern. Though you are not forced to call Create as it will be called trough the Instance() function(just saw I forgot to add that).
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Groogy's Game Engine
« Reply #18 on: June 27, 2011, 08:09:29 pm »
Can't you use the Meyers singleton? Then you don't even need dynamic memory.
Code: [Select]
template <typename T>
class Singleton
{
public:
static Singleton& Instance()
{
static Singleton instance;
return instance;
}

private:
...
};

If you absolutely do need a Release() function, you can do it like this, but of course the code becomes slightly more complicated:
Code: [Select]
#include <memory>

template <typename T>
class Singleton
{
public:
static Singleton& Instance()
{
if (!instance.get())
instance.reset(new Singleton);
return *instance;
}

static void Release()
{
instance.reset();
}

private:
// auto_ptr needs access to our destructor
template <typename T>
friend class std::auto_ptr;

static std::auto_ptr<Singleton> instance;

...
};
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Groogy's Game Engine
« Reply #19 on: June 27, 2011, 08:24:34 pm »
Hmm I could provide both Meyers and a normal one. These are just design patterns that are provided together with the library.

NOTE: There must be a Create function on the normal so that you can control the allocation in a nice way. Calling Instance() just to allocate the singleton is not very informative.

And of course I do not necessarily NEED the functions but I am just implementing the design pattern for use by others. So someone might expect a Create-Release function pair but if it then don't exist he will get grumpy on me, and then we have someone else that complains on that there is a Create-Release function pair and he get's grumpy. The difference is that the one that don't want the pair I can just tell him to ignore them as they are not needed to actually use the class.

For the actual application in GGE I would only use the normal singleton for one class and the rest would work perfectly(maybe even optimal) with Meyers Singleton.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

danman

  • Hero Member
  • *****
  • Posts: 1121
    • View Profile
    • Email
Groogy's Game Engine
« Reply #20 on: June 27, 2011, 11:41:13 pm »
I've used a singleton derived pattern for me (that support polymorphism i think, not tried), because i need a perfect control on what i singlelise :

Code: [Select]


Obj singleton;
SharedInstance(singleton);

SharedInstance<Obj>()->DoThat();

Obj singletwo;
SharedInstance(singletwo);
...



I agree with Groogy. although it's a C-like behavior, you need external memory management, because devs could need it and could be stopped by this leak.

But i don't manage it itself, I prefer let the user destroy it, or use a GTK-like Garbage, but with more semantics :

Code: [Select]

template<typename T>
class Garbage
{
public:
    virtual ~Garbage();
    T& Manage(T*); // I use reference, because the other code use reference, not a Qt like system
private:
    std::vector<T*> m_Objects;
};

class GuiHandle : public Garbage<Widget> // GuiHandle can manage memory destruction for widgets object
{

};


I hope you understand me  :oops:
Pointilleur professionnel

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Groogy's Game Engine
« Reply #21 on: June 30, 2011, 04:50:15 am »
Understood you perfectly danman. Unfortunately this is a subject there is a grey zone of right.

Anyway as I am reaching my own set deadline I am about to write some documentation and tutorials for use of the engine. Since the engine will eventually contain tools for like skeletal animations, shader/model previewers and so on it would be nice to have video tutorials too.

So am just asking if anyone got a screen capture application to recommend?
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Cuban-Pete

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Groogy's Game Engine
« Reply #22 on: June 30, 2011, 08:37:27 am »
camstudio works decent.

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Groogy's Game Engine
« Reply #23 on: June 30, 2011, 10:01:07 pm »
Thanks Pete, now I need a video editing tool to put the different clips together.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Groogy's Game Engine
« Reply #24 on: June 30, 2011, 10:45:06 pm »
Introduction tutorial is up on youtube now ^^


Sorry though for my English.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Groogy's Game Engine
« Reply #25 on: June 30, 2011, 11:02:36 pm »
I love your soft and sexy voice :D *gets out*.

Actually your English is quite better than mine.. and really easy to understand thus you shouldn't worry.
Want to play movies in your SFML application? Check out sfeMovie!

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Groogy's Game Engine
« Reply #26 on: June 30, 2011, 11:07:41 pm »
The thing that worries me are all the "Örhm" because I hesitate to think about what I am about to say... and that's even with me practising several times before XD

I actually like doing this. Was quite fun to "vlog" or whatever it's called ^^

Anyway the next tutorial will be up tonight with me showing how to implement the "hello world" application.

Anyway thanks Ceylo for the remark on my voice  :wink: *kisses*
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

MorleyDev

  • Full Member
  • ***
  • Posts: 219
  • "It is not enough for code to work."
    • View Profile
    • http://www.morleydev.co.uk/
Groogy's Game Engine
« Reply #27 on: July 01, 2011, 01:14:46 am »
If you have trouble coming up with names for a project, my tactic is to just keep clicking random on wikipedia until something catches my eye ^^ My latest project is called "Zander" xD

I've found rather easy to create a singleton pattern which decides at compile-time whether it is gamma or meyers, or something the user defines.

Anyway looks interesting ^^
UnitTest11 - A unit testing library in C++ written to take advantage of C++11.

All code is guilty until proven innocent, unworthy until tested, and pointless without singular and well-defined purpose.

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Groogy's Game Engine
« Reply #28 on: July 01, 2011, 05:09:09 am »
The new tutorial is out where we actually do something with the engine:



It became pretty long so had to divide it into two parts.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Groogy's Game Engine
« Reply #29 on: July 01, 2011, 09:06:46 am »
Aaah aaah aaaaaah got a kiss from the guy-with-a-sexy-voice *faints*.

Apart from that, I think you should increase the sound's volume because we can't hear you without setting the volume close to maximum.

As for the "erm" thing, maybe you should write down what you want to say so that you do no more hesitate?
Want to play movies in your SFML application? Check out sfeMovie!

 

anything