1
\$\begingroup\$

I’m a beginner developing a 2D game in SDL2 using C with a visual style that uses crisp high resolution graphics (like geometry dash and Hollow Knight -- not pixel art). I want the game to scale correctly to fullscreen on arbitrary monitor resolutions, keeping graphics crisp and sharp

I’ve found little guidance online about the industry-standard approach for this. I’m unsure whether I should:

  1. Use a fixed-size display buffer (a 720p or 1080p texture set to the render target) and scale it to the monitor size (adding black bars to maintain a 16:9 aspect ratio). My concern is that scaling a fixed buffer will enlarge individual pixels on larger monitors, making graphics less sharp.

  2. Use manual math with a "render_scale" variable to scale and position each sprite individually in SDL_RenderCopy.

  3. Use some other method that I’m not aware of.

I’m looking for the standard approach in modern 2D game development, not necessarily limited to SDL2. Any insights, techniques, or example rendering pipelines would be greatly appreciated.

LudoProf
7532 silver badges15 bronze badges
asked Aug 28 at 22:03
New contributor
NewCoder is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
\$\endgroup\$
5
  • \$\begingroup\$ Have you looked into Signed Distance Fields (SDF)? They're a way to render vector-like graphics that maintain crisper, smoother edges over a wider range of scales and transformations than traditional raster sprites. They're popular for text rendering, but they work for other cases where you want a complex solid or stroked shape drawn in a plain colour or gradients without surface texture. I have a previous answer demoing the technique / showing the difference in rendered visuals here and you can find lots more by searching those keywords. \$\endgroup\$ Commented Aug 29 at 0:09
  • \$\begingroup\$ Thanks for the suggestion! SDFs seem like a great method for a potential future project. Sorry for the confusion in my original wording — I’ve clarified the question. I’m mainly asking about scaling games with crisp raster images/sprites to different sized monitors (like in Geometry Dash or Hollow Knight): is that usually done with a fixed sized back buffer that is then scaled, per-sprite scaling, or another common method? \$\endgroup\$ Commented Aug 31 at 1:52
  • \$\begingroup\$ No, if you want maximum crispness, you'll match the back buffer resolution to the actual output destination. We'll only use a smaller back buffer in two cases: reducing rendering load to trade fidelity for better performance/framerate, or emulating a retro-style chunky pixel aesthetic. A render scale factor works, though in many engines/frameworks this will be implicit in the notion of a "camera" and a camera transformation that maps from a consistent world coordinate system to rendering coords. I can't speak to how it's normally done with SDL specifically, though — hopefully an answer will. \$\endgroup\$ Commented 2 days ago
  • \$\begingroup\$ opengl has glViewport() which allows resizing the screen. \$\endgroup\$ Commented 2 days ago
  • \$\begingroup\$ @tp1 that's not exactly what that function does.glViewport sets the portion of the window that will be drawn into, so it can help with doing things like letterboxing, but it doesn't itself handle scaling the game to work on different screen/window resolutions while maintaining crispness. \$\endgroup\$ Commented yesterday

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.