opengl中的抗鋸齒

2021-09-06 02:55:22 字數 1083 閱讀 9058

opengl的抗鋸齒

1.對直線和點主要用函式gl_enable(gl_line_smooth)或gl_enable(gl_point_smooth)

2.對rgba模式需要啟動混合功能,最常用的混合模式為gl_src_alpha和gl_one_minus_src_alpha(用gl_blend開啟混合模式)

以下摘自opengl程式設計指南的aargb.c**

/**  aargb.c

*  this program draws shows how to draw anti-aliased lines. it draws

*  two diagonal lines to form an x; when 'r' is typed in the window,

*  the lines are rotated in opposite directions.

*/#include

#include

#include

static float rotangle = 0.;

/*  initialize antialiasing for rgba mode, including alpha

*  blending, hint, and line width.  print out implementation

*  specific info on line width granularity and width.

*/void init(void)

/* draw 2 diagonal lines to form an x

*/void display(void)

void reshape(int w, int h)

void keyboard(unsigned char key, int x, int y)

}/*  main loop

*  open window with initial window size, title bar,

*  rgba display mode, and handle input events.

*/int main(int argc, char** argv)

openGL中的抗鋸齒實現

圖形繪製到螢幕時,光柵化影象通過離散的畫素點來表示,因此所繪製的圖元 比如直線 會產生鋸齒,這種鋸齒也稱作走樣。消除鋸齒的技術稱為反走樣,也叫做抗鋸齒,通過這種處理可在一定程度上消除鋸齒的影響,增強顯示效果。在opengl中,可通過函式glhint 來對影象質量和繪製速度之間的權衡作一些控制,其函式...

OpenGL學習十一 抗鋸齒

啟用抗鋸齒 還是以glenable來啟用抗鋸齒,可以根據不同圖形進行處理 1.gl point smooth 點 2.gl line smooth 線 3.gl polygon smooth 多邊形 抗鋸齒質量 效果越好,那麼計算機速度就越慢 glhint用於對點,線,多邊形的抗鋸齒程度進行設定 1...

OpenGL之抗鋸齒 以及 線寬的設定

原文 opengl之抗鋸齒 以及 線寬的設定 抗鋸齒 1.線的抗鋸齒 glenable gl line smooth 啟用 glhint gl line smooth,gl nicest 繪製 gldisable gl line smooth 關閉 2.點的抗鋸齒 glenable gl point...