本文介绍了allegro中的抗锯齿5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使allegro 5在绘图时使用抗锯齿?我需要斜线看起来光滑。
解决方案
为图元启用抗锯齿:
/ p> //创建显示之前:
al_set_new_display_option(ALLEGRO_SAMPLE_BUFFERS,1,ALLEGRO_SUGGEST);
al_set_new_display_option(ALLEGRO_SAMPLES,8,ALLEGRO_SUGGEST);
display = al_create_display(640,480);请注意,消除锯齿功能只适用于直接绘制到后台缓冲区的基元。
在OpenGL上,您的卡片必须支持扩展。
要检查是否已启用(使用ALLEGRO_SUGGEST):
if(al_get_display_option(display,ALLEGRO_SAMPLE_BUFFERS)){
printf(With multisampling,level%i \\\
,
al_get_display_option(display,ALLEGRO_SAMPLES));
}
else {
printf(Without multisampling.\\\
);
}
How do I make allegro 5 use anti-aliasing when drawing? I need diagonal lines to appear smooth. Currently, they are only lines of shaded pixels, and the edges look hard.
解决方案 To enable anti aliasing for the primitives:
// before creating the display:
al_set_new_display_option(ALLEGRO_SAMPLE_BUFFERS, 1, ALLEGRO_SUGGEST);
al_set_new_display_option(ALLEGRO_SAMPLES, 8, ALLEGRO_SUGGEST);
display = al_create_display(640, 480);
Note that anti-aliasing will only work for primitives drawn directly to the back buffer. It will not work anywhere else.
On OpenGL, your card must support the ARB_multisample extension.
To check if it was enabled (when using ALLEGRO_SUGGEST):
if (al_get_display_option(display, ALLEGRO_SAMPLE_BUFFERS)) {
printf("With multisampling, level %i\n",
al_get_display_option(display, ALLEGRO_SAMPLES));
}
else {
printf("Without multisampling.\n");
}
这篇关于allegro中的抗锯齿5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!