Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
RubyGL
Search
Danielle Smith
February 10, 2016
Programming
34
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
RubyGL
Ruby + OpenGL
Danielle Smith
February 10, 2016
More Decks by Danielle Smith
See All by Danielle Smith
Ruby Ruby
daninithepanini
0
160
A Brief History of Ruby
daninithepanini
0
61
Static Type Inferencing ... in Ruby?
daninithepanini
0
31
Off the Rails
daninithepanini
0
51
Action Game
daninithepanini
0
43
YeSQL
daninithepanini
0
34
Game Dev in Ruby
daninithepanini
0
49
Euler vs Hamilton
daninithepanini
0
57
Other Decks in Programming
See All in Programming
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
400
Heart of Swift Concurrency
koher
0
1.2k
AI時代のコードレビューは人に向けるな、仕組みに向けろ
texmeijin
5
3.3k
速習iPhone Duo対応
yuukiw00w
2
940
Go × SIMDで高速化するベクトル検索 ~ルーフラインモデルでSIMDが効く境界を探れ! ~
po3rin
1
6.1k
Agentic Software Factoryに、すごく賢いIF文を。 / super smart IF statement into the Agentic Software Factory.
rkaga
3
1.2k
AWSに止められる覚悟してますか?
morizo_1984
2
500
Workers Cache を知る
syumai
0
320
iOSDC2026登壇資料.pdf
riofujimon
0
200
setup-vp GitLab対応の裏側
naokihaba
0
150
標準パッケージに uuid が追加された 背景から見る Go らしい意思決定 / go_127_uuid_decision
convto
5
9.5k
世界の中心で、AI(App Intents)をさけぶ ー App Intents中心設計の実践ガイド
touyou
0
760
Featured
See All Featured
BBQ
matthewcrist
89
10k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
Paper Plane (Part 1)
katiecoart
PRO
2
11k
Writing Fast Ruby
sferik
630
63k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.4k
Optimising Largest Contentful Paint
csswizardry
37
4k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.7k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
68
58k
New Earth Scene 8
popppiees
4
2.6k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
68
58k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
2k
Designing Powerful Visuals for Engaging Learning
tmiket
1
590
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]