Merge 748fccdde5
into 7788b5f6be
This commit is contained in:
commit
663bc7e83c
@ -39,6 +39,9 @@ bool escapeDown = false;
|
|||||||
float windowX = 1920;
|
float windowX = 1920;
|
||||||
float windowY = 1080;
|
float windowY = 1080;
|
||||||
|
|
||||||
|
GLuint framebufferTexture;
|
||||||
|
GLuint depthTexture;
|
||||||
|
|
||||||
Camera camera;
|
Camera camera;
|
||||||
|
|
||||||
// Window options
|
// Window options
|
||||||
@ -47,13 +50,13 @@ Camera camera;
|
|||||||
float rectangleVertices[] =
|
float rectangleVertices[] =
|
||||||
{
|
{
|
||||||
// Coords // TexCoords
|
// Coords // TexCoords
|
||||||
1.0f, -1.0f, 1.0f, 0.0f,
|
|
||||||
-1.0f, -1.0f, 0.0f, 0.0f,
|
-1.0f, -1.0f, 0.0f, 0.0f,
|
||||||
-1.0f, 1.0f, 0.0f, 1.0f,
|
-1.0f, 1.0f, 0.0f, 1.0f,
|
||||||
|
|
||||||
1.0f, 1.0f, 1.0f, 1.0f,
|
|
||||||
1.0f, -1.0f, 1.0f, 0.0f,
|
1.0f, -1.0f, 1.0f, 0.0f,
|
||||||
-1.0f, 1.0f, 0.0f, 1.0f
|
|
||||||
|
1.0f, -1.0f, 1.0f, 0.0f,
|
||||||
|
-1.0f, 1.0f, 0.0f, 1.0f,
|
||||||
|
1.0f, 1.0f, 1.0f, 1.0f,
|
||||||
};
|
};
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
@ -120,7 +123,6 @@ int main()
|
|||||||
glGenFramebuffers(1, &FBO);
|
glGenFramebuffers(1, &FBO);
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, FBO);
|
glBindFramebuffer(GL_FRAMEBUFFER, FBO);
|
||||||
|
|
||||||
unsigned int framebufferTexture;
|
|
||||||
glGenTextures(1, &framebufferTexture);
|
glGenTextures(1, &framebufferTexture);
|
||||||
glBindTexture(GL_TEXTURE_2D, framebufferTexture);
|
glBindTexture(GL_TEXTURE_2D, framebufferTexture);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, windowX, windowY, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, windowX, windowY, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
|
||||||
@ -130,7 +132,6 @@ int main()
|
|||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, framebufferTexture, 0);
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, framebufferTexture, 0);
|
||||||
|
|
||||||
unsigned int depthTexture;
|
|
||||||
glGenTextures(1, &depthTexture);
|
glGenTextures(1, &depthTexture);
|
||||||
glBindTexture(GL_TEXTURE_2D, depthTexture);
|
glBindTexture(GL_TEXTURE_2D, depthTexture);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, windowX, windowY, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, windowX, windowY, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL);
|
||||||
@ -220,7 +221,7 @@ int main()
|
|||||||
highestFps = fps;
|
highestFps = fps;
|
||||||
fpsCount++;
|
fpsCount++;
|
||||||
std::chrono::steady_clock::time_point currentTimePoint = std::chrono::steady_clock::now();
|
std::chrono::steady_clock::time_point currentTimePoint = std::chrono::steady_clock::now();
|
||||||
if (std::chrono::duration_cast<std::chrono::milliseconds>(currentTimePoint - fpsStartTime).count() > 1000)
|
if (std::chrono::duration_cast<std::chrono::seconds>(currentTimePoint - fpsStartTime).count() >= 1)
|
||||||
{
|
{
|
||||||
avgFps = fpsCount;
|
avgFps = fpsCount;
|
||||||
lowestFps = -1;
|
lowestFps = -1;
|
||||||
@ -236,6 +237,8 @@ int main()
|
|||||||
processInput(window);
|
processInput(window);
|
||||||
|
|
||||||
// Rendering
|
// Rendering
|
||||||
|
glClearColor(0.6f, 0.8f, 1.0f, 1.0f);
|
||||||
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, FBO);
|
glBindFramebuffer(GL_FRAMEBUFFER, FBO);
|
||||||
|
|
||||||
@ -308,18 +311,23 @@ int main()
|
|||||||
}
|
}
|
||||||
|
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
|
glClearColor(0, 0, 0, 1);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
glBindVertexArray(rectVAO);
|
glBindVertexArray(rectVAO);
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, framebufferTexture);
|
glBindTexture(GL_TEXTURE_2D, framebufferTexture);
|
||||||
glActiveTexture(GL_TEXTURE1);
|
glActiveTexture(GL_TEXTURE1);
|
||||||
glBindTexture(GL_TEXTURE_2D, depthTexture);
|
glBindTexture(GL_TEXTURE_2D, depthTexture);
|
||||||
|
// disabled so that the screen renders
|
||||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||||
|
|
||||||
// Draw ImGui UI
|
// Draw ImGui UI
|
||||||
ImGui::Begin("Test");
|
ImGui::Begin("Test");
|
||||||
ImGui::Text("FPS: %f (Avg: %f, Min: %f, Max: %f)", fps, avgFps, lowestFps, highestFps);
|
ImGui::Text("FPS: %f (Avg: %f, Min: %f, Max: %f)", fps, avgFps, lowestFps, highestFps);
|
||||||
ImGui::Text("MS: %f", deltaTime * 100.0f);
|
ImGui::Text("MS: %f", deltaTime * 1000.f);
|
||||||
|
ImGui::Text("Facing: %.1f/%.1f", camera.Pitch, camera.Yaw);
|
||||||
|
ImGui::Text("Pos: %.2f, %.2f, %.2f", camera.Position.x, camera.Position.y, camera.Position.z);
|
||||||
ImGui::Text("Chunks: %d (%d rendered)", Planet::planet->numChunks, Planet::planet->numChunksRendered);
|
ImGui::Text("Chunks: %d (%d rendered)", Planet::planet->numChunks, Planet::planet->numChunksRendered);
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
|
||||||
@ -340,11 +348,18 @@ int main()
|
|||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void framebufferSizeCallback(GLFWwindow* window, int width, int height)
|
void framebufferSizeCallback(GLFWwindow* window, int width, int height)
|
||||||
{
|
{
|
||||||
windowX = width;
|
windowX = width;
|
||||||
windowY = height;
|
windowY = height;
|
||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
|
// Resize the framebuffer texture
|
||||||
|
glBindTexture(GL_TEXTURE_2D, framebufferTexture);
|
||||||
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
// resize depth buffer texture
|
||||||
|
glBindTexture(GL_TEXTURE_2D, depthTexture);
|
||||||
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, windowX, windowY, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void processInput(GLFWwindow* window)
|
void processInput(GLFWwindow* window)
|
||||||
|
Loading…
Reference in New Issue
Block a user