Skip to content

jdolan/ObjectivelyGPU

Repository files navigation

Build Zlib License Beta

ObjectivelyGPU

Object oriented graphics framework for SDL3 and C.

Zlib license.

About

ObjectivelyGPU is a cross-platform object oriented graphics framework for the C programming language. Built on Objectively and SDL_gpu, it provides a unified API for modern GPU programming with Metal, Vulkan, and Direct3D 12.

Features

  • Cross-platform support for Android, iOS, macOS, Linux and Windows
  • Resource objects with automatic lifecycle — Buffer, Texture, Sampler, Shader, GraphicsPipeline, ComputePipeline and RenderDevice initialize and tear themselves down
  • Typed passes: RenderPass, ComputePass and CopyPass with command-lifecycle validation that catches mistakes upfront
  • Framebuffer abstracts multiple render targets, depth, and MSAA with automatic resolve — convenience without forfeiting the low-level API
  • Shaders loaded by name, with the formats supported by your platform
  • Mathlib — vector, matrix, and quaternion math for 3D graphics

tl;dr

The verbose, error-prone handling of a raw GPU API collapses into reference-counted objects and a handful of intuitive methods.

Uploading an image to the GPU is a single call — the staging buffer and copy pass are handled for you:

SDL_Surface *surface = IMG_Load("crate.png");
Texture *texture = $(device, createTextureFromSurface, surface, SDL_GPU_TEXTUREUSAGE_SAMPLER);
SDL_DestroySurface(surface);

And a whole frame — acquire the swapchain, clear, draw a multisampled scene, resolve, and present:

CommandBuffer *commands = $(device, beginFrame);
if (commands) {

  const SDL_FColor clearColor = { 0.1f, 0.1f, 0.2f, 1.f };
  const SDL_GPUColorTargetInfo color = $(framebuffer, colorTargetInfo, 0, SDL_GPU_LOADOP_CLEAR, SDL_GPU_STOREOP_STORE, &clearColor);
  const SDL_GPUDepthStencilTargetInfo depth = $(framebuffer, depthTargetInfo, SDL_GPU_LOADOP_CLEAR, SDL_GPU_STOREOP_DONT_CARE, 1.f);

  RenderPass *pass = $(commands, beginRenderPass, &color, 1, &depth);
  $(pass, bindPipeline, pipeline);
  $(pass, bindVertexBuffers, 0, &(SDL_GPUBufferBinding) { .buffer = vertexBuffer->buffer }, 1);
  $(pass, drawPrimitives, 36, 1, 0, 0);
  pass = release(pass);

  $(device, endFrame);
}

The endFrame method resolves the multisampled Framebuffer and presents to the swapchain for you. No manual resolve targets, no store-op bookkeeping, no presentation plumbing.

Getting Started

Check out the Installation page for dependencies, building, and linking instructions.

User Guide

Peep the User Guide to draw your first frame — the render device, resource objects, framebuffers and MSAA, the typed passes, and shaders.

API Documentation

Browse the API Documentation to explore the library further.

Project Showcase

  1. Hello renders a spinning, multisampled 3D cube.
  2. HelloCompute animates particles with a compute shader and draws them as points.
  3. ObjectivelyMVC is a framework for modern game interfaces built on SDL3, Objectively and ObjectivelyGPU.
  4. Quetoo is a free first-person shooter that uses Objectively, ObjectivelyGPU and ObjectivelyMVC extensively.

Hello — a spinning, multisampled 3D cube HelloCompute — particles animated by a compute shader Hello ObjectivelyMVC - a simple in-game menu

About

Object oriented framework for modern, cross-platform graphics with SDL_gpu. Zlib license.

Topics

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages