From: "Weston Campbell said:
Actually, I want to know how the people who made these graphics
libraries and GUIs made them in the first place. How are these libraries
and toolkits working with graphics? How do they do it?
Ultimately such libraries tend to call window manager and graphics routines
on the native platform. These operating system calls are totally different on
Windows, Mac OS X, Linux, etc...
On Windows, one tends to use the CreateWindowEx() function to
create the window, which is documented here:
http://msdn2.microsoft.com/en-us/library/ms632680.aspx
There are numerous examples on the web for creating windows and
drawing graphics into them.
I need to know how to make my own custom libraries and toolkits, mainly
because I get so frustrated using something that I don't really
understand. Or, more likely, the library or tk doesn't have what I need
or implements something in a way I don't agree with.
If you want to do it yourself, you'll need to learn at least the following:
- How to write the code for your platform (usually in C or C++) to
create windows and draw graphics. (There will be plenty of examples
on the web for this.)
- How to wrap your C or C++ code so that it may be called from ruby.
Another possibility would be to start with an already-existing but simple
library which already has ruby bindings, and learn to use it. Then when
you find something it can't do, or something you would prefer to do
differently, study its code and tweak it to suit your needs, add features,
etc.
So, I'm basically asking how to make my own graphics libraries and GUI
toolkits, I want to know where my tech-organic graphics are being grown,
and how. Thanks for any enlightenment in advance.
Also - as Phlip mentioned: It depends on the _kind_ of graphics you want
to render. If you're interested in fast, efficient, high-framerate graphics
suitable for real-time video game rendering, you'll take one path. If you
are interested in slower high-resolution anti-aliased print-quality rendering,
you'll probably take a different path. If you want to render native-looking
buttons and widgets, and draw some simple static or animated icons next
to them, you might take a third path.
I would never try to discourage you from learning more about the native
window manager and graphics API calls on your platform. But at the
same time I would recommend at least *playing* with a few various
toolkits... Whether WxRuby, FXRuby, Tk, ... or even some more game-
oriented ones like Gosu or rubygame, if you want to cut right to the
graphics part.
http://wxruby.rubyforge.org/
http://www.fxruby.org/
http://code.google.com/p/gosu/
http://rubygame.sourceforge.net/
Hope this helps,
Bill