Skip to content
Angel Uriot edited this page Sep 9, 2021 · 13 revisions

Welcome to the Dimension3D wiki!

This wiki serves as a documentation for the library, you will find information about all the classes. I advise you to read this wiki before starting to use the library (it's quite short). Be careful! In this documentation, all the dim:: are intentionally omitted for clarity.

You can post an issue in case of problem.

Good luck!

Summary

General

The library only manages one real window (represented by the static class Window), but it can contain several ImGui windows and "scenes" (ImGui windows designed to display graphics content) represented by the class Scene. You can also display graphics content directly on the main window.

A lot of classes have a static container to store class instances (like FrameBuffer, Shader, Texture or Scene), I recommend using them because it's more convenient.

OpenGL objects (like Shader, FrameBuffer, Texture or VertexBuffer) need to be binded and unbided. Other objects (likes Object, Scene or Window) can be binded for optimization but it is not essential.

There is a default shader that takes the data with certain names, and the Object sends its data with the same names. If you want to replace only one of the two (use a custom VertexBuffer with the default shader or an Object with a custom shader), here is the name of the different data :

  • Attributes :

  • Uniforms :

    • Object :

      • u_model (mat4)
      • u_normals_model (mat3)
      • u_material (Material)
      • u_texture (Texture)
      • u_textured (int)
    • Camera :

    • Lights :

      • u_lights (Light[10])
      • u_nb_lights (int)

Main structure

To work correctly, your main.cpp code must keep this structure :

#include <dim/dimension3D.hpp>

int main()
{
    // Open the main window and initialize the libraries
    dim::Window::open(name, width, height, icon_path = "");

    // Create the scenes (not necessarily, you can directly draw on the main window)
    dim::Scene::add(name);

    // Cameras and controllers (not necessarily, you are not forced to use a camera or a controller)
    dim::Scene::get(name).set_camera(dim::PerspectiveCamera());
    dim::Scene::get(name).set_controller(dim::OrbitController());

    // Add lights (not necessarily, you are not forced to use lights)
    dim::Scene::get(name).add_light(dim::DirectionalLight(dim::Vector3(-1.f, -1.f, -1.f)));

    // Main loop
    while (dim::Window::running)
    {
        // Check events
        sf::Event sf_event;
        while (dim::Window::poll_event(sf_event))
        {
            dim::Window::check_events(sf_event);
            dim::Scene::check_all_events(sf_event);
        }

        // Clear the screen
        dim::Window::clear();
        dim::Scene::clear_all();

        // Update
        dim::Window::update();
        dim::Scene::update_all();

        // Draw stuff
        dim::Window::draw(...);
        dim::Scene::get(name).draw(...);

        // Display the scenes to the window
        dim::Scene::display_all();

        // ImGui stuff

        // Display the window to the screen
        dim::Window::display();
    }

    // Close the main window and shut down the libraries
    dim::Window::close();
    return EXIT_SUCCESS;
}

Note : If you have no scene (you display all the graphics content directly on the main window for example), you can remove all the lines related to the scenes.

Clone this wiki locally