SimpleGL  1.1.0
A framework for platform independent rendering
The SimpleGL Framework

Table of Contents

Introduction

This is the documentation of the SimpleGL project. You can find the repository of this framework here.

SimpleGL is licensed under the MIT License, which can be found here.

Installation

Step 1: Get the external libraries

This framework has some external depenencies, before using it you should get the following third party libraries:

For the OpenGL backend you also need the following third party libraries:

Follow the installation guides of these libraries.

For using the Vulkan backend you should have the Vulkan SDK installed.

Step 2: Compile source

After installing the third party libraries you should get the source code of this repository. You can download the current code by clicking here or by cloning this repository with Git.

This project is using CMake for generating project files or Makefiles. You need at least version 3.0.2 for compiling. After generating the files just compile it with your chosen compile environment like MinGW, Visual Studio or GCC.

The CMake file offers some options for the compilation.

Alternatively you can get the precompiled Windows source here. Note that this is currently a legacy version of the library which will only work on Windows systems.

Step 3: Install

The installation will be done by the generated CMake build files for example by calling make install or running the INSTALL project in Visual Studio. You can configure the installation directory by setting the CMAKE_INSTALL_PREFIX variable when generating the build files.

Create an example project

In the first step you need to create a C++ application. In the application project you have to create a reference to the framework.

With those prerequisites done you can create the source code now. For using the framework you need to extend a class with sgl::ApplicationGL if you want to use the OpenGL backend or sgl::ApplicationVK when using the Vulkan backend. The header file should look more or less like this:

#ifndef EXAMPLEAPPLICATION_HPP
#define EXAMPLEAPPLICATION_HPP
class ExampleApplication : public sgl::ApplicationGL {
public:
ExampleApplication(void);
~ExampleApplication(void);
void handleEvents(std::vector<sgl::Event*> events) override;
void updateScene(float delta) override;
void renderScene(float alpha) override;
};
#endif /* EXAMPLEAPPLICATION_HPP */

In the corresponding source file you implement a method for drawing, the source file should look somewhat like this:

#include "ExampleApplication.hpp"
using namespace sgl;
ExampleApplication::ExampleApplication(void) {
// Here you can add code for initializing the class
}
ExampleApplication::~ExampleApplication(void) {
// Here you can add code for disposing the class
}
void ExampleApplication::handleEvents(std::vector<sgl::Event*> events) {
// Here you can add code to handle mouse and key events
}
void ExampleApplication::updateScene(float delta) {
// Here you can add code to update the scene
}
void ExampleApplication::renderScene(float alpha) {
batch->begin();
batch->color(1.0, 0.0, 0.0);
batch->vertex(-0.75, -0.75, 0.0);
batch->color(0.0, 1.0, 0.0);
batch->vertex(0.75, -0.75, 0.0);
batch->color(0.0, 0.0, 1.0);
batch->vertex(0.0, 0.75, 0.0);
batch->end();
}

Now you need a main method to start the application. Your main file just needs to start the application:

#include "ExampleApplication.hpp"
int main() {
sgl::Application* app = new ExampleApplication();
app->run();
}

If everything is alright you should see a three-colored triangle.

triangle.png
Three-colored triangle