cerlib

Lightweight, cross-platform 2D game library for C++

APACHE-2.0 License

Stars
4

Bot releases are visible (Hide)

cerlib - v0.4.0 Latest Release

Published by cemderv 17 days ago

What's Changed

This release focuses on integrating ImGui into cerlib.


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: https://github.com/cemderv/cerlib/compare/v0.3.0...v0.4.0

cerlib - v0.3.0

Published by cemderv 25 days ago

What's Changed

  • Added Text input API (https://github.com/cemderv/cerlib/pull/35)
    • New type: cer::TextInputEvent
    • New virtual method: cer::Game::on_text_input()
    • New method: cer::Window::activate_onscreen_keyboard()
    • New method: cer::Window::deactivate_onscreen_keyboard()
  • Changed built-in colors to constexpr variables
    • Example: cer::Color::white() -> cer::white
  • Take parameters as const& in Game::update() and Game::draw()
  • Added the ability to query the current target platform
    • New enum: cer::TargetPlatform
    • New function: cer::target_platform()
    • New function: cer::is_desktop_platform()
    • New function: cer::is_mobile_platform()
  • Fixed case style of various parameters
  • Replaced <format> by fmtlib in order to allow compilation with older compilers that do not support <format>
  • cerlib now builds with GCC 13, Clang 16 and on macOS 13
  • cerlib now builds with Clang on Windows
  • Removed type_name property from cerlib objects
  • Fixed mygame template on Android
  • New function: cer::random_color()
  • Improved platform check for multi-window detection
  • Implemented proper Windows and Android logging
    • On Windows, the logging functions now write using the OutputDebugString Windows function
    • On Android, the logging functions now write to the Logcat output
  • Improved API documentation

Full Changelog: https://github.com/cemderv/cerlib/compare/v0.2.0...v0.3.0

cerlib - v0.2.0

Published by cemderv 30 days ago

  • Added gamepad support
  • Changed naming convention across all APIs
  • Decoupled math types from their functions
  • Various bug fixes