Giter Site home page Giter Site logo

Comments (2)

floooh avatar floooh commented on June 12, 2024

Thanks for the suggestion, but the situation is "complicated" :D

Basically: I'm already doing the scaling-trick you describe:

/* upscale the original framebuffer 2x with nearest filtering */
sg_begin_pass(gfx.upscale_pass, &gfx_upscale_pass_action);
sg_apply_pipeline(gfx.upscale_pip);
sg_apply_bindings(&gfx.upscale_bind);
sg_draw(0, 4, 1);
sg_end_pass();
/* tint the clear color red or green if flash feedback is requested */
if (gfx.flash_error_count > 0) {
gfx.flash_error_count--;
gfx_draw_pass_action.colors[0].val[0] = 0.7f;
}
else if (gfx.flash_success_count > 0) {
gfx.flash_success_count--;
gfx_draw_pass_action.colors[0].val[1] = 0.7f;
}
else {
gfx_draw_pass_action.colors[0].val[0] = 0.05f;
gfx_draw_pass_action.colors[0].val[1] = 0.05f;
}
/* draw the final pass with linear filtering */
int w = (int) sapp_width();
int h = (int) sapp_height();
sg_begin_default_pass(&gfx_draw_pass_action, w, h);
apply_viewport(w, h);
sg_apply_pipeline(gfx.display_pip);
sg_apply_bindings(&gfx.display_bind);
sg_draw(0, 4, 1);
sg_apply_viewport(0, 0, w, h, true);
if (gfx.draw_extra_cb) {
gfx.draw_extra_cb();
}
sg_end_pass();
sg_commit();

The original frame buffer is first upscaled 2x with nearest-filtering into an offscreen rendering target, and then rendered to the WebGL canvas with linear filtering, which provides a bit of smoothing.

If the webpage is running on a HighDPI display, there will be another scaling step because the WebGL canvas isn't created as HighDPI and this "browser internal" scaling step is where the canvas CSS settings come in.

Without having the WebGL canvas pixelated, the text rendering in the debugging UI would look poorly (you can see this effect when running the demos on a Retina Mac in Safari, because Safari doesn't seem to support those pixelated CSS parameters). On Safari, the actual emulator framebuffer looks pretty much the same, but the text rendering in debugging UI looks blurry.

Sooo... it's not as simply as simply deactivation the CSS pixelation unfortunately, but I'll keep the topic in the back of my head :)

from chips-test.

nippur72 avatar nippur72 commented on June 12, 2024

I see there is no more pixelation with the latest commit. Very nice result, I love it!

from chips-test.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.