Skip to content

Konstantysz/kappa-core

Repository files navigation

kappa-core

Build Status Tests Static Analysis Documentation

A modern C++20 application framework for OpenGL applications, providing essential infrastructure for window management, rendering, logging, and event handling.

Features

  • Application Framework - Complete application lifecycle management with layer-based architecture
  • Window Management - GLFW-based window wrapper with framebuffer callbacks and OpenGL context
  • Texture System - RAII-based OpenGL texture management
  • Logging - Powerful spdlog-based logging system with source location tracking
  • Event System - Type-safe event bus for decoupled communication
  • Layer Architecture - Composable layer system for organizing rendering and update logic

Components

Core Components

  • Application - Main application class managing window, layers, and render loop
  • Window - GLFW window wrapper with OpenGL context management
  • Layer - Abstract base class for application layers (UI, rendering, etc.)
  • EventBus - Type-safe publish-subscribe event system
  • Logger - Singleton logging system with multiple log levels
  • Texture - RAII OpenGL texture wrapper

Dependencies

  • GLFW 3 - Window and input management
  • glad - OpenGL loader
  • glm - OpenGL Mathematics library
  • spdlog - Fast C++ logging library

All dependencies are managed via vcpkg.

Requirements

  • C++20 compatible compiler
  • CMake 3.26+
  • vcpkg (for dependency management)

Installation

Using as a Git Submodule

cd your-project
git submodule add https://github.com/yourusername/kappa-core.git external/kappa-core
git submodule update --init --recursive

CMake Integration

# Add kappa-core subdirectory
add_subdirectory(external/kappa-core)

# Link against Core library
target_link_libraries(YourApp PRIVATE Core)

Quick Start

Minimal Application

#include "Application.h"
#include "Layer.h"

class MyLayer : public Kappa::Layer
{
public:
    void OnUpdate(float deltaTime) override
    {
        // Update logic here
    }

    void OnRender() override
    {
        // Rendering logic here
    }
};

int main()
{
    Kappa::ApplicationSpecification spec;
    spec.name = "My Application";
    spec.width = 1280;
    spec.height = 720;

    Kappa::Application app(spec);
    app.PushLayer(std::make_shared<MyLayer>());
    app.Run();

    return 0;
}

Logging

#include "Logger.h"

// Simple logging
LOG_INFO("Application started");
LOG_WARN("Warning message");
LOG_ERROR("Error occurred: {}", errorCode);

// Logging with source location
LOG_DEBUG("Debug info at {}:{}", __FILE__, __LINE__);

Event System

#include "EventBus.h"
#include "Event.h"

// Define custom event
struct MyEvent : public Kappa::Event
{
    int data;
};

// Subscribe to events
auto& eventBus = app.GetEventBus();
eventBus.Subscribe<MyEvent>([](const MyEvent& event) {
    LOG_INFO("Received event with data: {}", event.data);
});

// Publish events
eventBus.Publish(MyEvent{42});

Texture Loading

#include "Texture.h"

// Load texture from file (requires image loading library)
Kappa::Texture texture;
// ... load image data ...
texture.Create(width, height, imageData);

// Use texture
glBindTexture(GL_TEXTURE_2D, texture.GetID());

Architecture

Application Lifecycle

Application::Run()
├── Initialize Window
├── Load Resources
└── Main Loop
    ├── Process Events
    ├── Update Layers (OnUpdate)
    ├── Render Layers (OnRender)
    └── Swap Buffers

Layer System

Layers are processed in the order they're added:

  1. Update Phase - Each layer's OnUpdate() is called
  2. Render Phase - Each layer's OnRender() is called

Layers can be used for:

  • UI rendering (ImGui, etc.)
  • Game world rendering
  • Debug overlays
  • Post-processing effects

Examples

See the examples/ directory for complete sample applications:

  • minimal - Bare minimum application
  • logging - Logging system demonstration
  • layers - Multi-layer rendering
  • events - Event bus usage

Building

# Configure
cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=[vcpkg root]/scripts/buildsystems/vcpkg.cmake

# Build
cmake --build build

# Run tests
ctest --test-dir build

Testing

Kappa-core includes comprehensive unit tests using Google Test framework.

Running Tests

# Using CMake presets
cmake --preset Debug-vcpkg
cmake --build --preset Debug-vcpkg
ctest --preset Debug-vcpkg

# Or manually
cd build
ctest --output-on-failure

Test Coverage

Code coverage analysis is available using LLVM tools (requires llvm-profdata and llvm-cov).

# Enable coverage in CMake
cmake --preset Debug-coverage -DENABLE_COVERAGE=ON

# Run coverage analysis (automated)
python scripts/run-coverage.py

# Or manually using CMake targets
cmake --build build --target kappa-coverage-html
cmake --build build --target kappa-coverage-open  # Opens HTML report

Current Coverage: ~39% (73/81 tests passing)

  • Function Coverage: 39.29% (22/56)
  • Line Coverage: 38.92% (151/388)
  • Branch Coverage: 35.37% (29/82)

Test Suite

  • TestSimple.cpp - Basic sanity tests (4 tests)
  • TestEventBus.cpp - Event system tests (15 tests)
  • TestLayer.cpp - Layer lifecycle tests (15 tests)
  • TestWindow.cpp - Window specification tests (12 tests)
  • TestWindowStatePersistence.cpp - JSON persistence tests (15 tests)
  • TestApplication.cpp - Application framework tests (20 tests, 8 disabled due to MSVC allocator issues)

Total: 81 tests (73 passing, 8 disabled)

Project Structure

kappa-core/
├── include/                 # Public headers
│   ├── Application.h        # Main application framework
│   ├── Window.h             # GLFW window wrapper
│   ├── Layer.h              # Layer base class
│   ├── EventBus.h           # Event system
│   ├── Logger.h             # Logging system
│   ├── Texture.h            # OpenGL texture wrapper
│   └── Event.h              # Event base class
├── src/                     # Implementation files
│   ├── Application.cpp
│   ├── Window.cpp
│   ├── WindowStatePersistence.cpp
│   └── Texture.cpp
├── tests/                   # Unit tests (Google Test)
│   ├── TestSimple.cpp
│   ├── TestEventBus.cpp
│   ├── TestLayer.cpp
│   ├── TestWindow.cpp
│   ├── TestWindowStatePersistence.cpp
│   ├── TestApplication.cpp
│   └── README.md
├── cmake/                   # CMake modules
│   └── CodeQuality.cmake    # Coverage & quality targets
├── scripts/                 # Utility scripts
│   └── run-coverage.py      # Automated coverage analysis
├── examples/                # Example applications
├── CMakeLists.txt           # Build configuration
├── vcpkg.json               # Dependency manifest
├── README.md                # This file
└── TESTING.md               # Testing documentation

Design Philosophy

  • Modern C++ - Leverages C++20 features for clean, expressive code
  • RAII - Resource management through constructors/destructors
  • Minimal Dependencies - Only essential libraries, all via vcpkg
  • Type Safety - Strong typing, compile-time checks where possible
  • Composability - Layer system allows mixing different concerns
  • Zero-Cost Abstractions - Thin wrappers with minimal overhead

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Submit a pull request

License

MIT License - see LICENSE file for details

Acknowledgments

Built with:

Version History

v1.0.0 (Initial Release)

  • Application framework with layer system
  • Window management with GLFW
  • Logging system with spdlog
  • Event bus for type-safe events
  • OpenGL texture wrapper

Made with ❤️ for building modern C++ applications

About

Modern C++20 application framework for OpenGL applications

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors