Skip to content
/ kreogl Public

A simple OpenGL renderer, aimed to get any game project up and running with simple but satisfying graphics.

License

Notifications You must be signed in to change notification settings

phisko/kreogl

Repository files navigation

kreogl

build

A simple OpenGL renderer, aimed to get any game project up and running with simple but satisfying graphics.

Motivation

I'm not a graphics programmer and, although I do find it fun when I get pretty things to appear on-screen, I much prefer metaprogramming and engine architecture. However, whenever I've wanted to get some proof-of-concept graphics, I've always been frustrated to see there's no 3D equivalent to SFML: a simple 3D graphics library, letting me load meshes and draw them without having to write my own shaders.

Eventually I came to accept this, and started implementing a custom OpenGL system for the kengine. This was a learning process for me, as it was my first time toying with graphics programming.

Now that I'm relatively satisfied with the final result (although it's far from perfect), I figured it was time to move the functionality out of the kengine and have it become what I was initially looking for, so that future engine programmers don't have to write their own renderer from scratch.

Usage

Take a look at the example code. There are two examples:

  • a simple one which shows how to quickly draw and animate a model
  • a more complex one, which makes use of most available features but may be a bit harder to follow

The examples can be built by setting the KREOGL_EXAMPLE CMake option.

Below is a snippet of the important parts of the simple example:

kreogl::window window; // create a window
window.get_default_camera().set_position({ 0.f, 0.f, -5.f }); // move the camera back to see the centered scene

kreogl::world world; // the world that will be used to draw into the window

const kreogl::skybox_texture skybox_texture{ // load the skybox
	"resources/skybox/left.jpg",
	"resources/skybox/right.jpg",
	"resources/skybox/top.jpg",
	"resources/skybox/bottom.jpg",
	"resources/skybox/front.jpg",
	"resources/skybox/back.jpg",
};
world.skybox.texture = &skybox_texture; // add it to the world

kreogl::directional_light light; // create a light
world.add(light); // add it to the world
light.direction = { 0.f, -1.f, -1.f };
light.cast_shadows = false; // disable shadows for our scene

const auto model = kreogl::assimp::load_animated_model("resources/funnyman/funnyman.fbx"); // load a 3d model
assert(model && model->animations.size() == 1);

kreogl::animated_object object; // create an object
object.model = model.get(); // base it on the loaded 3d model
object.transform = glm: