带有PyGame的PyOpenGL中的图形毛刺

问题描述 投票:1回答:1

我目前正在使用PyGame和PyOpenGL编写游戏,并且在使用顶点缓冲区时会出现图形故障。毛刺包括在每个模型之间不应绘制的线条。我发现在Ground()和GroundVBO()之间交替通常不会导致任何图形故障。有什么我想念的吗?

global vbo
vbo = 0
def Ground():
    glBegin(GL_LINES)
    for edge in ground_edges:
        for vertex in edge:
            glVertex3fv(ground_verticies[vertex])
    glEnd()
def GroundVBO():
    for edge in ground_edges:
        for vertex in edge:
            ground_noot = glVertex3fv(ground_verticies[vertex])
    vbo = glGenBuffers(1)
    glBindBuffer (GL_ARRAY_BUFFER, vbo)
    glBufferData (GL_ARRAY_BUFFER, len(ground_verticies)*4, ground_noot, GL_STATIC_DRAW)
    glVertexPointer (3, GL_FLOAT, 0, None)
    glDrawArrays(GL_LINES, 0, 300)

python opengl pygame pyopengl
1个回答
0
投票

如果要使用固定功能属性,则必须通过glEnableClientState启用客户端功能。在循环中用glEnableClientState指定顶点是多余的。在glVertex3fv / glBegin序列之外指定顶点会导致不确定的行为。glEnd的最后一个参数是顶点坐标数:

glDrawArrays
© www.soinside.com 2019 - 2024. All rights reserved.