Giter VIP home page Giter VIP logo

aespinosadev / opengl-starterpack Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 15.04 MB

OpenGL-StarterPack (GLSP) is a lightweight open source OpenGL based framework that facilitates and speeds up project creation by offering a thin and flexible abstraction to the basic objects of the OpenGL API

License: MIT License

CMake 1.43% C++ 98.57%
computer-graphics computer-science graphics graphics-engine graphics-library graphics-programming learning open-source opengl opengl46 rendering rendering-3d-graphics rendering-engine shader shaders vulkan khrono

opengl-starterpack's Introduction

OpenGL-StarterPack (GLSP) πŸ“¦

OpenGL-StarterPack (GLSP) is a lightweight open source OpenGL based framework that facilitates and speeds up project creation by offering a thin and flexible abstraction to the basic objects of OpenGL.

GLSP is simple and aims for simplicity, adding only a light layer of abstraction to OpenGL. All its classes are designed to be easy inherited and converted into more complex objects, in case they are used as a base for more serious applications.

Finally, GLSP comes with the main lightweight libraries used in graphics already included and integrated, to offer the user their functionality from the start.

The philosophy of GLSP is based on inheritance. It provides a simple skeleton that can be easily modified so that the user can quickly achieve their goals. Thanks to this, it is also perfect for learning purposes !

image image

Table of Contents πŸ—ƒοΈ

  1. Building
  2. Project Integration
  3. Usage
  4. Main Data Classes
  5. Integrated Libraries

Building πŸ› οΈ

The prequisites for using this code are:

  • Windows 10, 11, Ubuntu 24.*.
  • CMake installed.
  1. Clone the repo:
    git clone https://github.com/AEspinosaDev/OpenGL-StarterPack.git
    cd OpenGL-StarterPack
  2. Build with CMake:
    mkdir build
    cd build
    cmake ..

The project is configured in such a way that, during the build process, CMake takes care of automatically locating and linking all dependencies on the system. Although the project has been implemented in Visual Studio Code, a practical file structure has been configured for CMake in case it is opened in Visual Studio.

The project compiles dependencies, the library itself, and the example applications directory, which statically links against the 3D library. The library is a STATIC lib, do not try to link dynamically against it.

  1. Building of the examples directory is optional, and can be turned off in CMake:
cmake -DBUILD_EXAMPLES=OFF /path/to/source

Project Integration βš™οΈ

Integration of GLSP into your own personal project is quite easy. If working with CMake, GLSP should be inserted inside the dependencies folder of your project root directory.

On your main project CMakeLists.txt, write:

cmake_minimum_required(VERSION 3.16)

project(JohnDoe VERSION 1.0.0)

# Add GLSP subdirectory ! Set if you want to build the examples directory ...
set(GLSP_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
add_subdirectory(dependencies/OpenGL-StarterPack)

#Setup project own source code (User-Defined)
file(GLOB APP_SOURCES "src/*.cpp")
file(GLOB APP_HEADERS "include/*.h")
add_executable(JohnDoe ${APP_SOURCES} ${APP_HEADERS})
target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include/)

# Link project against GLSP
target_link_libraries(JohnDoe PRIVATE GLSP)

....

Your project structure should be somewhat like this one:

project_root/
β”‚
β”œβ”€β”€ resources/
β”‚   β”œβ”€β”€ shaders
β”‚   β”œβ”€β”€ textures
β”‚   └── meshes
β”‚
β”œβ”€β”€ dependencies/
β”‚   β”œβ”€β”€ OpenGL-StarterPack
β”‚   └── another-cool-dependencies
β”‚
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ main.cpp
β”‚   └── compilation_file1.cpp
β”‚
β”œβ”€β”€ include/
β”‚   β”œβ”€β”€ header1.h
β”‚   └── header2.h
β”‚
└── CMakeLists.txt

If you are not working with CMake, sorry, but it is time for you to know... you should be !! Nah, just kidding πŸ™„ you can check how to include GLSL as a dependency in your IDE of choice. With luck, your IDE should not be difficult to handle.

Usage ✨

I encourage you to check the examples directory if you want to see how to use this framework.

  • The simple example can serve as a quite good starting point for any project.
  • Complex example shows how to work with a more complex OpenGL (different shader stages, compute, uniform buffers, user defined geometry)

As told in introduction, GLSP encourages you to take all that it has in order for you to modify it and turn it into yout own purposes.

It is also a good starting point for anyone trying to learn computer graphics or a simple graphics API such as OpenGL, as its thin abstraction facilitates the comprehension of OpenGL workarounds.

Main Data Classes 🧩

Class Description
Renderer A simple class that implements all the functionality associated with a renderer (creation and control of the graphic context, flow control, drawing loops, and updates). It is imperative that it be inherited and modified to create more complex and robust applications.
Buffer Wrappers of VAOs, VBOs, IBOs, and UBOs that allow the user to have complete control over their creation and use.
Camera A class that implements all the basic functionalities that a virtual camera should have.
Controller A class that serves as an interface between the spatial movement of 3D objects and user input. Useful for controlling the camera, for example.
Framebuffer Practical and flexible abstraction of FBOs and RBOs.
Loaders A namespace that offers some resource loading functions (.obj, .ply, images).
Mesh Abstracts and represents a mesh, composed, among others, of a geometry class and a material class. Inherits from Object3D, the base class that represents any object capable of being placed in a virtual world, characterized by its transform struct.
Shader Abstracts the functionality of OpenGL programs and the compilation of the different stages of the graphics and compute pipelines. GLSP shaders allow implementing all the functionality of the graphics pipeline in a single .glsl file, marking each part with a hashtag followed by the word stage and the name of the graphics stage itself (vertex, control, eval, geometry and fragment). It also allows separate files parsing as usual.
Texture Abstracts the functionality of OpenGL samplers and images. It is flexible, and through its configuration, all types of textures can be created.
Widgets A namespace that offers some functions to create utility widgets based on ImGui.
Material A very basic material class that abstracts and combines the concepts of the graphics pipeline, its handling, and object-level state control. For simple projects, it is not necessary, and its modification and inheritance are recommended to create more secure and solid materials in more serious projects.

Along with these classes, there are plenty of other auxiliar classes and structs and error handling functions.

Integrated Libraries πŸ“š

GLSP has already done the work of linking and integrating some useful libraries that any render application should have:

  • stb_image : for loading lots of kinds of image files πŸ–ΌοΈ.
  • tinyply : for loading .ply files πŸͺ©.
  • tiny_obj_loader : for loading .obj files πŸͺ©.
  • imgui : for having some user interface functionality πŸ“±.
  • glm : for doing some maths πŸ€“.
  • glfw : because if not, there is no window and no context 😭.
  • glad : to give you access to OpenGL, as its integrated in you hardware ! πŸ”‘

opengl-starterpack's People

Contributors

aespinosadev avatar

Stargazers

Ali Şahan Yalçın avatar

Watchers

 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.