Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
RubyGL
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Danielle Smith
February 10, 2016
Programming
31
0
Share
RubyGL
Ruby + OpenGL
Danielle Smith
February 10, 2016
More Decks by Danielle Smith
See All by Danielle Smith
Ruby Ruby
daninithepanini
0
150
A Brief History of Ruby
daninithepanini
0
44
Static Type Inferencing ... in Ruby?
daninithepanini
0
26
Off the Rails
daninithepanini
0
39
Action Game
daninithepanini
0
39
YeSQL
daninithepanini
0
28
Game Dev in Ruby
daninithepanini
0
39
Euler vs Hamilton
daninithepanini
0
45
Other Decks in Programming
See All in Programming
検索設計から 推論設計への重心移動と Recall-First Retrieval
po3rin
3
980
의존성 주입과 모듈화
fornewid
0
150
2026_04_15_量子計算をパズルとして解く
hideakitakechi
0
110
10年分の技術的負債、完済へ ― Claude Code主導のAI駆動開発でスポーツブルを丸ごとリプレイスした話
takuya_houshima
0
2.6k
ついに来た!本格的なマルチクラウド時代の Google Cloud
maroon1st
0
220
HTML-Aware ERB: The Path to Reactive Rendering @ RubyKaigi 2026, Hakodate, Japan
marcoroth
0
180
Agentic Elixir
whatyouhide
0
390
AI-DLC Deep Dive
yuukiyo
9
4.7k
Going Multiplatform with Your Android App (Android Makers 2026)
zsmb
2
450
〜バイブコーディングを超えて〜 チームで実験し続けたAI駆動開発
tigertora7571
0
150
Offline should be the norm: building local-first apps with CRDTs & Kotlin Multiplatform
renaudmathieu
0
220
Vibe하게 만드는 Flutter GenUI App With ADK , 박제창, BWAI Incheon 2026
itsmedreamwalker
0
550
Featured
See All Featured
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
120
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.4k
Mobile First: as difficult as doing things right
swwweet
225
10k
Darren the Foodie - Storyboard
khoart
PRO
3
3.3k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
110
Google's AI Overviews - The New Search
badams
0
980
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
199
73k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.6k
We Are The Robots
honzajavorek
0
220
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
540
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
180
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
65
55k
Transcript
RubyGL Ruby + OpenGL
What is OpenGL?
Talks to your Graphics Processor
Universal API for all hardware
Compare with Web Dev Graphics Processor OpenGL ? ? Network
Card HTTP Rack Rails
Why OpenGL?
Cross Platform
Runs on anything with a Graphics Processor
No license required
Used by millions
Why OpenGL + Ruby?
OpenGL is a C library
C isn’t fun :(
Ruby is fun :)
How OpenGL + Ruby?
$ gem install opengl-bindings
Call OpenGL functions from Ruby
Problem?
We inherit all the problems we had writing OpenGL in
C
Function order issues
Have to remember to bind objects before you use them
glBindBuffer(some_buffer) glBufferData(some_data_to_put_in_the_buffer) # ... glBindBuffer(some_buffer) glDrawElements(...)
Whack naming conventions
“Mesh” or “3D Object” == “Vertex Array Object (VAO)”
Pointers… :(
buffer = ' '*8 glGenBuffers(1, buffer) buffer = buffer.unpack('L')[0]
glBindBuffer(some_buffer) array = [1,2,3,4,...] ptr = Fiddle.Pointer.new( array.pack('L' * array.length
* BYTES_PER_INT) ) glBufferData(ptr, 0, array.length * BYTES_PER_INT)
No real exception handling
glSomething(...) raise “error!” unless glGetError.zero? glSomething(...) raise “error!” unless glGetError.zero?
glSomething(...) raise “error!” unless glGetError.zero? glSomething(...) raise “error!” unless glGetError.zero? # etc ...
“impossible” debugging
Something went wrong ¯\_(ツ)_/¯
Something went horribly wrong ¯\_(ツ)_/¯
OpenGL in Ruby is just as hard as C
:(
Has anyone solved this?
Ruby Graphics Libraries ◦ Rubygame: 2D only, latest commit in
2011 ◦ jemini: 2D only, latest commit in 2013 ◦ ray: limited 3D support, latest commit in 2013 ◦ shoes: GUI, 2D only, JRuby only ◦ gosu: 2D only ◦ ruby-opengl: bindings only ◦ ...
So… not really.
Solution!
Let’s solve this!
Let’s fix function order issues
Extract method! def draw(buffer) glBindBuffer(buffer) glDrawElements(...) end
Let’s fix whack naming conventions
Abstract OpenGL as a “proper” OOP library class Mesh def
initialize @buffer = glCreateBuffer() end def draw glBindBuffer(@buffer) glDrawElements(...) end end
Let’s fix Pointers… :(
def create_buffer buffer = ' '*8 glGenBuffers(1, buffer) buffer.unpack('L')[0] end
def bind_buffer_data(buffer, data) glBindBuffer(some_buffer) ptr = FFI.Pointer.new( array.pack('L' * data.length
* BYTES_PER_INT) ) glBufferData(ptr, 0, data.length * BYTES_PER_INT) end
Let’s fix no real exception handling
module OpenGLDebug def method_missing(sym) retval = OpenGL.send(sym, args) # do
thing puts sym, args, retval # debug error = glGetError raise error unless error.zero? # check error retval end end
Let’s fix “impossible” debugging
¯\_(ツ)_/¯
Mittsu
Mittsu (it’s a Japanese word for the number Three)
The “Rack” of Graphics Programming
Compare with Web Dev Graphics Processor OpenGL Mittsu ? Network
Card HTTP Rack Rails
Based off THREE.js (So it inherits pretty much the same
API structure)
Still a bit rough around the edges (It inherited most
of the crappy code structure, too)
Demo!
The Future
Performance
If Mittsu is the “Rack”, What is the “Rails”?
Support all the environments!
One API to rule them all!
Imagine: OSX/iOS + Metal + Rubymotion Android + OpenGL ES
+ Rubymotion JVM + LWJGL/JOGL + JRuby Windows + DirectX? Vulkan? (next-gen OpenGL)
Contribute! https://github.com/jellymann/mittsu https://rubygems.org/gems/mittsu I need help with: • Testing! •
Refactoring! • Find Bugs! • Write documentation e.g. Getting Started Guide
One more thing...
THAAAAANKS!!!
Tweet: @jellym4nn Collaborate: github.com/jellymann Contact:
[email protected]