<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/rendering-a-3d-gamepad-in-sdl-fplvwf437" -->

---
title: Rendering a 3D gamepad in SDL | daily.dev
description: A live-coding session builds a 3D gamepad visualizer using SDL3&#x27;s new GPU abstraction API and the Zig language, aiming to render a controller model with...
canonical: https://daily.dev/posts/rendering-a-3d-gamepad-in-sdl-fplvwf437
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Rendering a 3D gamepad in SDL | daily.dev
og:description: A live-coding session builds a 3D gamepad visualizer using SDL3&#x27;s new GPU abstraction API and the Zig language, aiming to render a controller model with...
og:url: https://daily.dev/posts/rendering-a-3d-gamepad-in-sdl-fplvwf437
og:image: https://api.daily.dev/og/posts/fpLVWf437.png
og:image:alt: Rendering a 3D gamepad in SDL
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Rendering a 3D gamepad in SDL

**[sphaerophoria](https://daily.dev/sources/sphaerophoria)** · 135 min read · 0 upvotes · 0 comments

## Summary

A live-coding session builds a 3D gamepad visualizer using SDL3's new GPU abstraction API and the Zig language, aiming to render a controller model with real-time button and gyro rotation data for streaming overlays. The stream walks through parsing an OBJ model exported from Blender, writing a custom OBJ lexer/parser in Zig, uploading vertex data to GPU buffers, wrestling with SDL3 GPU vertex/fragment uniform slot conventions, debugging a GPU crash caused by an incorrect uniform buffer count, fixing winding/triangulation issues, applying transform matrices for rotation, and finally wiring up SDL's gamepad and joystick event APIs to detect button presses and map them to the rendered model.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.youtube.com/watch?v=KySAnseDmU4>

## Questions this post answers

### In SDL3's GPU API, which uniform set number should be used for vertex shader uniform data versus fragment shader uniform data?

Vertex shader uniform data goes in set one, while set zero is reserved for samplers, storage textures, and storage buffers used by the vertex shader. Fragment shader uniform data goes in set three. Getting these wrong, or declaring the wrong number of uniform buffers for a stage, can cause invalid memory access and crash the GPU driver entirely.

_Developers debugging SDL3 GPU pipeline crashes can find similar low-level API gotchas curated on daily.dev._

### Why would only half the triangles of an OBJ model render correctly with holes in the mesh?

This can happen when the OBJ file contains quad faces instead of triangles and the exporter or parser doesn't triangulate them, causing every other triangle in a quad to be dropped or malformed. Re-exporting the mesh from Blender with the triangulate option enabled and ensuring modifiers like mirror are applied before export resolves the missing-triangle rendering artifacts.

_Anyone troubleshooting mesh rendering glitches can track practical graphics debugging writeups on daily.dev._

### How do you detect gamepad button presses using SDL3's event system?

Call SDL_InitSubSystem with both joystick and gamepad flags, then listen for SDL_EVENT_GAMEPAD_ADDED to open the device with SDL_OpenGamepad using its device ID. Subsequent SDL_EVENT_GAMEPAD_BUTTON_DOWN and SDL_EVENT_GAMEPAD_BUTTON_UP events include the gamepad ID and an SDL_GamepadButton value identifying which button, such as south, back, or start, changed state.

_Developers wiring up controller input handling can follow hands-on SDL3 gamepad walkthroughs like this on daily.dev._

## Similar posts on daily.dev

- [Master Low-Level Graphics in C: Build a Software Renderer from Scratch](https://daily.dev/posts/master-low-level-graphics-in-c-build-a-software-renderer-from-scratch-ssvj3mayp) · freeCodeCamp · 0 upvotes · 0 comments

---

Tags: [#gpu](https://daily.dev/tags/gpu), [#zig](https://daily.dev/tags/zig), [#graphics-programming](https://daily.dev/tags/graphics-programming)

[View this post on daily.dev](https://daily.dev/posts/rendering-a-3d-gamepad-in-sdl-fplvwf437)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Rendering a 3D gamepad in SDL","url":"https://daily.dev/posts/rendering-a-3d-gamepad-in-sdl-fplvwf437","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/rendering-a-3d-gamepad-in-sdl-fplvwf437"},"datePublished":"2026-08-13T23:05:02.657Z","dateModified":"2026-08-13T23:30:59.273Z","description":"A live-coding session builds a 3D gamepad visualizer using SDL3's new GPU abstraction API and the Zig language, aiming to render a controller model with...","image":"https://i.ytimg.com/vi/KySAnseDmU4/sddefault.jpg","thumbnailUrl":"https://i.ytimg.com/vi/KySAnseDmU4/sddefault.jpg","isAccessibleForFree":true,"articleSection":"sphaerophoria","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"sphaerophoria","logo":"https://media.daily.dev/image/upload/s--dgPUg2T7--/f_auto/v1728806109/logos/sphaerophoria","url":"https://daily.dev/sources/sphaerophoria"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/rendering-a-3d-gamepad-in-sdl-fplvwf437","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"gpu,zig,graphics-programming","timeRequired":"PT135M","video":{"@type":"VideoObject","name":"Rendering a 3D gamepad in SDL","description":"A live-coding session builds a 3D gamepad visualizer using SDL3's new GPU abstraction API and the Zig language, aiming to render a controller model with...","thumbnailUrl":"https://i.ytimg.com/vi/KySAnseDmU4/sddefault.jpg","uploadDate":"2026-08-13T23:05:02.657Z","duration":"PT135M","url":"https://api.daily.dev/r/fpLVWf437","embedUrl":"https://www.youtube.com/embed/KySAnseDmU4"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"sphaerophoria","item":"https://daily.dev/sources/sphaerophoria"},{"@type":"ListItem","position":3,"name":"Rendering a 3D gamepad in SDL"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/rendering-a-3d-gamepad-in-sdl-fplvwf437#faq","mainEntity":[{"@type":"Question","name":"In SDL3's GPU API, which uniform set number should be used for vertex shader uniform data versus fragment shader uniform data?","acceptedAnswer":{"@type":"Answer","text":"Vertex shader uniform data goes in set one, while set zero is reserved for samplers, storage textures, and storage buffers used by the vertex shader. Fragment shader uniform data goes in set three. Getting these wrong, or declaring the wrong number of uniform buffers for a stage, can cause invalid memory access and crash the GPU driver entirely. Developers debugging SDL3 GPU pipeline crashes can find similar low-level API gotchas curated on daily.dev."}},{"@type":"Question","name":"Why would only half the triangles of an OBJ model render correctly with holes in the mesh?","acceptedAnswer":{"@type":"Answer","text":"This can happen when the OBJ file contains quad faces instead of triangles and the exporter or parser doesn't triangulate them, causing every other triangle in a quad to be dropped or malformed. Re-exporting the mesh from Blender with the triangulate option enabled and ensuring modifiers like mirror are applied before export resolves the missing-triangle rendering artifacts. Anyone troubleshooting mesh rendering glitches can track practical graphics debugging writeups on daily.dev."}},{"@type":"Question","name":"How do you detect gamepad button presses using SDL3's event system?","acceptedAnswer":{"@type":"Answer","text":"Call SDL_InitSubSystem with both joystick and gamepad flags, then listen for SDL_EVENT_GAMEPAD_ADDED to open the device with SDL_OpenGamepad using its device ID. Subsequent SDL_EVENT_GAMEPAD_BUTTON_DOWN and SDL_EVENT_GAMEPAD_BUTTON_UP events include the gamepad ID and an SDL_GamepadButton value identifying which button, such as south, back, or start, changed state. Developers wiring up controller input handling can follow hands-on SDL3 gamepad walkthroughs like this on daily.dev."}}]}
```

