在 webGL 中,可以在像
这样的 Canvas 上下文初始化上激活抗锯齿gl = canvas.getContext("experimental-webgl", { antialias: true });
我的简单问题是:如何通过 Emscripten C++ 将此选项设置为 asm.js 编译器?我不会询问通过自定义着色器代码实现我自己的抗锯齿。
最佳答案
在 SDL 中,您可以通过 SDL_GL_MULTISAMPLEBUFFERS 设置启用抗锯齿。像这样:
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(...)
此 native 代码将为 gl 上下文启用抗锯齿。查看 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)
};
关于webgl - 如何通过 Emscripten 激活抗锯齿,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22847399/