webgl - 如何通过 Emscripten 激活抗锯齿

标签 webgl sdl antialiasing emscripten asm.js

在 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/

相关文章:

audio - waveInXXX是否应用低通滤波器?

3d - 我可以在 Three.js 中让圆柱体发光,使其看起来像管灯吗?

javascript - 具有多个属性的绘制元素

javascript - 你如何在 glsl/webgl 中将一个 32 位的整数打包成 4 个、8 位的整数?

rust - SDL2如何安装和使用 "gfx"功能

c++ - 返回 0 数组的数组按位或异或

ios - UIImageView 中的反别名 UIImage

python - pygame.gfxdraw.aacircle 对于大圈子来说很有趣,还有其他选择吗?

javascript - 渲染到纹理和属性位置