显示地面的GL_QUADS

时间:2015-06-07 12:49:13

标签: c++ opengl

我想在游戏中使用gl_quads而不是gl_lines作为地面。 gl_lines最初位于gl_quads位置,显示网格表面。我想放gl_quads所以我可以添加颜色。这是对的吗?

//original code
void makeGrid(float size){
glColor4f(0.0f, 0.0f, 0.0f, 1.0f -radarVisionMagnitude);
glBegin(GL_LINES);
for(int i=-size;i<=size;++i) {
    glVertex3f(i,0,-size);
    glVertex3f(i,0,size);

    glVertex3f(size,0,i);
    glVertex3f(-size,0,i);
}
glEnd();
} 

//修改后的代码

void makeGrid(float size){
glBegin(GL_QUADS);
for(int i=-size;i<=size;++i) 
{
    glColor4f(0.0f,0.0f,0.0f,1.0f);
    glVertex3f(size,0,i);
    glVertex3f(-size,0,i);
    glVertex3f(i,0,-size);
    glVertex3f(i,0,size);
}
glEnd();
}

0 个答案:

没有答案