# Re: Embedded Ruby and OpenGL

**URL:** <https://www.ruby-forum.com/t/re-embedded-ruby-and-opengl/100075>\
**Category:** Ruby\
**Created:** [July 27, 2006, 12:26am UTC](https://www.ruby-forum.com/t/re-embedded-ruby-and-opengl/100075 "2006-07-27T00:26:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Frank\_Davis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/a9adbd/32.png) [@Frank\_Davis](https://www.ruby-forum.com/u/Frank_Davis)\
**Post date:** [July 27, 2006, 12:26am UTC](https://www.ruby-forum.com/t/re-embedded-ruby-and-opengl/100075/1 "2006-07-27T00:26:16Z")

</div>

There’s only one way I can see this working: Develop a plugin for  
Firefox, using C / C++, that would operate very similar to the way the  
Flash plugin works. Your plugin would have a Ruby interpreter embedded  
in it, and support OpenGL rendering onto the space provided for it by  
the browser. Your plugin would run a Ruby/OpenGL script the same way the  
Flash plugin runs .SWF files.

While this would be a really cool plugin (and I’d definitely use it if  
it already existed), I think most people decide just to use one of the  
existing alternatives (Flash, Shockwave, SVG, or the nifty new Canvas)  
once they see the amount of work involved. Plus, these’s the drawback of  
requiring people to install your plugin before your web page will render  
correctly – that’s so dot-com!

Frank Davis

---

<div class="post-metadata">

**Author:** ![Frank\_Davis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/a9adbd/32.png) [@Frank\_Davis](https://www.ruby-forum.com/u/Frank_Davis)\
**Post date:** [July 27, 2006, 12:40am UTC](https://www.ruby-forum.com/t/re-embedded-ruby-and-opengl/100075/2 "2006-07-27T00:40:16Z")

</div>

Frank Davis wrote:

> There’s only one way I can see this working: Develop a plugin for  
> Firefox, using C / C++, that would operate very similar to the way the  
> Flash plugin works. Your plugin would have a Ruby interpreter embedded  
> in it, and support OpenGL rendering onto the space provided for it by  
> the browser. Your plugin would run a Ruby/OpenGL script the same way the  
> Flash plugin runs .SWF files.
> 
> While this would be a really cool plugin (and I’d definitely use it if  
> it already existed), I think most people decide just to use one of the  
> existing alternatives (Flash, Shockwave, SVG, or the nifty new Canvas)  
> once they see the amount of work involved. Plus, these’s the drawback of  
> requiring people to install your plugin before your web page will render  
> correctly – that’s so dot-com!
> 
> Frank Davis

Flash is equal parts wonderful and stupid. I’ve never seen this “Canvas”  
thing, and I’ll definitely check that out. It’s good to know the Erb /  
OGL thing can be done in principle, though I’d say it’s just a bit out  
of my league as yet.

As for installing… people do it for things much less cool than 3d  
games 🙂

Thanks much,  
Matthew Carlin

---

<div class="post-metadata">

**Author:** ![Frank\_Davis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/a9adbd/32.png) [@Frank\_Davis](https://www.ruby-forum.com/u/Frank_Davis)\
**Post date:** [July 27, 2006, 3:12am UTC](https://www.ruby-forum.com/t/re-embedded-ruby-and-opengl/100075/3 "2006-07-27T03:12:38Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

Frank Davis wrote:

> Your plugin would have a Ruby interpreter embedded in it, and  
> support OpenGL rendering onto the space provided for it by the  
> browser.

If you want an example of embedding a Ruby interpreter within a C  
program, have a look at my project:

[http://ruby-vpi.rubyforge.org/](http://ruby-vpi.rubyforge.org/)

Basically you run the Ruby interpreter within its own pthread and  
then have it execute some Ruby script file. But, _make sure_ that  
you _never_ call any Ruby-C-API function from your C program! _Only_  
the Ruby thread is allowed to call the Ruby-C-API.

Good luck.  
-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.4.2.2 (GNU/Linux)

iD8DBQFEyBKfmV9O7RYnKMcRAsRPAJ4zeYMmyNf1iknuKRFTbjIeoh93QwCfeOIT  
C+cjODdkLTVTzNzyp9Duh0w=  
=7o4x  
-----END PGP SIGNATURE-----
