Ruby and 2D graphics


#1

Hi everybody,

I’m searching for a way to get simple graphical output in ruby for a
simple physics simulation. All I need are circles and lines and a decent
framerate in fullscreen-like resolutions. I tried ruby-processing but in
800*600 i get less than 10 frames on my not-too-old pc. And that’s just
a
circle moving around, no physics whatsoever involved.

Thanks for your input

Philip


#2

I would recomend you gosu:

http://www.libgosu.org/

On Mar 24, 2009, at 4:01 PM, Philip Müller wrote:

Philip

regards,


#3

Quoting “Philip Müller” removed_email_address@domain.invalid:

I’m searching for a way to get simple graphical output in ruby for a
simple physics simulation. All I need are circles and lines and a
decent framerate in fullscreen-like resolutions. I tried
ruby-processing but in 800*600 i get less than 10 frames on my
not-too-old pc. And that’s just a circle moving around, no physics
whatsoever involved.

I used Ruby/OpenGL in my physics simulator. It gave me 60 fps on ~20
objects w/out physics or 30 with it. Fast enough for me. I have NVidia
Geforce FX 5200 and Athlon 64 3000+.


#4

Philip Müller wrote:

Philip
I mentioned tkar, my own tool for this purpose, on the list a few weeks
ago:

http://groups.google.com/group/ruby-talk-google/browse_thread/thread/268d3a322473d7ba

It’s written in ruby, but you can pipe it data from anything, and it
even embeds as a simulink block.

It’s based on the tk canvas, which is really pretty good for simple
purposes, and easy to make interactive.


#5

On Tue, 24 Mar 2009 21:08:34 +0100, Peter Z.
removed_email_address@domain.invalid
wrote:

I used Ruby/OpenGL in my physics simulator.

Interesting. What do I need to use OpenGL in ruby and where can I get
documentation for that?

Philip

Give a man a fire and he’s warm for a day, but set fire to him and he’s
warm for the rest of his life.
– Terry Prattchett – Jingo (1997)


#6

Quoting “Philip Müller” removed_email_address@domain.invalid:

On Tue, 24 Mar 2009 21:08:34 +0100, Peter Z.
removed_email_address@domain.invalid wrote:

I used Ruby/OpenGL in my physics simulator.

Interesting. What do I need to use OpenGL in ruby and where can I
get documentation for that?

They have a site, http://ruby-opengl.rubyforge.org/. There are also a
nice tutorial, but I found examples that were shipped with gem
(ruby-opengl) more informative. Or you can browse them at SVN
(http://ruby-opengl.rubyforge.org/svn/trunk/examples/). Unfortunately,
I cannot give you sources of my simulator, they probably were lost.


#7

Ruby/OpenGL is a 1-1 mapping of the functions under the GL module.
Just grab the ruby-opengl gem and start writing, basically.

http://ruby-opengl.rubyforge.org/tutorial.html

And I’ll second on Gosu. Good library. That, and rubygame.

Jason


#8

On Tue, 24 Mar 2009 21:08:12 +0100, Rolando A. removed_email_address@domain.invalid
wrote:

I would recomend you gosu:

http://www.libgosu.org/

ok, maybe this is getting off-topic now, but when I

sudo gem install gosu

i get

Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

I have no idea where to search for this mkmf.log file and I have no idea
why it fails in the first place.

If this is off-topic here please direct me somewhere where it fits.

thanks
Philip


#9

Philip Müller wrote:

On Tue, 24 Mar 2009 21:08:12 +0100, Rolando A. removed_email_address@domain.invalid
wrote:

I would recomend you gosu:

http://www.libgosu.org/

ok, maybe this is getting off-topic now, but when I

sudo gem install gosu

i get

Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

I have no idea where to search for this mkmf.log file and I have no idea
why it fails in the first place.

If this is off-topic here please direct me somewhere where it fits.

thanks
Philip

That’s… pretty weird. That never happens to me when I’m using gosu.
I’d ask you what platform you’re using, but perhaps a better idea would
be for me to direct your questions to the official Gosu forums:
http://www.libgosu.org/cgi-bin/mwf/forum_show.pl


#10

On Tue, 24 Mar 2009 22:26:22 +0100, Philip Müller removed_email_address@domain.invalid
wrote:

when I

sudo gem install gosu

i get

Could not create Makefile due to some reason,

nevermind.
I should have RTFM ->
http://code.google.com/p/gosu/wiki/GettingStartedOnLinux
and installed the prerequisites.
Seems to work now.

Philip


#11

Rubygame and Gosu are great options. I use Rubygame; I have started a
framework on top of it to make simple game objects with physics attached
easy to setup and run.

It’s still very much alpha, but may suit your needs:
http://shawn42.github.com/gamebox/

A sample Asteroids clone w/ physics is available here:

http://is.gd/oLTI

If it looks to meet your needs, I can walk you through setting up
Rubygame/Gamebox for yourself (as the documentation is incomplete at the
moment).

/Shawn


#12

Philip Müller wrote:
Hi everybody,

I’m searching for a way to get simple graphical output in ruby for a
simple physics simulation. All I need are circles and lines and a decent
framerate in fullscreen-like resolutions. I tried ruby-processing but in
800*600 i get less than 10 frames on my not-too-old pc. And that’s just
a
circle moving around, no physics whatsoever involved.

Thanks for your input

Philip

Two more options:

Chipmunk

2D video games engine; 2D graphics library

http://wiki.slembcke.net/main/published/Chipmunk

http://code.google.com/p/gosu/wiki/RubyChipmunkIntegration

GLFW

a free, Open Source, portable framework for OpenGL application
development

http://ruby-glfw.rubyforge.org

Cheers,

j.k.


#13

2009/3/25 Tom R. removed_email_address@domain.invalid:


SYSTEM CONFIGURATION

Windows Vista
sqlite3.dll is in the same directory as the program - windows version
ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32]
gem sqlite3-ruby-1.2.0-mswin32

Move sqlite3.dll to somewhere in your PATH.

Refer to
http://groups.google.com/group/comp.lang.ruby/browse_thread/thread/9d5c9ee6167dace4

Regards,

Park H.


#14

Can anyone tell me how to correct the following error?

RUBY PROGRAM:

require ‘sqlite3’
p “open db”
db = SQLite3::Database.new( “data.db” )
p “db close”
db.close


ERROR:

ruby dbtest.rb
./sqlite3.dll: 127: The specified procedure could not be found. -
Init_sqlite3 (LoadError)
./sqlite3.dll from
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require’
from dbtest.rb:2
Exit code: 1


SYSTEM CONFIGURATION

Windows Vista
sqlite3.dll is in the same directory as the program - windows version
ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32]
gem sqlite3-ruby-1.2.0-mswin32

I’d appreciate any information available.
Thanks
Tom R.


#15

On Mar 25, 2009, at 9:13 AM, Heesob P. wrote:

db.close
from dbtest.rb:2
Move sqlite3.dll to somewhere in your PATH.

Refer to http://groups.google.com/group/comp.lang.ruby/browse_thread/thread/9d5c9ee6167dace4

Or switch to Amalgalite so you don’t have to worry about issues like
this. :slight_smile:

James Edward G. II


#16

Hi,
Can anybody give some examples or link for debugging a ruby script.

Thanks,
Anil kumar


#17

On Wed, Mar 25, 2009 at 11:55 AM, removed_email_address@domain.invalid
wrote:

Hi,
Can anybody give some examples or link for debugging a ruby script.

Thanks,
Anil kumar

http://www.datanoise.com/articles/2006/7/12/tutorial-on-ruby-debug


Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale


#18

On Mar 25, 2009, at 05:38 , Tom R. wrote:

Can anyone tell me how to correct the following error?

Please don’t thread hijack. It bothers those of us who use real mail
clients.


#19

So educate me –
Exactly what is thread hijacking? Never heard of it before
TR


#20

On Mar 25, 2009, at 08:55 , removed_email_address@domain.invalid
<removed_email_address@domain.invalid

wrote:

Hi,
Can anybody give some examples or link for debugging a ruby script.

Please don’t thread hijack. It bothers those of us who use real mail
clients.