我目前正在为我的游戏开发WebGL GUI,我真的想深入了解GPU图形技术,因为它比WebKit CSS渲染更加流畅。
是否可以制作一个滚动视图,其中内部网格遵循溢出规则,在超出父网格边界时隐藏?
也许着色器可以起作用,有什么建议吗?
谢谢!
是否可以制作一个滚动视图,其中内部网格遵循溢出规则,在超出父网格边界时隐藏?
也许着色器可以起作用,有什么建议吗?
谢谢!
gl.enable(gl.SCISSOR_TEST);
gl.scissor(x, y, width, height);
WebGLRenderer.setScissor
和 WebGLRenderer.setScissorTest
。 // Clearing the stencil buffer
gl.clearStencil(0);
gl.clear(gl.STENCIL_BUFFER_BIT);
// Tell webgl how to render into the stencil buffer
gl.stencilFunc(gl.ALWAYS, 1, 1);
gl.stencilOp(gl.REPLACE, gl.REPLACE, gl.REPLACE);
gl.colorMask(false, false, false, false);
gl.enable(gl.STENCIL_TEST);
// Renders the inner rectangle of scroll area
drawInnerRectangleOfScrollArea();
// Tell webgl how to clip rendering of the scroll area content
gl.stencilFunc(gl.EQUAL, 1, 1);
gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP);
gl.colorMask(true, true, true, true);
// Renders the inner contents of scroll area (ie the list of items, etc)
drawInnerContentsOfScrollArea();
// Reset the stenicl test state so to not affect any other rendering
gl.disable(gl.STENCIL_TEST);