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.


Topics - Kan

Pages: [1]
1
SFML projects / Arc Library
« on: October 03, 2021, 03:18:20 pm »
Hi. I would like to share a small project that I've been working on for a while. The project is called Arc and it is a header only library that contains vertex array utilities for use with SFML.

Even though the focus is on vertex arrays there are a bunch of extra stuff there as well such as vector utilities and matrix transformations on 2d points and I am also keen on adding more stuff to it in the future.

Here is some sample code to give a short demonstration of how to use it
#include <Arc/Arc.hpp> // include all of Arc's features
#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window({ 800, 600 }, "Demo");
    window.setFramerateLimit(60);
   
    sf::VertexArray vertices;
    vertices.setPrimitiveType(sf::Quads);
    vertices.resize(4);
   
    // functions like this are templated on what container you are using for holding an array of sf::Vertex
    // such as sf::VertexArray or std::vector<sf::Vertex>
    Arc::MakeQuad(vertices, 0, { 400.0f, 300.0f }, { 200.0f, 200.0f });
   
    sf::Clock clock;
    while (window.isOpen())
    {
        sf::Event evt;
        while (window.pollEvent(evt))
        {
            if (evt.type == sf::Event::Closed)
            {
                window.close();
            }
        }
       
        const float dt = clock.restart.asSeconds();
        Arc::RotateQuad(vertices, 0, dt * 180.0f); // rotate the quad 180 degrees per second
       
        window.clear();
        window.draw(vertices);
        window.display();
    }
   
    return 0;
}
 

If anyone is interested in other stuff you can do, there is an examples that you can either build using cmake or just directly placing it in your own project similar to ImGui::ShowDemoWindow().

I think this will be useful for people who want some form of batch rendering in their SFML applications.

The link to the github repository is here for those who are interested but please note that this library makes use of some C++17 features which means that C++17 or higher is a requirement.
https://github.com/kan-xyz/Arc

That is all I have for now, I hope people will have fun with this.

Pages: [1]