DEV Community

Cover image for GoGPU: A Pure Go Graphics Library for GPU Programming
Andrey Kolkov
Andrey Kolkov

Posted on

GoGPU: A Pure Go Graphics Library for GPU Programming

Finally, a graphics framework that feels like Go.

TL;DR

  • Problem: Go lacks a professional graphics library
  • Solution: GoGPU — Pure Go, Zero-CGO, WebGPU-based
  • Result: 15 lines of code instead of 500
  • Status: Working triangle demo, Windows support
  • Repo: github.com/gogpu/gogpu

The Problem: Go and Graphics Don't Mix (Until Now)

If you've ever tried graphics programming in Go, you know the pain:

  • CGO hell — Most libraries require a C compiler
  • Abandoned projects — Promising repos with no updates since 2019
  • "Just use Rust/C++" — The default answer in every forum

I saw this frustration firsthand in a Reddit thread: "Go deserves more support in GUI development".

Hundreds of upvotes. Dozens of comments. All saying the same thing:

"Why can't we have nice things in Go?"

So I decided to build it.

Introducing GoGPU

GoGPU is a Pure Go GPU Computing Ecosystem designed to make graphics programming accessible to every Go developer.

Principle What It Means
Zero-CGO No C compiler required. Pure Go bindings via FFI.
WebGPU-First Modern API. Works on Vulkan, Metal, DX12. Future WASM support.
Simple by Default Easy things are easy. Hard things are possible.
Cross-Platform Windows today. macOS and Linux coming soon.

Show Me the Code

Here's a complete program that opens a window and draws a colored triangle:

package main

import (
    "log"
    "github.com/gogpu/gogpu"
    "github.com/gogpu/gogpu/math"
)

func main() {
    app := gogpu.NewApp(gogpu.DefaultConfig().
        WithTitle("GoGPU Triangle").
        WithSize(800, 600))

    app.OnDraw(func(ctx *gogpu.Context) {
        ctx.DrawTriangleColor(math.DarkGray)
    })

    if err := app.Run(); err != nil {
        log.Fatal(err)
    }
}
Enter fullscreen mode Exit fullscreen mode

That's 15 lines.

The equivalent raw WebGPU code? 400-500 lines of boilerplate.

GoGPU handles:

  • Window creation and event loop
  • GPU device initialization
  • Surface configuration
  • Shader compilation
  • Render pipeline setup
  • Frame presentation

You focus on what to draw. GoGPU handles how.

How It Works

┌─────────────────────────────────────────┐
│           Your Application              │
│         (15 lines of code)              │
├─────────────────────────────────────────┤
│             gogpu/gogpu                 │
│         Graphics Framework              │
├─────────────────────────────────────────┤
│             gogpu/naga                  │
│    Shader Compiler (WGSL → SPIR-V)      │
├─────────────────────────────────────────┤
│          go-webgpu/webgpu               │
│       Pure Go WebGPU Bindings           │
├─────────────────────────────────────────┤
│          go-webgpu/goffi                │
│        Pure Go FFI (Zero-CGO)           │
├─────────────────────────────────────────┤
│            wgpu-native                  │
│       Vulkan / Metal / DX12             │
└─────────────────────────────────────────┘
Enter fullscreen mode Exit fullscreen mode

The key innovation is goffi — a Pure Go FFI library that lets us call native code without CGO. No C compiler. No build complexity. Just go build.

My Background

This project builds on years of work in the Go ecosystem:

GPU & Graphics:

Systems & Libraries:

The foundation is battle-tested. GoGPU is the next step.

Roadmap

Version Milestone Status
v0.0.x Project structure ✅ Done
v0.1.0-alpha Triangle rendering ✅ Done
v0.2.0-alpha Textures & sprites 🔄 Next
v0.3.0-alpha Text rendering 📋 Planned
v0.5.0-beta API stabilization 📋 Planned
v1.0.0 Production ready 🎯 Goal

The Ecosystem

Repository Purpose Status
gogpu/gogpu Core graphics framework Active
gogpu/naga Shader compiler Active
gogpu/gg 2D graphics API Planned
gogpu/ui GUI toolkit Future

Why WebGPU?

WebGPU is the future:

  1. Cross-platform by design — Same API on Windows, macOS, Linux, and browsers
  2. Modern architecture — Built on lessons from Vulkan, Metal, and DX12
  3. Safe by default — Validation prevents common GPU programming errors
  4. Browser-ready — Your code can run in WASM (future goal)

Current Status

Let's be honest:

Version: v0.1.0-alpha (Early Development)
Platform: Windows (macOS/Linux stubs ready)
API: Will change. Things will break.
Enter fullscreen mode Exit fullscreen mode

But:

  • ✅ The architecture is solid
  • ✅ The triangle renders
  • ✅ The foundation is proven (go-webgpu powers Born ML)

How You Can Help

⭐ Star the Repo

github.com/gogpu/gogpu

🧪 Try It Out

git clone https://github.com/gogpu/gogpu
cd gogpu
go run ./examples/triangle
Enter fullscreen mode Exit fullscreen mode

🐛 Report Issues

Open an issue

💻 Contribute Code

PRs welcome! Especially needed:

  • macOS platform support
  • Linux platform support
  • Documentation
  • More examples

Links


Go deserves a great graphics library. Let's build it together.

Questions? Drop them in the comments.

Top comments (0)