Hello, found out about SFML not long ago and is trying it out.
I love the ruby language and was happy I found a promising graphics library for it.
Using the prebuilt windows Ruby package, and I have a couple of questions.
First, How can I set up the projection matrix, or whatever it is called, to make the resolution 160x120, and still keep the window size as 640x480.
I tried something like this, but is having some problems.
# The graphics mode we want to use
mode = VideoMode.new( 640,480, 32)
# Open up a window
win = RenderWindow.new( mode, "My test", 0 )
# Set up a view
view = View.new( FloatRect.new(0,0,160,120) )
For some reason sprites isn't getting scaled.
I draw them using win.draw( my_sprite ) and its drawn at the top left, and in its original size.
It also looks a bit blury. (Most likely because of subpixel accuracy or mipmapping or something. I'm not so good at this hardware accelerated thingys
)
Would really appreciate some help.
If needed, here's what I have at the moment. It's not much but I have only been working on it for an hour or so.
require 'RubySFML'
include SFML
# The graphics mode we want to use
mode = VideoMode.new( 640,480, 32)
# Open up a window
win = RenderWindow.new( mode, "My test", 0 )
# Set up a view
view = View.new( FloatRect.new(0,0,160,120) )
# Misc settings
win.showMouseCursor( false )
win.useVerticalSync( true )
# Load images
tiles_gfx = Image.new("tiles.png")
tiles = Sprite.new( tiles_gfx )
# Main loop
done = false
while !done
while e = win.getEvent()
done = true if e.type == Event::Closed or
(e.type == Event::KeyReleased and e.code == Key::Escape)
end
# GFX
win.draw( tiles )
win.display()
sleep(0.01)
end
Thank you