QuantumBadger / Speedy2D

Rust library for hardware accelerated drawing of 2D shapes, images, and text, with an easy to use API.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cheaply scaling drawing

superlou opened this issue · comments

I understand that the intent of this library is to do all drawing in physical pixels, so the user can handle application-specific logic (e.g. snapping to integer pixel positions for crisp lines) if needed. I think that paradigm makes the most sense for making "applications," e.g., a text editor with GUI controls and menus. I'm trying to use Speedy2D for something more like a game application, where in order to run fast enough, I'm willing to render at lower resolutions and let OpenGL scale it up cheaply, accepting the loss of quality and control.

Is it possible to use something like the OpenGL projection matrix for this without managing the custom GL context? Is there another approach that could be used?

(Following up on a bit of conversation from #83)

commented

maybe #75 might help? My clue is that you render to the context and then you manually upscale it to a window with some other libraries

I think that would work for upscaling, but if I ever want to downscale (e.g. in my app: design a display for 1920x1080 but scale the window smaller so it's easy to test on a monitor). I'm a little convinced I can mess with the uniforms (https://github.com/QuantumBadger/Speedy2D/blob/master/src/renderer2d.rs#L178) that are setting scale_x and scale_y or the viewport, but I have to learn how OpenGL's works.

I'm going to close this in favor of a new issue based on the discussion from #88.