Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / Ruby Gosu / OpenGL hack for that sweet pixely retro-feeling
- By ippa Date 2009-09-12 19:37
So, Julian has been pondering adding non-blurry "zooming" to Gosu but hasn't come around to implement it just yet.. but he taught me the hack, and here it's for everyone to enjoy:

   @image =  Gosu::Image.new( ... )

    glBindTexture(GL_TEXTURE_2D, @image.gl_tex_info.tex_name)
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)

Then whe you scale @image (with draw_rot's factor_x, factor_y parameters) it wont get blurry. You can simulate an old retro look with this.. making each pixel in your sprite bigger.

You'll need the "ruby-opengl" gem for this to work. If you have problem compiling it on  windows you can DL a binarygem @ http://rubyforge.org/frs/?group_id=2103
- By deps Date 2009-09-12 19:50
Nice! :)

About the official implementation, how about
@image.retro!
or
@image.filter( Gosu::NEAREST ) # for both min and mag, use filter( Gosu::NEAREST, Gosu::SOMEOTHER ) to set them to different things.
or maybe both? ;)
- By r.kachowski Date 2009-09-13 16:09
hey cool! i've been trying to get some nearest neighbour pixely goodness for a while now!

i get edges of my images disappearing occasionally when using this however, but it'll do fine 'til the next release (which i hope comes soon :|)
Up Topic Gosu / Gosu Exchange / Ruby Gosu / OpenGL hack for that sweet pixely retro-feeling

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill