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

Author Topic: [ODFAEG] (Open Source Development Framework Adapted for Every Game)  (Read 140044 times)

0 Members and 1 Guest are viewing this topic.

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
Re: [ODFAEG] (Open Source Development Framework Adapted for Every Game)
« Reply #120 on: March 16, 2014, 05:51:45 pm »
I need to have big f2p games on linux..

What do you mean?

Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Re: [ODFAEG] (Open Source Development Framework Adapted for Every Game)
« Reply #121 on: March 16, 2014, 06:18:49 pm »
My graphical card driver on window is actually dead and it's quite annoying to do reinstallations because of a virus, pub spamming or a wrong driver. (And I don't have the installation cd because he's no more provided by the vendor, so I'll have to crack windows...)

In linux you know where find the right software directly (thanks to the apt repository), it's free so you haven't the license problems and you don't waste time to find a good website for an application or a driver.
And if the appli isn't in the apt repository, if you download bad sofware and pub integrated in the dowload you'll be sure that linux'll block it. (It's not the case with window so my window has become a real mess)

Windows is only good for gaming, because wine doesn't work very well with windows applications and windows applications aren't made to work on linux anyway. (Because they only want to avoid to loose their clients)

I'm quite disappointed of that so it's why I would like to create an f2p which works well on linux. (Because it's quite annoying to be forced to go on windows only to play at your favorite game)

panithadrum

  • Sr. Member
  • ****
  • Posts: 304
    • View Profile
    • Skyrpex@Github
    • Email
Re: [ODFAEG] (Open Source Development Framework Adapted for Every Game)
« Reply #122 on: March 16, 2014, 07:29:49 pm »
I think he means he wsnts to create f2p games that work in Linux

Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Re: [ODFAEG] (Open Source Development Framework Adapted for Every Game)
« Reply #123 on: March 16, 2014, 09:03:25 pm »
Is there a system restaure on linux ? (Like on window)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10837
    • View Profile
    • development blog
    • Email
AW: Re: [ODFAEG] (Open Source Development Framework Adapted for Every Game)
« Reply #124 on: March 16, 2014, 09:10:30 pm »
Is there a system restaure on linux ? (Like on window)
Why don't you ask somewhere else? This forum is about SFML and not some general help forum. ;)
« Last Edit: March 16, 2014, 09:53:32 pm by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Re: [ODFAEG] (Open Source Development Framework Adapted for Every Game)
« Reply #125 on: March 16, 2014, 09:26:18 pm »
Ok

Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Re: [ODFAEG] (Open Source Development Framework Adapted for Every Game)
« Reply #126 on: March 17, 2014, 12:16:59 pm »
Major improvements are coming!

Hi, for the 3D my entity manager is not sufficient so I've create a new one :

-The application class'll choose the render classes and the opengl options which'll be used for the 3D or the 2D rendering. (you'll just have to specify if it's a 3D or a 2D application)

For the 2D : if shader aren't avalaible this is the sf::RenderWindow class which'll be used, otherwise this'll be the odfaeg::RenderWindow class.
In case 1 : the entities'll be inserted by their layer's positions into the visible entity vector, otherwise they'll be inserted by their texture.

For the 3D it'll always be the odfaeg::RenderWindow which'll be used and the entities'll always be inserted by their texture, but if the shader aren't avalaible the deth and alpah test'll be activated.

I'll rename the class Tile to the class Face because sprite and tile aren't not the same, sprite are simply textured quads entities, faces are'll be able to use any king of primitive type and they are attached to an entity.

The odfaeg entity manager'll simply regroup every faces using the same texture into the same tilemap and'll return all these tilemaps.

the world class'll be modified and'll be used to do the abstraction between all the entity managers types and entity system types used and the developper. (So the developper'll only have access to the function of the classe world to create the maps.)

Each entity manager'll be able to have a different view.

So the developer'll not have to know which entity manager and which renderwindow he must use if the shader are avalaible or not.












Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
Re: [ODFAEG] (Open Source Development Framework Adapted for Every Game)
« Reply #127 on: March 17, 2014, 12:22:45 pm »
I'm pretty sure this is the most game specific library I've seen, it is NOT suited for most games as claimed :p

Why don't you learn first what a traditional 3D engine looks like and also a 2D one? Look at Unity and other good engines and try to do what they do, achieve a design that fits most games you can imagine.. I'm sure you would have better results..

Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Re: [ODFAEG] (Open Source Development Framework Adapted for Every Game)
« Reply #128 on: March 17, 2014, 05:58:45 pm »
I know what a traditional 2D or 3D engine looks like, it's why I want to combine the techniques of a 2D and a 3D engine to be able to create many different games genres.





Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
Re: [ODFAEG] (Open Source Development Framework Adapted for Every Game)
« Reply #129 on: March 17, 2014, 09:08:03 pm »
I'm hanging on to see one good sample  :D

Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Re: [ODFAEG] (Open Source Development Framework Adapted for Every Game)
« Reply #130 on: March 18, 2014, 02:51:00 pm »
Yeah I know but it'll take time because I have computers which support functionnalities than other doesn't support. (By example my oldest computer don't support FBO and shaders)

So I need to have very specific classes for each supported functionnalities. (It's not always the case with actual frameworks or libraries) :

-JOGL doesn't work on my PC if I use swing and some javaclass which lead to concurrent thread exceptions. (Same for each framework using JOGL)
-QtSockets doesn't work on my plateform.
-Unity, Irrlicht and other c++ framework doesn't use SFML, so, I'm forced to use their entity system and I don't really need them for simple 2D games. (I prefer don't use GLSL if my  Pc doesn't support shaders and fbo and use ASM shaders by example, but I'll not make that here because I very suck in ASM, but in case of someone want to do it...)

So I've a class called "World" which use different EntityManagers type depending on which functionnalities are supported. (So I can use shaders or not, if the PC support shaders, the effects'll just be more beautifull.)

Here is an example (I use the crtp pattern) :P
#ifndef WORLD_H
#define WORLD_H

#include <SFML/Graphics.hpp>
#include "../Graphics/3D/view.h"
#include "../Graphics/2D/entityManager.h"
#include "../Graphics/3D/entityManager.h"
namespace odfaeg {
class EntitiesUpdater;
class AnimUpdater;
class World {
    public :
        static void createEntityManager (sf::View &view, std::string name, int cellWidth, int cellHeight, int cellDepth);
        static void createEntityManager (g3d::View &view, std::string name, int cellWidth, int cellHeight, int cellDepth = 1);
        static void removeEntityManager(std::string mapName);
        static void setCurrentEntityManager(std::string name);
        static void update();
        static void checkVisibleEntities();
        template <typename E>
        static std::vector<E*> getVisibleEntities (std::string expression);
        template <typename E>
        static bool containsMovableVisibleEntity(E *ae) {
            if (!ae->isMovable())
                return false;
            if (currentEntityManager->isG2DEntity())
                static_cast<g2d::EntityManager*>(currentEntityManager)->containsMovableVisibleEntity(ae);
            else
                static_cast<g3d::EntityManager*>(currentEntityManager)->containsMovableVisibleEntity(ae);
        }
        template <typename E>
        static void removeVisibleEntity(E* entity);
        template <typename E>
        static void insertVisibleEntity(E* entity);
        virtual ~World();
    private :
        static std::vector<EntitiesUpdater*> eus;
        static std::vector<AnimUpdater*> aus;
        static std::vector<EntityManagerHolder*> ems;
        static EntityManagerHolder* currentEntityManager;
};
}
#endif
 

g3d::EntityManager use a shader but g2d::EntityManager doesn't use a shader.

I'll put some items into the class Application (the command system, the view, etc...) and the developper'll just have to inherits from this class, redefining some methods to render, build and update the world.

#ifndef APPLICATION
#define APPLICATION
#include <SFML/Graphics.hpp>
#include "resourceCache.h"
#include "../Graphics/3D/renderWindow.h"
#include "../Graphics/3D/renderStates.h"
#include "system.h"
#include "../Graphics/3D/tileMap.h"
namespace odfaeg {
class Application {
public :
    Application(sf::VideoMode vm, std::string title, bool g2dAppli, sf::Uint32 style = sf::Style::Default, sf::ContextSettings settings = sf::ContextSettings()) {
        if (g2dAppli) {
            if (sf::Shader::isAvailable()) {
                ODFAEGWindow = new g3d::RenderWindow(vm, title, style, settings);
                g3d::View& view = ODFAEGWindow->getView();
                view.setUpVector(Vec3f(0, -1, 0));
                view.scale(-1, 1, 1);
                view.move(-ODFAEGWindow->getSize().x * 0.5f, -ODFAEGWindow->getSize().y * 0.5f, 0);
            } else {
                SFMLWindow = new sf::RenderWindow(vm, title, style, settings);
            }
        } else {
            if (sf::Shader::isAvailable()) {
                ODFAEGWindow = new g3d::RenderWindow(vm, title, style, settings);
            } else {
                ODFAEGWindow = new g3d::RenderWindow(vm, title, style, settings, true);
            }
        }
        clearColor = sf::Color(0, 0, 0);
        app = this;
        running = false;
    }
    void move(float x, float y, float z = 0) {
        if (ODFAEGWindow != nullptr)
            ODFAEGWindow->getView().move(x, y, z);
        else
            SFMLWindow->getView().move(x, y);
    }
    int exec() {
        load();
        running = true;
        while (running) {
            render();
            update();
        }
        return EXIT_SUCCESS;
    }
    void stop() {
        running = false;
        if(SFMLWindow != nullptr)
            SFMLWindow->close();
        else
            ODFAEGWindow->close();
    }
    void load() {
        if (SFMLWindow != nullptr)
            g3d::TileMap::genBuffers(SFMLWindow->getSize().x, SFMLWindow->getSize().y);
        else
            g3d::TileMap::genBuffers(ODFAEGWindow->getSize().x, ODFAEGWindow->getSize().y);
        onLoad();
        onInit();
        running = true;
    }
    virtual void onInit() {}
    void render() {
        g3d::TileMap::clearBufferBits(sf::Color(0, 0, 0));
        g3d::TileMap::clearDepthBits();
        if (SFMLWindow != nullptr) {
            SFMLWindow->clear(clearColor);
        } else {
            ODFAEGWindow->clear(clearColor);
        }
        onRender();
        if (SFMLWindow != nullptr) {
            SFMLWindow->display();
        } else {
            ODFAEGWindow->display();
        }
    }
    void update() {
        sf::Event event;
        if (SFMLWindow != nullptr) {
            if (SFMLWindow->pollEvent(event)) {
                onUpdate(event);
            }
        } else {
            if (ODFAEGWindow->pollEvent(event)) {
                onUpdate(event);
            }
        }
        listener.pushEvent(event);

    }
    void draw(sf::Drawable& drawable, sf::RenderStates states = sf::RenderStates::Default) {
        if (SFMLWindow != nullptr)
            SFMLWindow->draw(drawable, states);
    }
    void draw(g3d::Drawable& drawable, g3d::RenderStates states = g3d::RenderStates::Default) {
        if (ODFAEGWindow != nullptr) {
            ODFAEGWindow->draw(drawable, states);
        }
    }
    virtual void onLoad (){}
    virtual void onRender (){}
    virtual void onUpdate (sf::Event &event) {}
    void addClock(sf::Clock clock, std::string name)  {
        //std::map<std::string, sf::Clock>::iterator it = clocks.find(name);
        /*if (it != clocks.end())
            throw Erreur (13, "This clock already exist!", 0);*/

        clocks.insert(std::pair<std::string, sf::Clock>(name, clock));
    }
    sf::Clock getClock(std::string name) {
        std::map<std::string, sf::Clock>::iterator it = clocks.find(name);
        if (it == clocks.end())
            throw Erreur (14, "Clock not found!", 0);
        return it->second;
    }

    ResourceCache& getCache() {
        return cache;
    }

    void setClearColor(sf::Color clearColor) {
        this->clearColor = clearColor;
    }
    static bool isG2dAppli() {
        return g2dAppli;
    }
    static Application* app;
private :

    sf::RenderWindow *SFMLWindow;
    g3d::RenderWindow *ODFAEGWindow;
    std::map<std::string, sf::Clock> clocks;
    Listener listener;
    ResourceCache cache;
    static bool g2dAppli;
    bool running;
    sf::Color clearColor;
};

}
#endif // APPLICATION
 

The sf::Event'll be passed at the derived application, the developper'll be able so to retrieve event's informations and the application'll pass each sf::Event to the listener which'll execute each actions.




Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
Re: [ODFAEG] (Open Source Development Framework Adapted for Every Game)
« Reply #131 on: March 18, 2014, 05:35:24 pm »
What kind of design is that? How does the entity manager know whats visible or not in the world? You really should try to encapsulate things better.

For example, you could have a renderer class which knows about the camera and the scene, and can therefore do culling by itself.. Just a suggestion

Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Re: [ODFAEG] (Open Source Development Framework Adapted for Every Game)
« Reply #132 on: March 18, 2014, 08:52:23 pm »
No because the world can have more than one entity manager so..., but the developper'll have to select the entity manager before working with it.

World::setCurrentEntityManager("entityManagerName");
 

The same things goes for the camera, I've more than one camera. (It depends of the game perspective)

So the framework have to create the right entitymanagers and the right camera depending on the hardware support..., and the game perspective... (The World class create the right entity manager and the Application class create the right camera and renderwindow)
And the entity systems have to update the current entity manager.
I've also to change the vertex position in perspective projection because I've coordinates between -1 and 1 with the perspective projection and between 0 and screenresolution with the pespective projection.

I would like to always have coordinate between 0 and screenresolution for the culling.

But the world knows about the camera and the scene so...






Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Re: [ODFAEG] (Open Source Development Framework Adapted for Every Game)
« Reply #133 on: March 19, 2014, 11:36:35 am »
Hi!

I've passed the renderwindow to the entity manager in the world.

So the shadows and lights are rendered differently depending on the hardware support (By rendertexture or by printscreen)

I'll add a render function in the class world whitch'll render the current frame.





 


Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Re: [ODFAEG] (Open Source Development Framework Adapted for Every Game)
« Reply #134 on: March 19, 2014, 02:08:01 pm »
Finally I think I'll only use my own classes to draw 3D or 2D objects with 3D vertices and get rid of SFML.

It'll be better.

It'll only use SFML for the sound and the network.

 

anything