[Q] Ruby for graphics

I just learned of Ruby, and was wondering if its a good lang for
creating graphics and 3D apps?

Sorry if this may have been covered already…

Depends on what you consider “good”.

To me, “good” is more “is it easy to read and write”, rather than
“does it run blindingly fast”. Others have different metrics
depending on what they’re doing.

···

— Your Name Here jim@fivek.com wrote:

I just learned of Ruby, and was wondering if its a good lang

for
creating graphics and 3D apps?

Sorry if this may have been covered already…


Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more

“Michael Campbell” michael_s_campbell@yahoo.com wrote in message
news:20030408151706.32038.qmail@web12401.mail.yahoo.com

···

— Your Name Here jim@fivek.com wrote:

I just learned of Ruby, and was wondering if its a good lang

for
creating graphics and 3D apps?

Sorry if this may have been covered already…

Depends on what you consider “good”.

To me, “good” is more “is it easy to read and write”, rather than
“does it run blindingly fast”. Others have different metrics
depending on what they’re doing.

Well, in this case good means fast and efficient…

If you want easy to read and write at the expense of speed, why not use
JAVA, what advantage does Ruby have over JAVA ?

Depends on what you consider “good”.

To me, “good” is more “is it easy to read and write”, rather than
“does it run blindingly fast”. Others have different metrics
depending on what they’re doing.

Well, in this case good means fast and efficient…

If you want easy to read and write at the expense of speed, why not use
JAVA, what advantage does Ruby have over JAVA ?

:slight_smile: Is this a troll?

That’s a long, involved question. Just do some more
research into Ruby.

I’d say that if there were a “dynamic OOP” scale
from 1 to 10, and C++ were a 3, then Java would
be a 5 and Ruby an 8.

If you want speed, use C or C++. Or write the
sensitive code in C/C++ and call it from Ruby.

Disclaimer: The above is only my opinion. Some
people don’t like Ruby.

Hal

···

----- Original Message -----
From: “Your Name Here” jim@fivek.com
Newsgroups: comp.lang.ruby
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Tuesday, April 08, 2003 10:34 AM
Subject: Re: [Q] Ruby for graphics

To me, “good” is more “is it easy to read and write”, rather than
“does it run blindingly fast”. Others have different metrics
depending on what they’re doing.

Well, in this case good means fast and efficient…

If you want easy to read and write at the expense of speed, why not use
JAVA, what advantage does Ruby have over JAVA ?

Think of Ruby as even farther up the power continuum: About maybe
10x “easier to read and write” than Java, but also generally slower
at run-time. :slight_smile:

In addition to all my other uses for Ruby, I do actually use Ruby to
prototype graphics algorithms: precisely because Ruby is such a high-
level, powerful language. But I do expect to re-code the finished
algorithms in C++ for speed.

Hope this helps,

Bill

···

From: “Your Name Here” jim@fivek.com

Well, in this case good means fast and efficient…

Ruby’s strength, like most any scripting language, is not necessarily
speed.

If you want easy to read and write at the expense of speed, why not
use
JAVA, what advantage does Ruby have over JAVA ?

MUCH easier to write (and read later).

···

Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more

“Bill Kelly” billk@cts.com wrote in message
news:003401c2fde8$879d7b00$6404a8c0@musicbox…

From: “Your Name Here” jim@fivek.com

To me, “good” is more “is it easy to read and write”, rather than
“does it run blindingly fast”. Others have different metrics
depending on what they’re doing.

Well, in this case good means fast and efficient…

If you want easy to read and write at the expense of speed, why not use
JAVA, what advantage does Ruby have over JAVA ?

Think of Ruby as even farther up the power continuum: About maybe
10x “easier to read and write” than Java, but also generally slower
at run-time. :slight_smile:

In addition to all my other uses for Ruby, I do actually use Ruby to
prototype graphics algorithms: precisely because Ruby is such a high-
level, powerful language. But I do expect to re-code the finished
algorithms in C++ for speed.

Hope this helps,

Bill

Yep, that answers my question…

Bill Kelly wrote:

In addition to all my other uses for Ruby, I do actually use Ruby to
prototype graphics algorithms: precisely because Ruby is such a high-
level, powerful language. But I do expect to re-code the finished
algorithms in C++ for speed.

After measuring the bottlenecks and only corrected those as necessary?
Or a complete re-write?

···


Bil Kleb, NASA, Hampton, Virginia, USA

Hi,

Bill Kelly wrote:

In addition to all my other uses for Ruby, I do actually use Ruby to
prototype graphics algorithms: precisely because Ruby is such a high-
level, powerful language. But I do expect to re-code the finished
algorithms in C++ for speed.

After measuring the bottlenecks and only corrected those as necessary?
Or a complete re-write?

I think I probably spoke a bit over-generally, based on my project-
of-the-moment. I’m a huge fan of measuring before optimizing, and
I’ve been (indeed) doing some rough C++ timing estimates while coding
the Ruby sample implementation of what are intended to be some very
real-time pixel filtering operations.

In Ruby it was convenient for me to develop the filter in an object-
oriented manner… but now that I understand how the filter works,
it boils down to a few memory fetches, some arithmetic, and a few
memory stores per pixel. I could optimize the Ruby version a bit,
of course - now that I know how to actually code the thing. . .
My current Ruby implementation gets less than one frame per second on
a 120x144 buffer, whereas my rough C++ timing tests indicate I should
achieve a few thousand frames a second on that sized buffer in that
language. . . . But my Ruby implementation was never intended
to be fast… I used Ruby to explore an idea and learn how to
achieve the filtering effect I desired…

So in essence I guess I’ve selected about the most inappropriate
task for which to use Ruby from a speed perspective - but I knew that
going into it… The whole filter is the bottleneck. :slight_smile: But I
still found Ruby very useful in developing it.

Regards,

Bill

···

From: “Bil Kleb” William.L.Kleb@NASA.Gov

hm, just some stupid question. new to ruby. what is to use for graphic
manipulation??
niels

···

----- Original Message -----
From: “Bil Kleb” William.L.Kleb@NASA.Gov
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Wednesday, April 09, 2003 4:10 AM
Subject: Re: [Q] Ruby for graphics

Bill Kelly wrote:

In addition to all my other uses for Ruby, I do actually use Ruby to
prototype graphics algorithms: precisely because Ruby is such a high-
level, powerful language. But I do expect to re-code the finished
algorithms in C++ for speed.

After measuring the bottlenecks and only corrected those as necessary?
Or a complete re-write?


Bil Kleb, NASA, Hampton, Virginia, USA

In Ruby it was convenient for me to develop the filter in an object-
oriented manner… but now that I understand how the filter works,
it boils down to a few memory fetches, some arithmetic, and a few
memory stores per pixel. I could optimize the Ruby version a bit,
of course - now that I know how to actually code the thing. . . My
current Ruby implementation gets less than one frame per second on
a 120x144 buffer, whereas my rough C++ timing tests indicate I should
achieve a few thousand frames a second on that sized buffer in that
language. . . . But my Ruby implementation was never intended
to be fast… I used Ruby to explore an idea and learn how to
achieve the filtering effect I desired…

I would like to do some graphics programming on my own, but I don’t know
which API to use…
May I ask you what software you use and on which OS?

thank you!
Dominik

Hi Dominik and Neils,

I would like to do some graphics programming on my own, but I don’t know
which API to use…
May I ask you what software you use and on which OS?

hm, just some stupid question. new to ruby. what is to use for graphic
manipulation??

I’m personally using RUDL (Ruby bindings to libsdl:
[ http://froukepc.dhs.org/rudl/ ]), and also a little OpenGL.

Currently the RUDL FAQ lists some problems running under
non-windows operating systems. I’m using Ruby 1.6.6 on win2k.

However I believe the OpenGL bindings definitely work on Linux. If
you’re on Windows, and using the Pragmatic Programmers installer for
Ruby, OpenGL support should already be installed for you. Otherwise,
see the RAA: [ http://raa.ruby-lang.org/list.rhtml?name=opengl ]

RUDL provides support for loading images as textures or sprites,
drawing them to the screen, full-screen mode or windowed, some
basic graphics primitives, and I think audio and joystick support
(but I haven’t tried the latter two.)

Here’s one of the simpler examples that comes with RUDL, for
loading a sprite and bouncing it around on the screen:

···

From: “Dominik Werder” dwerder@gmx.net
From: “niels wolf” k-zimir@gmx.net

require 'RUDL'; include RUDL

display = DisplaySurface.new([640, 480])
ball = Surface.load_new('media/bounce.bmp')
lastrect = [0,0,0,0]

loop {
  break if EventQueue.poll.type == QuitEvent
  pos = [(Timer.ticks%1024-512).abs, ((Timer.ticks+200)%704-352).abs]
  rect = display.blit(ball, pos)
  display.update([rect.union(lastrect)])
  display.fill([0, 0, 0], lastrect = rect)
}

As for image manipulation libraries, I haven’t used any with
Ruby yet. Last I looked, there appeared to be some available
for Linux (imlib2 bindings, ImageMagick bindings, etc.) but I
didn’t see much for Windows. That may have changed… try
looking on RAA:
[ http://raa.ruby-lang.org/cat.rhtml?category_major=Library;category_minor=Graphics ]

Hope this helps,

Bill

Hope this helps,

Yes, thank you!
Will look into it :slight_smile:

bye!
Dominik

thanx.
yep i had a look and opengl was what i found also. i’m sitting on winxp. but
want to write for the server, so linux/unix. so i was looking for something
“native”, so i can test and develop on my machine and set it on the server
without bugs or changings.
niels

···

----- Original Message -----
From: “Bill Kelly” billk@cts.com
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Wednesday, April 09, 2003 7:20 PM
Subject: Re: [Q] Ruby for graphics

Hi Dominik and Neils,

From: “Dominik Werder” dwerder@gmx.net

I would like to do some graphics programming on my own, but I don’t know
which API to use…
May I ask you what software you use and on which OS?

From: “niels wolf” k-zimir@gmx.net

hm, just some stupid question. new to ruby. what is to use for graphic
manipulation??

I’m personally using RUDL (Ruby bindings to libsdl:
[ http://froukepc.dhs.org/rudl/ ]), and also a little OpenGL.

Currently the RUDL FAQ lists some problems running under
non-windows operating systems. I’m using Ruby 1.6.6 on win2k.

However I believe the OpenGL bindings definitely work on Linux. If
you’re on Windows, and using the Pragmatic Programmers installer for
Ruby, OpenGL support should already be installed for you. Otherwise,
see the RAA: [ http://raa.ruby-lang.org/list.rhtml?name=opengl ]

RUDL provides support for loading images as textures or sprites,
drawing them to the screen, full-screen mode or windowed, some
basic graphics primitives, and I think audio and joystick support
(but I haven’t tried the latter two.)

Here’s one of the simpler examples that comes with RUDL, for
loading a sprite and bouncing it around on the screen:

require 'RUDL'; include RUDL

display = DisplaySurface.new([640, 480])
ball = Surface.load_new('media/bounce.bmp')
lastrect = [0,0,0,0]

loop {
  break if EventQueue.poll.type == QuitEvent
  pos = [(Timer.ticks%1024-512).abs, ((Timer.ticks+200)%704-352).abs]
  rect = display.blit(ball, pos)
  display.update([rect.union(lastrect)])
  display.fill([0, 0, 0], lastrect = rect)
}

As for image manipulation libraries, I haven’t used any with
Ruby yet. Last I looked, there appeared to be some available
for Linux (imlib2 bindings, ImageMagick bindings, etc.) but I
didn’t see much for Windows. That may have changed… try
looking on RAA:
[
http://raa.ruby-lang.org/cat.rhtml?category_major=Library;category_minor=Gra
phics ]

Hope this helps,

Bill

hmm. has anyboy experience with this opengl thing for ruby??
i kind of didn’t get it…eh.
niels

···

----- Original Message -----
From: “Dominik Werder” dwerder@gmx.net
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Wednesday, April 09, 2003 7:33 PM
Subject: Re: [Q] Ruby for graphics

Hope this helps,

Yes, thank you!
Will look into it :slight_smile:

bye!
Dominik

Niels,

“niels wolf” k-zimir@gmx.net writes:

hmm. has anyboy experience with this opengl thing for ruby??
i kind of didn’t get it…eh.

Sure. Grab Ruboids from the RAA. It’s an OpenGL Boids (bird flocking)
implementation.

The bad news is, it requires Qt. The good news is, you can steal all of the
OpenGL code.

Jim

···


Jim Menard, jimm@io.com, http://www.io.com/~jimm/
“Sanity is a one-trick pony: rationality is all you get. With insanity,
the sky’s the limit!” – The Tick

Hi,

hmm. has anyboy experience with this opengl thing for ruby??
i kind of didn’t get it…eh.

If you’re on Windows and using the Pragmatic Programmers’
installer, look in your ruby/samples/opengl directory…

There should be almost 50 OpenGL examples there, all ported
to Ruby!

Also, if you install RUDL, several of NeHe’s OpenGL tutorials
[ http://nehe.gamedev.net/ ] have been ported to OpenGL/RUDL
and will be installed when you install RUDL…

(Even if you don’t install RUDL, I highly recommend NeHe’s
tutorials if you want to learn about OpenGL… See for
instance: http://nehe.gamedev.net/lesson.asp?index=01 )

Hope this helps,

Bill

···

From: “niels wolf” k-zimir@gmx.net