抗锯齿

来源:互联网 发布:java 调用jenkins api 编辑:程序博客网 时间:2024/05/01 14:07

启用抗锯齿

还是以glEnable来启用抗锯齿,可以根据不同图形进行处理

  1. GL_POINT_SMOOTH 点
  2. GL_LINE_SMOOTH 线
  3. GL_POLYGON_SMOOTH 多边形

抗锯齿质量

当然效果越好,那么计算机速度就越慢,即有一个参数设置

glHint用于对点,线,多边形的抗锯齿程度进行设置

  1. GL_DONT_CARE 放弃,应该是系统默认吧
  2. GL_FASTEST 速度优先
  3. GL_NICEST 图形显示质量优先


cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. //glEnable(GL_POINT_SMOOTH);                    //点
  2. //glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);  
  3.   
  4. //glEnable(GL_LINE_SMOOTH);                               //线
  5. //glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);  
  6.   
  7. //glEnable(GL_POLYGON_SMOOTH);                  //多边形
  8. //glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);  



【实例】

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

[cpp] view plain copy
  1. // Initialize OpenGL's rendering modes  
  2. void initRendering()  
  3. {  
  4.   
  5.  glEnable ( GL_DEPTH_TEST );  
  6.   
  7.  // Uncomment out the first block of code below, and then the second block,  
  8.  //  to see how they affect line and point drawing.  
  9.   
  10.  // The following commands should cause points and line to be drawn larger  
  11.  // than a single pixel width.  
  12.  glPointSize(8);  
  13.  glLineWidth(5);  
  14.   
  15.    
  16.   
  17.  // The following commands should induce OpenGL to create round points and   
  18.  // antialias points and lines.  (This is implementation dependent unfortunately).  
  19.  //RGBA mode antialias need cooperate with blend function.  
  20.  glEnable(GL_POINT_SMOOTH);  
  21.  glEnable(GL_LINE_SMOOTH);  
  22.  glHint(GL_POINT_SMOOTH_HINT, GL_NICEST); // Make round points, not square points  
  23.  glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);  // Antialias the lines  
  24.  glEnable(GL_BLEND);  
  25.  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);  
  26.   
  27.   
  28. }  

 

写一个openGL程序画一个点,如果没有抗锯齿,则为方形的。如果我们启动抗锯齿设置,则点是一个圆点。

0 0
原创粉丝点击