Skip to content

v0.4.0

Latest
Compare
Choose a tag to compare
@cemderv cemderv released this 02 Oct 18:17
· 4 commits to main since this release
6db11c8

What's Changed

This release focuses on integrating ImGui into cerlib.

imgui_demo

The integration is configurable via the CERLIB_ENABLE_IMGUI CMake option, and is ON by default.
When the integration is activated, ImGui is built together with and embedded directly into cerlib.

Users of cerlib automatically get access to the ImGui API, thus can #include <imgui.h> in their code.

A new method in the Game class called draw_imgui was introduced where users can draw their ImGui stuff as usual.

Example:

#include <cerlib.hpp>
#include <imgui.h> // Automatically available

struct MyGame : cer::Game {
    // ...

    void draw(const cer::Window& window) override {
        cer::draw_sprite(img,
                         (window.size_px() - img.size()) / 2 + img_offset,
                         img_color);
    }

    // This is automatically called by cerlib when ImGui contents should be drawn.
    void draw_imgui(const cer::Window& window) override {
        ImGui::Begin("My ImGui Window");

        ImGui::Text("Hello, ImGui! %d", 123);

        if (ImGui::Button("Randomize offset"))
            img_offset = cer::random_vector2(-200, 200);

        if (ImGui::Button("Randomize color"))
            img_color = cer::random_color();

        ImGui::ColorEdit4("Image color", &img_color.r);

        ImGui::End();
    }

    cer::Image   img;
    cer::Color   img_color = cer::white;
    cer::Vector2 img_offset;
};

The integration is not exclusive to any platform, it works on all target platforms. Have fun!

Other changes include:

  • Compatibility with newer Emscripten versions
  • Make OpenGL context forward-compatible for Apple platforms
  • Improved CMake presets (wasm, wasm-debug)

Full Changelog: v0.3.0...v0.4.0