OpenTk - 如何启用多重采样
OpenTk - How to Enable Multisampling
我正在尝试在 OpenTK 中实现多重采样,但是当我启用它时,两者之间没有区别
没有抗锯齿和多重采样。
No Antyaliasing
Multisampling Enabled
这是 OnRenderFrame 中用于多重采样的代码:
protected override void OnRenderFrame(FrameEventArgs e)
{
base.OnRenderFrame(e);
GL.Viewport(0, 0, Width, Height);
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
GL.Enable(EnableCap.DepthTest);
GL.Clear(ClearBufferMask.AccumBufferBit);
shaders[activeShader].EnableVertexAttribArrays();
int indiceat = 0;
GL.Enable(EnableCap.Multisample);
GL.Hint(HintTarget.MultisampleFilterHintNv,HintMode.Nicest);
foreach (Volume v in objects)
{
GL.ActiveTexture(TextureUnit.Texture0);
GL.BindTexture(TextureTarget.Texture2D, v.TextureID);
GL.UniformMatrix4(shaders[activeShader].GetUniform("modelview"), false, ref v.ModelViewProjectionMatrix);
GL.DrawElements(BeginMode.Triangles, v.IndiceCount, DrawElementsType.UnsignedInt, indiceat * sizeof(uint));
indiceat += v.IndiceCount;
}
}
您必须通过设置 GraphicsMode
. Set the GraphicsMode
when the GameWindow
构造来创建具有多重采样缓冲区的 window:
例如:
public class OpenTK_Window
: GameWindow
{
OpenTK_Window(int width, int height, string title)
: base(width, height, new GraphicsMode(32, 24, 8, 8), title,
{}
// [...]
}
在这种情况下,GraphicsMode
的构造函数的第 4 个参数是样本数。
我正在尝试在 OpenTK 中实现多重采样,但是当我启用它时,两者之间没有区别 没有抗锯齿和多重采样。
No Antyaliasing
Multisampling Enabled
这是 OnRenderFrame 中用于多重采样的代码:
protected override void OnRenderFrame(FrameEventArgs e)
{
base.OnRenderFrame(e);
GL.Viewport(0, 0, Width, Height);
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
GL.Enable(EnableCap.DepthTest);
GL.Clear(ClearBufferMask.AccumBufferBit);
shaders[activeShader].EnableVertexAttribArrays();
int indiceat = 0;
GL.Enable(EnableCap.Multisample);
GL.Hint(HintTarget.MultisampleFilterHintNv,HintMode.Nicest);
foreach (Volume v in objects)
{
GL.ActiveTexture(TextureUnit.Texture0);
GL.BindTexture(TextureTarget.Texture2D, v.TextureID);
GL.UniformMatrix4(shaders[activeShader].GetUniform("modelview"), false, ref v.ModelViewProjectionMatrix);
GL.DrawElements(BeginMode.Triangles, v.IndiceCount, DrawElementsType.UnsignedInt, indiceat * sizeof(uint));
indiceat += v.IndiceCount;
}
}
您必须通过设置 GraphicsMode
. Set the GraphicsMode
when the GameWindow
构造来创建具有多重采样缓冲区的 window:
例如:
public class OpenTK_Window
: GameWindow
{
OpenTK_Window(int width, int height, string title)
: base(width, height, new GraphicsMode(32, 24, 8, 8), title,
{}
// [...]
}
在这种情况下,GraphicsMode
的构造函数的第 4 个参数是样本数。