Hi there,
I’m new to this forum. I create my games using Solar2D, but a disadvantage in HTML5 is that the images and text appear blurry. I’ve found some solutions online, but the main issue is that they all use a ‘2d’ context, while Solar2D uses WebGL (webgl or webgl2). I’m unsure how to adapt the following code:
function fix_dpi() {
//get DPI
let dpi = window.devicePixelRatio;
//get canvas
let canvas = document.getElementById('canvas');
//get context
let ctx = canvas.getContext('2d');
//get CSS height
//the + prefix casts it to an integer
//the slice method gets rid of "px"
let style_height = +getComputedStyle(canvas).getPropertyValue("height").slice(0, -2);
//get CSS width
let style_width = +getComputedStyle(canvas).getPropertyValue("width").slice(0, -2);
//scale the canvas
canvas.setAttribute('height', style_height * dpi);
canvas.setAttribute('width', style_width * dpi);
}