[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: ruby-opengl

jmg3000

7/7/2006 4:52:00 PM

On 7/7/06, anne001 <anne@wjh.harvard.edu> wrote:
> 1. Did you look at Yoshi's install?

Well, I had a look through extconf.rb if that's what you mean. :)

> I was not able to install 0.32g on
> tiger with the 1.8.4 ruby. I was able to install it with 1.8.2 ruby,
> moving the bundles to a directory 1.8.4 could see.

Ilmari Heikkinen alerted me to a fix for Mac OS X. I'll try to apply that soon.

> Unless people can install...
>
> 2. I can see why you would want to do away with GL and GLUT in front
> of the function, less typing,

Well, it's not really much less typing.

GL_FOO_BAR instead of GL::FOO_BAR
glFooBar instead of GL::FooBar

The real reason for the name changes is to make the calls look more
like they are in C.

> but for a beginner, they were very
> useful. I should still be able to put them in front, no?

Yeah, if you use the version I just provided, you can still do that.
But it may not stay that way. Though, if you prefix your calls,
they'll have to look like GL::glFooBar instead of GL::FooBar.

> a) I found the GL and GLUT in front of the opengl function very helpful
> just to remember what library the function came from
>
> b) Swapping GL for a new class, I was able to redirect the output which
> I found very useful:
> as an opengl beginner, I found it difficult to figure out what the
> opengl code was that I was outputing, given that I had recursive calls
> through trees... (for the limb of a person for example) replacing GL by
> a new class constant gave me a wonderful tool to redirect the code to a
> text file without changing any of the code.
> RealGL = GL
>
> class LoggingGL
> class << self
> def method_missing(meth, *args)
> puts "#{meth}(#{args.join(', ')})"
> RealGL.send(meth, *args)
> end
> def const_missing(const)
> RealGL.const_get(const)
> end
> end
> end
>
> GL = LoggingGL
>
> http://groups.google.com/group/comp.lang.ruby/browse_frm/thread/84888e5307628bf3/a1d1508397bff92c?q=realGL&rnum=1#a1d150...

I'll have to think about that. Thanks for the link.

> 3) "Your Ruby GL code should look a whole lot like your C code"
> I don't agree with that idea at all. I spent a lot of time working on
> robot.rb so it would take advantage of the
> OOP aspect of ruby, and as a consequence, my ruby openGL does not look
> much like the C code I think.
> If I am going to code in ruby the way I would in C I don't really see
> the point in using Ruby. In ruby, I am trying to code the ruby way.

Maybe I wasn't being clear there. You can still do all sorts of OO
tricks in your Ruby code. I meant to say, "Your Ruby calls to GL code
should look a whole lot like they do in C."

BTW, lots of folks write OO code in C, or so I hear. :)

> 4) Thank you for giving an example of the use of lambda.

You're welcome, but I must admit that I don't yet see why it just
doesn't use a top-level method instead of that lambda. I just copied
what I saw in the samples. :) I'll have to ask about it on the list
sometime.

> It took me a
> while to figure out how to use that feature - with help from this list
> -- as Yoshi's examples are straight C translation which use a fx.
>
> reshape = lambda do |w, h|
> glViewport( ... )
> glMatrixMode( GL_PROJECTION )
> # etc.
> glMatrixMode( GL_MODELVIEW )
> glLoadIdentity
> end
>
> glutReshapeFunc( reshape )
>
> 5) I would be happy to pass you a copy of the robot.rb version I worked
> on. I would love for someone who knows ruby

Well, I'm still a novice at Ruby (as of this afternoon). :)

> to improve on it so people
> have a real ruby way opengl example, instead of souped up C opengl
> example to start with.

Haven't yet had a chance to look at robot.rb. I'm only done with the
'a's so far! :) Thanks for the offer.

---John