Pyglet OpenGL绘图抗锯齿 [英] Pyglet OpenGL drawing anti-aliasing

查看:126
本文介绍了Pyglet OpenGL绘图抗锯齿的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找一种在OpenGL中消除锯齿的方法,但是它们似乎都不起作用...这是一些示例代码:

I've been looking around for a way to anti-alias lines in OpenGL, but none of them seem to work... here's some example code:

import pyglet                                                                      
from pyglet.gl import *                                                            

window = pyglet.window.Window(resizable=True)                                      

@window.event                                                                      
def on_draw():                                                                     
    window.clear()                                                                 
    pyglet.gl.glColor4f(1.0,0,0,1.0)                                               
    glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)                             
    glEnable (GL_BLEND)                                                            
    glEnable (GL_LINE_SMOOTH);                                                     
    glHint (GL_LINE_SMOOTH_HINT, GL_DONT_CARE)                                     
    glLineWidth (3)                                                                
    pyglet.graphics.draw(2, pyglet.gl.GL_LINES,                                    
        ('v2i', (10, 15, 300, 305))                                                
    )                                                                              

pyglet.app.run() 

有人可以看到我在做什么错吗?

Can anyone see what I am doing wrong?

推荐答案

允许Pyglet使用额外的示例缓冲区可能会有所帮助.将您的窗口行更改为此:

Allow Pyglet to use an extra sample buffer might help. Change your window line to this:

config = pyglet.gl.Config(sample_buffers=1, samples=4)
window = pyglet.window.Window(config=config, resizable=True) 

这对我有用.

这篇关于Pyglet OpenGL绘图抗锯齿的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆