Skip to content

CodenameLambda/ObjectiveSDL

Repository files navigation

ObjectiveSDL

This project is unstable, untested, and the API will likely change in the future!

This is a wrapper around SDL, that allows for object oriented programming.

The goal of this project is to be able to use every feature of SDL, but in an object oriented manner. As said goal is very ambitious, because the whole SDL library is huge, this will take a while to get to the point where it is ready for usage.

A code example that uses ObjectiveSDL

This code example is meant to show, what ObjectiveSDL usage should/could look like in the future.

#include <ObjectiveSDL.hh>

int main() {
    SDL::init(SDL::Subsystems::all);
    
    SDL::Window window("Title", SDL::DisplayMode(640, 480));
    window.fill(SDL::Color(0x00, 0x00, 0x00));
    
    SDL::Font font("Arial", 64);
    
    SDL::Clock clock;
    
    SDL::mainloop([&]() mutable {
        auto tdelta = clock.tick(30);  // limits the framerate; tdelta is in milliseconds
        auto s = std::to_string(tdelta.count());
        SDL::Surface s = font.render(s);
        window.draw(s, SDL::Vector2S{20, 10});
        // Vector2S = 2 dimensional size_t vector; SDL::Window inherits from SDL::Surface
        window.update();
    });
    
    SDL::quit(SDL::Subsystems::all);
}

Contributing

You can contribute via pull requests, and contact me under [email protected] if you want to get one of the main developers of this project.

Unstable, untested

I am pretty sure that I have made some mistakes, like destructors that free resources that are still needed because the data behind it was copied.

And there are some bits that don't even allow you to copy a data structure, because the destructor would pose a problem otherwise. But this wont change in the future (probably), but I'll add some structures that do the same thing, but with std::shared_ptr or something like that.

If you find mistakes or bits where you can do better, please improve!

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published