Not logged inGosu Forums
Forum back to Help Search Register Login
Up Topic Gosu / Gosu Exchange / Gosu::Window#clip_to
- By asoules Date 2009-06-21 12:47
Hello All,

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!
- By jlnr (dev) Date 2009-06-21 12:53
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 :)
- By asoules Date 2009-06-21 12:59
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.
- By jlnr (dev) Date 2009-06-21 13:43
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. :)
- By jlnr (dev) Date 2009-06-22 09:37
Also asoules, congrats on having written the 1000th posting in this forum! Partytime!! ;)
- By asoules Date 2009-06-22 13:07
Wow, that's excellent. I spent all weekend on my game, should have some media to post soon!
- By Maverick Date 2009-06-22 13:33
We should party when it;s over 9,000.
- - By mcdowellgames Date 2014-06-03 05:05
Hi everyone!

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.

If you have any suggestions, please let me know.

Thanks for your time. :)
Parent - By lol_o2 Date 2014-06-03 09:06
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.
Parent - By jlnr (dev) Date 2014-06-03 21:01
See this old thread about how to do this without TexPlay or Ashton, but it will be very CPU intensive.
Parent - - By Spooner Date 2014-06-04 03:18
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.
Parent - - By mcdowellgames Date 2014-06-05 03:46

Thanks for the responses, guys! :-)

(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.

Again, thank you all!
Parent - - By jlnr (dev) Date 2014-06-05 07:14
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.
Parent - - By mcdowellgames Date 2014-06-05 13:37
So, is there an Ashton source I can download and manually add into the lib folder in my wrapper?

Parent - - By jlnr (dev) Date 2014-06-06 08:40
No, because parts of Ashton are written in C. Spooner should know more about this :) Please email me at 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.
Parent - - By arrow Date 2014-08-07 22:36
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.
Parent - By jlnr (dev) Date 2014-08-08 09:53
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.
Up Topic Gosu / Gosu Exchange / Gosu::Window#clip_to

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill