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

Author Topic: [SOLVED] How to properly draw everything and than scale up the screen?  (Read 4153 times)

0 Members and 1 Guest are viewing this topic.

LakySimi1

  • Newbie
  • *
  • Posts: 35
    • View Profile
Hi Everyone,

i'm doing my little retro-rpg, with a pixelated low resolution, of course i want it to render, with those big pixels, on higher modern resolution screen.

The method i am using is the following, i do refer to first part of code:
(click to show/hide)

The problem is that drawing lines does not match up with the goals, in fact the following code draws a line of 1 pixel thickness.. how should i proceed?

Line code:
(click to show/hide)

Results:
(click to show/hide)
« Last Edit: July 22, 2024, 06:27:26 pm by LakySimi1 »

Me-Myself-And-I

  • Jr. Member
  • **
  • Posts: 93
    • View Profile
Re: How to properly draw everything and than scale up the screen?
« Reply #1 on: July 22, 2024, 05:03:53 am »
You don't have an sf::view. If you want the pixels to be big ,simply create a View as explained here.
https://www.sfml-dev.org/tutorials/2.6/graphics-view.php
And set the viewport size to make the pixels look big instead of making the actual images big.

kojack

  • Sr. Member
  • ****
  • Posts: 343
  • C++/C# game dev teacher.
    • View Profile
Re: How to properly draw everything and than scale up the screen?
« Reply #2 on: July 22, 2024, 01:43:13 pm »
A view will scale the coordinate system, and sprites will render scaled (so may look pixelated), but line primitive rendering happens at the resolution of the buffer regardless of view.
(Technically the sprites are also at buffer resolution, if you rotate them the edges will be high res, it's just the texture that is pixelated)

To get a complete pixelated view, what you can do is have a RenderTexture with a low resolution. Render all of the gfx into the rendertexture. Then render the rendertexture onto window using a scaled up sprite.

LakySimi1

  • Newbie
  • *
  • Posts: 35
    • View Profile
SOLVED: How to properly draw everything and than scale up the screen?
« Reply #3 on: July 22, 2024, 06:26:51 pm »
Thank you very much! I've achieved the goal! :D (a bit of thanks also to ChatGPT :P)

Here an example of output, the rectangle rotated to confirm that it does not elaborate in high resolution, as my original code:
(click to show/hide)

Here the code used for the image above, directly implementable:
(click to show/hide)