First of all, thanks for creating Gosu! I've spent my last couple weekends working on a ruby game using Gosu and Chipmunk. So far its been an excellent experience coming from Ruby on Rails.
I just have a quick question about the Window instance method "clip_to." Is it designed to override the drawing of images that are outside the box to speed up the game, or does it simply crop the game window?
Thanks, hopefully I'll have some photos/video of my game soon!
clip_to is definitely not a performance booster, I think it slows things down a bit on some drivers. It is meant to enable stuff like splitscreen, by drawing the first half of the screen as usual and then drawing the second half in a clip_to rect. I would try to use it as little as possible, OpenGL does a nice job clipping things that are outside of the window's coordinates already :)
cool, thanks. I just added some conditions to my drawing methods that should speed things up. I'm not using OpenGL in my project yet... perhaps I should be looking into that.
Oh, I didn't mean custom OpenGL! Gosu uses OpenGL for all its rendering too. So for performance, a brief check to only draw objects which are roughly close to the screen is the way to go, unless you want to introduce things like dividing the object list into several sectors etc. :)
I am working on a game which has a large number of image layers. Is it possible that I use the "clip_to" as a tool to cut the image in the middle, other than cropping? The reason I'm asking is because I have a huge black overlay image as a purpose to create darkness (yes, this game is supposed to be spooky) and I want to find a way to cut a hole to create an artificial "light source." I need to do this because my game has a lot of lit objects such as, torches, lanterns, fire, etc.
It's impossible with clip_to and probably with only Gosu. You can use one of extension libraries: TexPlay or Ashton. The second one is much faster, but it's a bit buggy.
If you just want a single view into the blackness, create an image that is white in the middle, fading out to full transparency. Draw that in gosu's multiply mode over your rendered scene and you are sorted.
If you need multiple moving light sources, you really need to use Ashton to compose an image made up of several of those white spots or use shaders ( the latter would be a lot more complicated, but not have much advantage).
Tex play would be fine for creating such a white blob dynamically, so would be fine for a single light source, but is to slow to do so every frame.
(Spooner) - I think I'll switch to Ashton right now. Could you send me a download link of Ashton? I need a RubyGosu App Wrapper version. If you could do that, I'll totally appreciate that.
The burden for providing app wrapper-compatible gems is on me :( Ashton will be included in the next app wrapper release, but I have no schedule for this right now.
No, because parts of Ashton are written in C. Spooner should know more about this :) Please email me at julian@raschke.de and I'll try to send you a .dylib back that you can put into the .app wrapper within the next days, but I can't promise anything.
I'm missing this as well. I recall having a mac wrapper with opengl and ashton running but I can't find it again. I don't mind an older version as long as I can find one that works.
I've added a note with your email address to my To Do list as well. I've already tried to send one dylib to mcdowellgames, but it didn't really work - I think I'll have to build a brand-new app wrapper.