Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Using the same image with different resolutions?  (Read 2956 times)

0 Members and 1 Guest are viewing this topic.

santiaboy

  • Full Member
  • ***
  • Posts: 118
    • View Profile
Using the same image with different resolutions?
« on: January 31, 2013, 08:20:57 pm »
Hey guys, I've been developing a Breakout clone in 800x600. I wanted to try and make it so people could play on different resolutions.

The problem is that the textures I've been using for the 800x600 version get blurry when the reslolution changes to, for example, 1680x1050. So, I went and made bigger images. However, there is still a problem: when playing on 800x600 now the "HD" textures look blurry.

Is there a way to solve this? How is it normally solved in a game? Do they have the same imagen in a bunch of different resolutions?

images (1, 2 low def; 3, 4 "high def") http://imgur.com/a/OdWgE#0

I was kinda hoping not to use black bars, unless it really simplifies it.

mateandmetal

  • Full Member
  • ***
  • Posts: 171
  • The bird is the word
    • View Profile
    • my blog
Re: Using the same image with different resolutions?
« Reply #1 on: January 31, 2013, 08:32:44 pm »
Try using texture smoothing. You have to enable it on each texture.

myTexture.setSmooth (true);
 
- Mate (beverage) addict
- Heavy metal addict _lml
- SFML 2 addict
- My first (and free) game: BichingISH!

santiaboy

  • Full Member
  • ***
  • Posts: 118
    • View Profile
Re: Using the same image with different resolutions?
« Reply #2 on: January 31, 2013, 08:40:51 pm »
Try using texture smoothing. You have to enable it on each texture.

myTexture.setSmooth (true);
 

YESYEsyesys

thank you, it worked!

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
AW: Using the same image with different resolutions?
« Reply #3 on: January 31, 2013, 10:22:23 pm »
The easiest solution is the one you have now.
But it's of corse possible to have different resolutions, it just needs more work, but it could look way better at higher resolutions.
So you'd basically have to adapt the sf::View and make sure the input & movement behaves the same, but with more pixels. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Weeve

  • Jr. Member
  • **
  • Posts: 87
  • C++ Programmer (Intermediate), 3D Artist (Skilled)
    • View Profile
    • Email
Re: Using the same image with different resolutions?
« Reply #4 on: February 01, 2013, 05:58:43 pm »
here should be something simple to swap the images at different sizes of the screen, or you could find a way to tell SFML not to do any scaling blur, and to get the nearest pixel(does sfml have a function liek that?), or you could write your own, its easy when scaling down to write the function, your basically getting the float of your x/y index of the scaled pixel, dividing it by your scale, and multiplying it by your unscaled image, then rounding it down, and where that pixel land on the old image is your color


C++ code to swap images at different sizes of window:
// to initialize
// wrote this code in the reply box without testing, so you might have to debug some stupid stuff :-)
bool HighRes;
sf::Sprite ResSprite;
if ((sf::RenderWindow here).GetWidth() > 600){
   ResSprite = sf::Sprite(BigImage,...Stuff Here);
   HighRes = true;
}else{
   ResSprite = sf::Sprite(SmallImage,...Stuff Here);
   HighRes = false;
}

// to change, if the resolution is not what it should be
// remove the extra parameters if you don't need them, as they waste CPU
if (((sf::RenderWindow here).GetWidth() > 600) && (!HighRes)){
   ResSprite = sf::Sprite(BigImage,ResSprite.GetPosition(),ResSprite.GetScale(),ResSprite.GetRotation());
}else if (HighRes){
   ResSprite = sf::Sprite(SmallImage,ResSprite.GetPosition(),ResSprite.GetScale(),ResSprite.GetRotation());
}

 
Long live rapid project development! -- Kestrel3D Game-Engine nearing completion