-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added several SHOW_* options to enabled/disable
rendering of various things
- Loading branch information
Showing
5 changed files
with
98 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,6 +69,7 @@ typedef struct { | |
GLuint timer; | ||
GLuint extra1; | ||
GLuint extra2; | ||
GLuint extra3; | ||
} Attrib; | ||
|
||
static GLFWwindow *window; | ||
|
@@ -790,6 +791,7 @@ int render_chunks(Attrib *attrib, Player *player) { | |
glUniform1i(attrib->sampler, 0); | ||
glUniform1i(attrib->extra1, 2); | ||
glUniform1f(attrib->extra2, get_daylight()); | ||
glUniform1i(attrib->extra3, SHOW_SKY_DOME); | ||
glUniform1f(attrib->timer, time_of_day()); | ||
for (int i = 0; i < chunk_count; i++) { | ||
Chunk *chunk = chunks + i; | ||
|
@@ -1148,6 +1150,7 @@ int main(int argc, char **argv) { | |
block_attrib.sampler = glGetUniformLocation(program, "sampler"); | ||
block_attrib.extra1 = glGetUniformLocation(program, "sky_sampler"); | ||
block_attrib.extra2 = glGetUniformLocation(program, "daylight"); | ||
block_attrib.extra3 = glGetUniformLocation(program, "show_sky_dome"); | ||
block_attrib.camera = glGetUniformLocation(program, "camera"); | ||
block_attrib.timer = glGetUniformLocation(program, "timer"); | ||
|
||
|
@@ -1434,50 +1437,69 @@ int main(int argc, char **argv) { | |
// RENDER 3-D SCENE // | ||
glClear(GL_COLOR_BUFFER_BIT); | ||
glClear(GL_DEPTH_BUFFER_BIT); | ||
render_sky(&sky_attrib, player, sky_buffer); | ||
glClear(GL_DEPTH_BUFFER_BIT); | ||
if (SHOW_SKY_DOME) { | ||
render_sky(&sky_attrib, player, sky_buffer); | ||
glClear(GL_DEPTH_BUFFER_BIT); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
fogleman
Author
Owner
|
||
} | ||
int face_count = render_chunks(&block_attrib, player); | ||
render_players(&block_attrib, player); | ||
render_wireframe(&line_attrib, player); | ||
if (SHOW_WIREFRAME) { | ||
render_wireframe(&line_attrib, player); | ||
} | ||
|
||
// RENDER HUD // | ||
glClear(GL_DEPTH_BUFFER_BIT); | ||
render_crosshairs(&line_attrib); | ||
render_item(&block_attrib); | ||
if (SHOW_CROSSHAIRS) { | ||
render_crosshairs(&line_attrib); | ||
} | ||
if (SHOW_ITEM) { | ||
render_item(&block_attrib); | ||
} | ||
|
||
// RENDER TEXT // | ||
char text_buffer[1024]; | ||
float ts = 12 * scale; | ||
float tx = ts / 2; | ||
float ty = height - ts; | ||
int hour = time_of_day() * 24; | ||
char am_pm = hour < 12 ? 'a' : 'p'; | ||
hour = hour % 12; | ||
hour = hour ? hour : 12; | ||
snprintf( | ||
text_buffer, 1024, "(%d, %d) (%.2f, %.2f, %.2f) [%d, %d, %d] %d%cm %dfps", | ||
chunked(x), chunked(z), x, y, z, | ||
player_count, chunk_count, face_count * 2, hour, am_pm, fps.fps); | ||
render_text(&text_attrib, LEFT, tx, ty, ts, text_buffer); | ||
for (int i = 0; i < MAX_MESSAGES; i++) { | ||
int index = (message_index + i) % MAX_MESSAGES; | ||
if (strlen(messages[index])) { | ||
ty -= ts * 2; | ||
render_text(&text_attrib, LEFT, tx, ty, ts, messages[index]); | ||
if (SHOW_INFO_TEXT) { | ||
int hour = time_of_day() * 24; | ||
char am_pm = hour < 12 ? 'a' : 'p'; | ||
hour = hour % 12; | ||
hour = hour ? hour : 12; | ||
snprintf( | ||
text_buffer, 1024, | ||
"(%d, %d) (%.2f, %.2f, %.2f) [%d, %d, %d] %d%cm %dfps", | ||
chunked(x), chunked(z), x, y, z, | ||
player_count, chunk_count, | ||
face_count * 2, hour, am_pm, fps.fps); | ||
render_text(&text_attrib, LEFT, tx, ty, ts, text_buffer); | ||
ty -= ts * 2; | ||
} | ||
if (SHOW_CHAT_TEXT) { | ||
for (int i = 0; i < MAX_MESSAGES; i++) { | ||
int index = (message_index + i) % MAX_MESSAGES; | ||
if (strlen(messages[index])) { | ||
render_text(&text_attrib, LEFT, tx, ty, ts, | ||
messages[index]); | ||
ty -= ts * 2; | ||
} | ||
} | ||
} | ||
if (typing) { | ||
ty -= ts * 2; | ||
snprintf(text_buffer, 1024, "> %s", typing_buffer); | ||
render_text(&text_attrib, LEFT, tx, ty, ts, text_buffer); | ||
ty -= ts * 2; | ||
} | ||
if (player != me) { | ||
render_text(&text_attrib, CENTER, width / 2, ts, ts, player->name); | ||
} | ||
Player *other = player_crosshair(player); | ||
if (other) { | ||
render_text(&text_attrib, CENTER, | ||
width / 2, height / 2 - ts - 24, ts, other->name); | ||
if (SHOW_PLAYER_NAMES) { | ||
if (player != me) { | ||
render_text(&text_attrib, CENTER, width / 2, ts, ts, | ||
player->name); | ||
} | ||
Player *other = player_crosshair(player); | ||
if (other) { | ||
render_text(&text_attrib, CENTER, | ||
width / 2, height / 2 - ts - 24, ts, other->name); | ||
} | ||
} | ||
|
||
// RENDER PICTURE IN PICTURE // | ||
|
@@ -1507,13 +1529,17 @@ int main(int argc, char **argv) { | |
ortho = 0; | ||
fov = 65; | ||
|
||
render_sky(&sky_attrib, player, sky_buffer); | ||
glClear(GL_DEPTH_BUFFER_BIT); | ||
if (SHOW_SKY_DOME) { | ||
render_sky(&sky_attrib, player, sky_buffer); | ||
glClear(GL_DEPTH_BUFFER_BIT); | ||
} | ||
render_chunks(&block_attrib, player); | ||
render_players(&block_attrib, player); | ||
|
||
glClear(GL_DEPTH_BUFFER_BIT); | ||
render_text(&text_attrib, CENTER, pw / 2, ts, ts, player->name); | ||
if (SHOW_PLAYER_NAMES) { | ||
render_text(&text_attrib, CENTER, pw / 2, ts, ts, | ||
player->name); | ||
} | ||
} | ||
|
||
// swap buffers | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
out of curiosity, why only clear the depth buffer if you are rendering the sky? seems like you would want that either way.