How to render to a different resolution than window?
Hi, I want to render a 128x128 canvas into a window of a possibly different size, how can I do this?
I was having the same issue as yours, and I discovered what you have to do. I'm not 100% sure if this is what you're looking for, but there you go:
On your Window Builder variable, set it like this:
let wb = glutin::window::WindowBuilder::new().with_inner_size(glium::glutin::dpi::LogicalSize::new(width, height))
replace the width and height variables with your desired resolution, which is 128x128.
I don't know what exactly each word on this code really means, because I'm a beginner. But I hope it helped to achieve what you want.
You can render to any OpenGL texture using what are called framebuffer objects. In Glium, these are called "Surfaces".
Thus, you can simply create a 128x128 empty texture and then call texture.as_surface(), and render to it in the same way as the window.
However, I do recommend you specify a 16 bit format, since the default 8 bit textures only have enough resolution if you use an SRGB format. However, you can't use an SRGB texture as a surface.