OPENGL 怎么开启反走样多边形?

gamemagic 2010-08-21 12:38:26
点个线都设置好了,有反走样效果,透明混合也设置了,就是多边形总是不行,
画了个三角形,边缘锯齿很严重
我是按点和线的方法设置的多边形。问题在哪里?
...全文
420 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
引力场变动源 2010-08-21
  • 打赏
  • 举报
回复
中文的两个:
http://www.hellocpp.net/Articles/Article/122.aspx
http://www.zwqxin.com/archives/opengl/antialiasing-multi-sample-2.html
引力场变动源 2010-08-21
  • 打赏
  • 举报
回复
类似D3D中的那种全屏抗锯齿的用法参考这个:http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=46
引力场变动源 2010-08-21
  • 打赏
  • 举报
回复
void glHint(GLenum target,GLenum hint);

参数target说明控制什么行为:GL_POINT_SMOOTH_HINT、GL_LINE_SMOOTH_HINT和GL_POLYGON_SMOOTH_HINT分别指定点、线和多边形的采样质量;GL_FOG_HINT指出雾是按像素进行(GL_NICEST)还是按顶点进行(GL_FASTEST);GL_PERSPECTIVE_CORRECTION_HINT指定了颜色纹理插值的质量并可纠正由单纯线性插值所带来的一些视觉错误。参数hint可以是:GL_FASTEST(给出最有效的选择)、GL_NICEST(给出最高质量的选择)、GL_DONT_CARE(没有选择)。

虽然在OpenGL的颜色索引模式下也可以实现反走样,但仍建议在RGBA模式下进行。对图元进行反走样时也要先调用glEnable()函数启动反走样(其参数为GL_POINT、GL_LINE_SMOOTH或GL_POLYGON_SMOOTH)。如果是在RGBA模式下进行反走样,还必须与融合配合使用,通常使用GL_SRC_ALPHA和GL_ONE_MINUS_SRC_ALPHA分别作为源和目的因子。

openGL中使用反走样,需要在设置函数中进行设置,下面设置反走样的代码:

view plaincopy to clipboardprint?
// Initialize OpenGL's rendering modes
void initRendering()
{
glEnable ( GL_DEPTH_TEST );
// Uncomment out the first block of code below, and then the second block,
// to see how they affect line and point drawing.

// The following commands should cause points and line to be drawn larger
// than a single pixel width.
glPointSize(8);
glLineWidth(5);

// The following commands should induce OpenGL to create round points and
// antialias points and lines. (This is implementation dependent unfortunately).
//RGBA mode antialias need cooperate with blend function.
glEnable(GL_POINT_SMOOTH);
glEnable(GL_LINE_SMOOTH);
glHint(GL_POINT_SMOOTH_HINT, GL_NICEST); // Make round points, not square points
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); // Antialias the lines
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
// Initialize OpenGL's rendering modes
void initRendering()
{
glEnable ( GL_DEPTH_TEST );

// Uncomment out the first block of code below, and then the second block,
// to see how they affect line and point drawing.

// The following commands should cause points and line to be drawn larger
// than a single pixel width.
glPointSize(8);
glLineWidth(5);
// The following commands should induce OpenGL to create round points and
// antialias points and lines. (This is implementation dependent unfortunately).
//RGBA mode antialias need cooperate with blend function.
glEnable(GL_POINT_SMOOTH);
glEnable(GL_LINE_SMOOTH);
glHint(GL_POINT_SMOOTH_HINT, GL_NICEST); // Make round points, not square points
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); // Antialias the lines
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
写一个openGL程序画一个点,如果没有抗锯齿,则为方形的。如果我们启动抗锯齿设置,则点是一个圆点。
gamemagic 2010-08-21
  • 打赏
  • 举报
回复
等于说POLYGON SMOOTH的设置形同虚设?面反走样只能参考其他方法?
引力场变动源 2010-08-21
  • 打赏
  • 举报
回复
后面的那几个链接里面的方法试试,和第一个回复不一样的。
gamemagic 2010-08-21
  • 打赏
  • 举报
回复
你发的代码的都设置了,只有点和线有效

8,325

社区成员

发帖
与我相关
我的任务
社区描述
游戏开发相关内容讨论专区
社区管理员
  • 游戏开发
  • 呆呆敲代码的小Y
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧