如标题所示,我希望每帧/更新只能调用一次 glBegin 和 glEnd ,因为我听说过并且正在经历,如果每次更新多次调用它,它会大大减慢。
这是我的渲染功能代码:
GL11.glTranslatef(0, 0, -10);
int x = 0;
while (x < World.BLOCKS_WIDTH - 1) {
int y = 0;
while (y < World.BLOCKS_HEIGHT - 1) {
if( x * World.BLOCK_SIZE <= Display.getHeight() || y * World.BLOCK_SIZE <=
Display.getWidth() || x * World.BLOCK_SIZE >= 0 ||
y * World.BLOCK_SIZE >= 0 ) {
blocks.b[data.blocks[x][y]].draw(x + Main.PosX, y + Main.PosY);
}
y++;
}
x++;
}
任何帮助表示赞赏。
这是我的块类:
GL11.glPushMatrix();
GL11.glTranslatef(Xa * World.BLOCK_SIZE, Ya * World.BLOCK_SIZE, 0);
//GL11.glRotatef(0, 0, 1, 0);
//GL11.glRotatef(0, 1, 0, 0);
Texture.bind();
GL11.glBegin(GL11.GL_QUADS);
GL11.glColor3f(1f, 1f, 1f);
//GL11.glNormal3f(0, 0, 1);
GL11.glTexCoord2f(0, 0);
GL11.glVertex2f(0, 0);
GL11.glTexCoord2f(0, 1);
GL11.glVertex2f(0, S);
GL11.glTexCoord2f(1, 1);
GL11.glVertex2f(S, S);
GL11.glTexCoord2f(1, 0);
GL11.glVertex2f(S, 0);
GL11.glEnd();
GL11.glPopMatrix();
}
PS。我可以理解一点纯OpenGL。