Webgl 如何通过Emscripten激活抗锯齿
在webGL中,可以激活画布上的抗锯齿上下文初始化,如Webgl 如何通过Emscripten激活抗锯齿,webgl,sdl,antialiasing,emscripten,asm.js,Webgl,Sdl,Antialiasing,Emscripten,Asm.js,在webGL中,可以激活画布上的抗锯齿上下文初始化,如 gl = canvas.getContext("experimental-webgl", { antialias: true }); 我的简单问题是:如何将这个选项通过EnScript C++来设置为ASM.JS编译器?我不要求通过自定义着色器代码实现我自己的抗锯齿 在SDL中,您可以通过SDL\u GL\u多采样缓冲区设置启用的抗锯齿。像这样: SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS,
gl = canvas.getContext("experimental-webgl", { antialias: true });
我的简单问题是:如何将这个选项通过EnScript C++来设置为ASM.JS编译器?我不要求通过自定义着色器代码实现我自己的抗锯齿 在SDL中,您可以通过SDL\u GL\u多采样缓冲区设置启用的抗锯齿。像这样:
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(...)
此本机代码将为gl上下文启用antialias。请看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)
};
在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(...)
此本机代码将为gl上下文启用antialias。请看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)
};
如果使用SDL,如另一个答案中所述,您可以简单地调用以下命令:
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0 or 1);
如果使用GLUT,只需调用glutInitDisplayMode()
带/不带GLUT\u MULTISAMPLE
如果使用EGL,唯一的选择是强制将构建的javascript代码从
\u glutInitDisplayMode(146)更改代码>至显示模式(18)
aseglCreateContext()
仅在内部使用GLUT命令。如果使用SDL,如另一个答案中所述,您只需调用以下命令:
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0 or 1);
如果使用GLUT,只需调用glutInitDisplayMode()
带/不带GLUT\u MULTISAMPLE
如果使用EGL,唯一的选择是强制将构建的javascript代码从
\u glutInitDisplayMode(146)更改代码>至显示模式(18)
aseglCreateContext()
只是在内部使用GLUT命令。我在outputed.js文件中找到了以下代码,这提示在不编辑用于生成的html/js“shell文件”的情况下,可以通过某种方式设置变量:createContext:function(canvas、useWebGL、setInModule、webGLContextAttributes)返回ctx=canvas.getContext(webglId,contextAttributes);我在outputed.js文件中发现了以下代码,这提示在不编辑用于生成的html/js“shell文件”的情况下,可以通过某种方式设置变量:createContext:function(canvas,useWebGL,setInModule,webGLContextAttributes)return ctx=canvas.getContext(webglId,contextAttributes);