Git Product home page Git Product logo

dimension3d's Introduction

Dimension3D

Release Language Size Open Source


This repository contains the source code of a simple graphics library (2D, 3D and windows). It looks like SFML for 3D or ThreeJS for C++.



Summary


Features

Windows :

  • Interactive windows with buttons, sliders... (see ImGui for more information)

  • Scene windows for display

2D :

  • Rectangles, circles, custom shapes, images... (see SFML for more information) on a scene or the main window

  • A drag controller to move the view with the mouse

3D :

  • Cubes, spheres, cylinders, cones, custom meshes...

  • Phong materials, Textures...

  • Ambient, directional and point lights

  • Perspective and orthographic cameras

  • Drag, fly and orbit controllers

Simplified OpenGL objects :

  • Shaders, framebuffers, vertexbuffers, textures...

Utils :

  • Colors, vectors, small functions...

Install

Dependencies

Integrating into your project (not recommended)

Link all the dependecies to your project and compile the Dimension3D library as if it was part of your project.

Using the skeleton project (recommended)

Download the skeleton project, delete the main.cpp demo and put your project files in the sources folder.

Then follow the instructions of the skeleton project here.


Demo

Code example

#include <dim/dimension3D.hpp>

int main()
{
    // Open the main window and initialize the libraries
    dim::Window::open("App", 0.75f);

    // Create the scenes
    dim::Scene scene("Scene");

    // Cameras and controllers
    scene.set_controller(dim::OrbitController());

    dim::PerspectiveCamera cam;
    cam.set_position(dim::Vector3(0.f, 0.f, 3.f));
    scene.set_camera(cam);

    // Add lights
    scene.add_light(dim::DirectionalLight(dim::Vector3(-1.f, -1.f, -1.f)));

    // Create objects
    dim::Object object_1(dim::Mesh::Sphere(256, 256), dim::Material(dim::Color(1.f, 0.1f, 0.1f), 0.1f, 0.5f, 0.6f, 30.f));

    dim::Object object_2(dim::Mesh::Cone(256), dim::Material(dim::Color(0.1f, 1.f, 0.1f), 0.1f, 0.5f, 0.6f, 30.f));
    object_2.move(dim::Vector3(1.1f, 0.f, 0.f));

    dim::Object object_3(dim::Mesh::Cylinder(256), dim::Material(dim::Color(0.1f, 0.1f, 1.f), 0.1f, 0.5f, 0.6f, 30.f));
    object_3.move(dim::Vector3(-1.1f, 0.f, 0.f));

    // The example button color
    float color[4] = { 1.f, 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);
            scene.check_events(sf_event);
        }

        // Clear the screen
        dim::Window::clear();
        scene.clear();

        // Update interactive stuff
        dim::Window::update();
        scene.update();

        // Draw the objects
        scene.draw(object_1);
        scene.draw(object_2);
        scene.draw(object_3);

        // Display the scenes to the window
        scene.display();

        // The ImGui window and button example
        ImGui::Begin("Menu");
        ImGui::Button("Button");
        ImGui::ColorPicker3("Color picker", color, ImGuiColorEditFlags_PickerHueWheel);
        ImGui::End();

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

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

Release

You can also see the releases of the skeleton project to test the example code without compiling.


Documentation

You can read the documentation by consulting the wiki.


Notes

  • This is a small project of a single beginner programmer so there may be bugs if you do not use the library as indicated

Credits

dimension3d's People

Contributors

angeluriot avatar maghin avatar antoninhrlt avatar loicvdb avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.