Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to activate anti-aliasing via Emscripten

in webGL, it is possible to activate anti-aliasing on canvas-context intialization like

gl = canvas.getContext("experimental-webgl", { antialias: true });

My simple question is: how can this option be set via Emscripten C++ to asm.js compiler ? I do not ask about implementing my own antialiasing via custom shader code.

like image 479
user1610743 Avatar asked Oct 19 '25 12:10

user1610743


1 Answers

In SDL you can set antialias enabled through SDL_GL_MULTISAMPLEBUFFERS. Like this:

SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); // enable MULTISAMPLE
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 2); // can be 2, 4, 8 or 16
SDL_SetVideoMode(...)

This native code will enable antialias for gl context. Look at library_sdl.js:

// in makeSurface function
var webGLContextAttributes = {
    antialias: ((SDL.glAttributes[13 /*SDL_GL_MULTISAMPLEBUFFERS*/] != 0) && (SDL.glAttributes[14 /*SDL_GL_MULTISAMPLESAMPLES*/] > 1)),
    depth: (SDL.glAttributes[6 /*SDL_GL_DEPTH_SIZE*/] > 0),
    stencil: (SDL.glAttributes[7 /*SDL_GL_STENCIL_SIZE*/] > 0)
};
like image 191
caiiiycuk Avatar answered Oct 21 '25 00:10

caiiiycuk