void renderChunk(world::chunk* c) { int x, y, z; renderer::Init(2, 3); for (x = 0; x < 16; x++) { for (y = 0; y < 16; y++) { for (z = 0; z < 16; z++) { block curr = c->getblock(x, y, z); if (curr == blocks::AIR) continue; if (!BlockInfo(curr).isTranslucent()) renderblock(x, y, z, c); } } } renderer::Flush(c->vbuffer[0], c->vertexes[0]); renderer::Init(2, 3); for (x = 0; x < 16; x++) { for (y = 0; y < 16; y++) { for (z = 0; z < 16; z++) { block curr = c->getblock(x, y, z); if (curr == blocks::AIR) continue; if (BlockInfo(curr).isTranslucent() && BlockInfo(curr).isSolid()) renderblock(x, y, z, c); } } } renderer::Flush(c->vbuffer[1], c->vertexes[1]); renderer::Init(2, 3); for (x = 0; x < 16; x++) { for (y = 0; y < 16; y++) { for (z = 0; z < 16; z++) { block curr = c->getblock(x, y, z); if (curr == blocks::AIR) continue; if (!BlockInfo(curr).isSolid()) renderblock(x, y, z, c); } } } renderer::Flush(c->vbuffer[2], c->vertexes[2]); }
void chunk::buildlists(){ if (isEmptyChunk) return; //建立chunk显示列表 int x, y, z; for (x = -1; x != 2; x++) { for (y = -1; y != 2; y++) { for (z = -1; z != 2; z++) { if (x == 0 && y == 0 && z == 0) continue; if (chunkOutOfBound(cx + x, cy + y, cz + z)) continue; if (!chunkLoaded(cx + x, cy + y, cz + z)) return; } } } rebuiltChunks++; updatedChunks++; if (!isBuilt) { isBuilt = true; loadAnim = cy * 16 + 16; glGenBuffersARB(3, vbuffer); } renderer::Init(); glBindTexture(GL_TEXTURE_2D, BlockTextures); for (x = 0; x != 16; x++) { for (y = 0; y != 16; y++) { for (z = 0; z != 16; z++) { if (pblocks[x][y][z] == blocks::AIR) continue; if (!BlockInfo(pblocks[x][y][z]).isTranslucent()) renderblock(x, y, z, this); } } } renderer::Flush(vbuffer[0], vertexes[0]); renderer::Init(); glBindTexture(GL_TEXTURE_2D, BlockTextures); for (x = 0; x != 16; x++){ for (y = 0; y != 16; y++){ for (z = 0; z != 16; z++){ if (pblocks[x][y][z] == blocks::AIR) continue; if (BlockInfo(pblocks[x][y][z]).isTranslucent() && BlockInfo(pblocks[x][y][z]).isSolid()) renderblock(x, y, z, this); } } } renderer::Flush(vbuffer[1], vertexes[1]); renderer::Init(); glBindTexture(GL_TEXTURE_2D, BlockTextures); for (x = 0; x != 16; x++){ for (y = 0; y != 16; y++){ for (z = 0; z != 16; z++){ if (pblocks[x][y][z] == blocks::AIR) continue; if (!BlockInfo(pblocks[x][y][z]).isSolid()) renderblock(x, y, z, this); } } } renderer::Flush(vbuffer[2], vertexes[2]); updated = false; }
void chunk::buildRender(){ if (Empty) return; #ifdef NEWORLD_DEBUG_CONSOLE_OUTPUT if (pblocks == nullptr || pbrightness == nullptr){ DebugWarning("Empty pointer when building vertex buffers!"); return; } #endif //建立chunk显示列表 int x, y, z; for (x = -1; x <= 1; x++) { for (y = -1; y <= 1; y++) { for (z = -1; z <= 1; z++) { if (x == 0 && y == 0 && z == 0) continue; if (chunkOutOfBound(cx + x, cy + y, cz + z)) continue; if (!chunkLoaded(cx + x, cy + y, cz + z)) return; } } } rebuiltChunks++; updatedChunks++; if (renderBuilt == false){ renderBuilt = true; loadAnim = cy * 16.0f + 16.0f; } renderer::Init(); for (x = 0; x < 16; x++) { for (y = 0; y < 16; y++) { for (z = 0; z < 16; z++) { if (pblocks[x*256 + y*16 + z] == blocks::AIR) continue; if (!BlockInfo(pblocks[x*256 + y*16 + z]).isTranslucent()) renderblock(x, y, z, this); } } } renderer::Flush(vbuffer[0], vertexes[0]); renderer::Init(); for (x = 0; x < 16; x++){ for (y = 0; y < 16; y++){ for (z = 0; z < 16; z++){ if (pblocks[x*256 + y*16 + z] == blocks::AIR) continue; if (BlockInfo(pblocks[x*256 + y*16 + z]).isTranslucent() && BlockInfo(pblocks[x*256 + y*16 + z]).isSolid()) renderblock(x, y, z, this); } } } renderer::Flush(vbuffer[1], vertexes[1]); renderer::Init(); for (x = 0; x < 16; x++){ for (y = 0; y < 16; y++){ for (z = 0; z < 16; z++){ if (pblocks[x*256 + y*16 + z] == blocks::AIR) continue; if (!BlockInfo(pblocks[x*256 + y*16 + z]).isSolid()) renderblock(x, y, z, this); } } } renderer::Flush(vbuffer[2], vertexes[2]); updated = false; }