Adds HUD elements #9

Merged
EmaMaker merged 7 commits from hud into main 2023-09-20 12:44:00 +02:00
12 changed files with 257 additions and 17 deletions

3
.gitignore vendored
View File

@ -9,4 +9,5 @@ gmon.out*
cscope* cscope*
test.cpp test.cpp
a.out a.out
*screenshot* *screenshot*
imgui.ini

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "lib/imgui"]
path = lib/imgui
url = https://github.com/ocornut/imgui/

View File

@ -2,8 +2,8 @@ cmake_minimum_required(VERSION 3.2)
project(cmake-project-template) project(cmake-project-template)
set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O3") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -O3")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -g") #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -g")
set(CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR}) set(CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR})

19
include/debugwindow.hpp Normal file
View File

@ -0,0 +1,19 @@
#ifndef DEBUG_WINDOW_H
#define DEBUG_WINDOW_H
#include <any>
#include <string>
#include <GLFW/glfw3.h>
namespace debug{
namespace window {
void init(GLFWwindow* window);
void prerender();
void render();
void destroy();
void set_parameter(std::string key, std::any value);
}
}
#endif

View File

@ -1,2 +1,3 @@
add_subdirectory(glad) add_subdirectory(glad)
add_subdirectory(glm) add_subdirectory(glm)
add_subdirectory(imgui)

1
lib/imgui Submodule

@ -0,0 +1 @@
Subproject commit 6addf28c4b5d8fd109a6db73bed6436952b230b2

View File

@ -4,7 +4,25 @@ in vec2 TexCoord;
out vec4 FragColor; out vec4 FragColor;
uniform sampler2D renderTex; uniform sampler2D renderTex;
uniform int screenWidth;
uniform int screenHeight;
uniform int crosshairType;
void main(){ void main(){
float crosshair_alpha = 0.8;
float dist = length(gl_FragCoord.xy-vec2(screenWidth/2, screenHeight/2));
FragColor = texture(renderTex, TexCoord); FragColor = texture(renderTex, TexCoord);
/*float crosshair_color = (FragColor.x + FragColor.y + FragColor.z) / 3;
/*if(crosshair_color <= 0.5) crosshair_color = 1.0;
/*else crosshair_color = 0.0;*/
float crosshair_color = 1.0;
if(dist <= 7){
if( (crosshairType == 0 && dist >= 5) ||
(crosshairType == 1 && ( int(gl_FragCoord.x) == int(screenWidth / 2) ||
int(gl_FragCoord.y) == int(screenHeight / 2)) )
) FragColor = vec4(vec3(crosshair_color), crosshair_alpha);
}
} }

View File

@ -1,9 +1,10 @@
cmake_minimum_required(VERSION 3.2) cmake_minimum_required(VERSION 3.2)
project(OpenGLTest) project(OpenGLTest)
set(SOURCE_FILES main.cpp chunk.cpp chunkmanager.cpp chunkmesher.cpp chunkgenerator.cpp renderer.cpp spacefilling.cpp stb_image.cpp utils.cpp OpenSimplexNoise.cpp) set(SOURCE_FILES main.cpp chunk.cpp chunkmanager.cpp chunkmesher.cpp chunkgenerator.cpp
debugwindow.cpp renderer.cpp spacefilling.cpp stb_image.cpp utils.cpp OpenSimplexNoise.cpp)
add_executable(OpenGLTest ${SOURCE_FILES}) add_executable(OpenGLTest ${SOURCE_FILES})
target_link_libraries(OpenGLTest glfw tbb glad glm) target_link_libraries(OpenGLTest glfw tbb glad glm imgui)
install(TARGETS OpenGLTest DESTINATION ${DIVISIBLE_INSTALL_BIN_DIR}) install(TARGETS OpenGLTest DESTINATION ${DIVISIBLE_INSTALL_BIN_DIR})

View File

@ -12,6 +12,7 @@
#include "chunk.hpp" #include "chunk.hpp"
#include "chunkgenerator.hpp" #include "chunkgenerator.hpp"
#include "chunkmesher.hpp" #include "chunkmesher.hpp"
#include "debugwindow.hpp"
#include "globals.hpp" #include "globals.hpp"
#include "renderer.hpp" #include "renderer.hpp"
@ -33,6 +34,7 @@ namespace chunkmanager
// Queue of chunks to be meshed // Queue of chunks to be meshed
ChunkPriorityQueue chunks_to_mesh_queue; ChunkPriorityQueue chunks_to_mesh_queue;
int block_to_place{2};
// Init chunkmanager. Chunk indices and start threads // Init chunkmanager. Chunk indices and start threads
int chunks_volume_real; int chunks_volume_real;
@ -85,6 +87,8 @@ namespace chunkmanager
update_thread = std::thread(update); update_thread = std::thread(update);
gen_thread = std::thread(generate); gen_thread = std::thread(generate);
mesh_thread = std::thread(mesh); mesh_thread = std::thread(mesh);
debug::window::set_parameter("block_type_return", &block_to_place);
} }
// Method for world generation thread(s) // Method for world generation thread(s)
@ -117,6 +121,16 @@ namespace chunkmanager
int chunkY=static_cast<int>(theCamera.getAtomicPosY() / CHUNK_SIZE); int chunkY=static_cast<int>(theCamera.getAtomicPosY() / CHUNK_SIZE);
int chunkZ=static_cast<int>(theCamera.getAtomicPosZ() / CHUNK_SIZE); int chunkZ=static_cast<int>(theCamera.getAtomicPosZ() / CHUNK_SIZE);
debug::window::set_parameter("px", theCamera.getAtomicPosX());
debug::window::set_parameter("py", theCamera.getAtomicPosY());
debug::window::set_parameter("pz", theCamera.getAtomicPosZ());
debug::window::set_parameter("cx", chunkX);
debug::window::set_parameter("cy", chunkY);
debug::window::set_parameter("cz", chunkZ);
debug::window::set_parameter("lx", theCamera.getFront().x);
debug::window::set_parameter("ly", theCamera.getFront().y);
debug::window::set_parameter("lz", theCamera.getFront().z);
// Update other chunks // Update other chunks
for(int i = 0; i < chunks_volume_real; i++) { for(int i = 0; i < chunks_volume_real; i++) {
const uint16_t x = chunks_indices[i][0] + chunkX; const uint16_t x = chunks_indices[i][0] + chunkX;
@ -152,6 +166,9 @@ namespace chunkmanager
a.release(); a.release();
} }
debug::window::set_parameter("update_chunks_total", (int) (chunks.size()));
debug::window::set_parameter("update_chunks_bucket", (int) (chunks.max_size()));
Chunk::Chunk* n; Chunk::Chunk* n;
nUnloaded = 0; nUnloaded = 0;
while(chunks_todelete.try_pop(n)){ while(chunks_todelete.try_pop(n)){
@ -240,11 +257,17 @@ namespace chunkmanager
if(!chunks.find(a1, calculateIndex(px1, py1, pz1))) return; if(!chunks.find(a1, calculateIndex(px1, py1, pz1))) return;
Chunk::Chunk* c1 = a1->second; Chunk::Chunk* c1 = a1->second;
// place the new block (only stone for now) // place the new block (only stone for now)
c1->setBlock( Block::STONE, bx1, by1, bz1); c1->setBlock((Block)block_to_place, bx1, by1, bz1);
// mark the mesh of the chunk the be updated // mark the mesh of the chunk the be updated
chunks_to_mesh_queue.push(std::make_pair(c1, MESHING_PRIORITY_PLAYER_EDIT)); chunks_to_mesh_queue.push(std::make_pair(c1, MESHING_PRIORITY_PLAYER_EDIT));
chunks_to_mesh_queue.push(std::make_pair(c, MESHING_PRIORITY_PLAYER_EDIT)); chunks_to_mesh_queue.push(std::make_pair(c, MESHING_PRIORITY_PLAYER_EDIT));
debug::window::set_parameter("block_last_action", place);
debug::window::set_parameter("block_last_action_block_type", (int)(Block::STONE));
debug::window::set_parameter("block_last_action_x", px1*CHUNK_SIZE + bx1);
debug::window::set_parameter("block_last_action_y", px1*CHUNK_SIZE + by1);
debug::window::set_parameter("block_last_action_z", px1*CHUNK_SIZE + bz1);
}else{ }else{
// replace the current block with air to remove it // replace the current block with air to remove it
c->setBlock( Block::AIR, bx, by, bz); c->setBlock( Block::AIR, bx, by, bz);
@ -265,6 +288,13 @@ namespace chunkmanager
chunkmesher::mesh(b2->second); chunkmesher::mesh(b2->second);
if(bz == CHUNK_SIZE - 1 && pz +1 < 1024 && chunks.find(c2, calculateIndex(px, py, pz +1))) if(bz == CHUNK_SIZE - 1 && pz +1 < 1024 && chunks.find(c2, calculateIndex(px, py, pz +1)))
chunkmesher::mesh(c2->second); chunkmesher::mesh(c2->second);
debug::window::set_parameter("block_last_action", place);
debug::window::set_parameter("block_last_action_block_type", (int) (Block::AIR));
debug::window::set_parameter("block_last_action_x", px*CHUNK_SIZE + bx);
debug::window::set_parameter("block_last_action_y", py*CHUNK_SIZE + by);
debug::window::set_parameter("block_last_action_z", pz*CHUNK_SIZE + bz);
} }
break; break;
} }

130
src/debugwindow.cpp Normal file
View File

@ -0,0 +1,130 @@
#include "debugwindow.hpp"
#include <imgui/imgui.h>
#include <imgui/imgui_impl_opengl3.h>
#include <imgui/imgui_impl_glfw.h>
#include <imgui_stdlib.h>
#include <iostream>
#include <string>
#include <unordered_map>
namespace debug{
namespace window{
void show_debug_window();
constexpr int frametimes_array_size = 20;
float frametimes_array[frametimes_array_size]{};
std::unordered_map<std::string, std::any> parameters;
void init(GLFWwindow* window){
// Setup Dear ImGui context
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO();
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
// Setup Platform/Renderer backends
ImGui_ImplGlfw_InitForOpenGL(window, true); // Second param install_callback=true will install GLFW callbacks and chain to existing ones.
ImGui_ImplOpenGL3_Init();
}
void prerender(){
// Start the Dear ImGui frame
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
//ImGui::ShowDemoWindow(); // Show demo window! :)
show_debug_window();
}
void render(){
// (Your code clears your framebuffer, renders your other stuff etc.)
ImGui::Render();
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
// (Your code calls glfwSwapBuffers() etc.)
}
void destroy(){
ImGui_ImplOpenGL3_Shutdown();
ImGui_ImplGlfw_Shutdown();
ImGui::DestroyContext();
ImGui_ImplOpenGL3_Shutdown();
ImGui_ImplGlfw_Shutdown();
ImGui::DestroyContext();
}
void set_parameter(std::string key, std::any value){
parameters[key] = value;
}
void show_debug_window(){
ImGui::Begin("Debug Window");
ImGui::PushItemWidth(ImGui::GetFontSize() * -12);
try{
if (ImGui::CollapsingHeader("Frametimes")){
ImGui::Text("FPS: %d", std::any_cast<int>(parameters.at("fps")));
ImGui::Text("Frametime (ms): %f",
std::any_cast<float>(parameters.at("frametime"))*1000);
//ImGui::PlotLines("Frame Times", arr, IM_ARRAYSIZE(arr);
}
if(ImGui::CollapsingHeader("Player")){
ImGui::Text("X: %f, Y: %f, Z: %f",
std::any_cast<float>(parameters.at("px")),std::any_cast<float>(parameters.at("py")),std::any_cast<float>(parameters.at("pz")) );
ImGui::Text("X: %d, Y: %d, Z: %d (chunk)", std::any_cast<int>(parameters.at("cx")),std::any_cast<int>(parameters.at("cy")),std::any_cast<int>(parameters.at("cz")) );
ImGui::Text("Pointing in direction: %f, %f, %f",
std::any_cast<float>(parameters.at("lx")),std::any_cast<float>(parameters.at("ly")),std::any_cast<float>(parameters.at("lz")) );
if(parameters.find("block_last_action") != parameters.end()){
ImGui::Text("Last Block action: %s",
std::any_cast<bool>(parameters.at("block_last_action")) ? "place" : "destroy");
ImGui::Text("Last Block action block type: %d",
std::any_cast<int>(parameters.at("block_last_action_block_type")));
ImGui::Text("Last Block action position: X: %d, Y: %d, Z: %d",
std::any_cast<int>(parameters.at("block_last_action_x")),std::any_cast<int>(parameters.at("block_last_action_y")),std::any_cast<int>(parameters.at("block_last_action_z")) );
}
ImGui::SliderInt("Crosshair type",
std::any_cast<int*>(parameters.at("crosshair_type_return")), 0, 1);
ImGui::SliderInt("Block to place",
std::any_cast<int*>(parameters.at("block_type_return")), 2, 6);
}
if(ImGui::CollapsingHeader("Mesh")){
ImGui::Text("Total chunks updated: %d",
std::any_cast<int>(parameters.at("render_chunks_total")));
ImGui::Text("Chunks rendered: %d",
std::any_cast<int>(parameters.at("render_chunks_rendered")));
ImGui::Text("Frustum culled: %d",
std::any_cast<int>(parameters.at("render_chunks_culled")));
ImGui::Text("Chunks out of view: %d",
std::any_cast<int>(parameters.at("render_chunks_oof")));
if(parameters.find("render_chunks_deleted") != parameters.end())
ImGui::Text("Chunks deleted: %d",
std::any_cast<int>(parameters.at("render_chunks_deleted")));
ImGui::Text("Vertices in the scene: %d",
std::any_cast<int>(parameters.at("render_chunks_vertices")));
ImGui::Checkbox("Wireframe",
std::any_cast<bool*>(parameters.at("wireframe_return")));
}
if(ImGui::CollapsingHeader("Chunks")){
ImGui::Text("Total chunks present: %d",
std::any_cast<int>(parameters.at("update_chunks_total")));
/*ImGui::Text("Chunks freed from memory: %d",
std::any_cast<int>(parameters.at("update_chunks_delete")));*/
ImGui::Text("Bucket size: %d",
std::any_cast<int>(parameters.at("update_chunks_bucket")));
}
}catch(const std::bad_any_cast& e){
std::cout << e.what();
}
ImGui::End();
}
}
}

View File

@ -10,6 +10,7 @@
#include "chunkmanager.hpp" #include "chunkmanager.hpp"
#include "main.hpp" #include "main.hpp"
#include "debugwindow.hpp"
#include "renderer.hpp" #include "renderer.hpp"
#include "spacefilling.hpp" #include "spacefilling.hpp"
#include "shader.hpp" #include "shader.hpp"
@ -21,7 +22,7 @@ int frames = 0;
float lastBlockPick=0.0; float lastBlockPick=0.0;
bool blockpick = false; bool blockpick = false;
bool canChangeWireframe = true; bool cursor = false;
int main() int main()
{ {
@ -67,8 +68,10 @@ int main()
sines[i] = sin(3.14 / 180 * i); sines[i] = sin(3.14 / 180 * i);
cosines[i] = cos(3.14 / 180 * i); cosines[i] = cos(3.14 / 180 * i);
} }
SpaceFilling::initLUT(); SpaceFilling::initLUT();
chunkmanager::init(); chunkmanager::init();
debug::window::init(window);
renderer::init(window); renderer::init(window);
while (!glfwWindowShouldClose(window)) while (!glfwWindowShouldClose(window))
@ -78,10 +81,12 @@ int main()
deltaTime = currentFrame - lastFrame; deltaTime = currentFrame - lastFrame;
lastFrame = currentFrame; lastFrame = currentFrame;
debug::window::set_parameter("frametime", deltaTime);
// FPS Counter // FPS Counter
frames++; frames++;
if(currentFrame - lastFPSFrame >= 1.0f){ if(currentFrame - lastFPSFrame >= 1.0f){
std::cout << "FPS: " << frames << " Frametime: " << deltaTime << std::endl; //std::cout << "FPS: " << frames << " Frametime: " << deltaTime << std::endl;
debug::window::set_parameter("fps", frames);
frames = 0; frames = 0;
lastFPSFrame = currentFrame; lastFPSFrame = currentFrame;
} }
@ -112,6 +117,7 @@ int main()
// Cleanup allocated memory // Cleanup allocated memory
chunkmanager::destroy(); chunkmanager::destroy();
renderer::destroy(); renderer::destroy();
debug::window::destroy();
glfwTerminate(); glfwTerminate();
return 0; return 0;
@ -146,16 +152,15 @@ void processInput(GLFWwindow *window)
lastBlockPick=glfwGetTime(); lastBlockPick=glfwGetTime();
} }
if (glfwGetKey(window, GLFW_KEY_F) == GLFW_PRESS && canChangeWireframe){
wireframe = !wireframe;
canChangeWireframe = false;
}
if (glfwGetKey(window, GLFW_KEY_F) == GLFW_RELEASE) canChangeWireframe = true;
// Reset blockpicking if enough time has passed // Reset blockpicking if enough time has passed
if(glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_1) == GLFW_RELEASE && glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_2) == GLFW_RELEASE) blockpick = false; if(glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_1) == GLFW_RELEASE && glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_2) == GLFW_RELEASE) blockpick = false;
if(glfwGetKey(window, GLFW_KEY_F2) == GLFW_PRESS) renderer::saveScreenshot(); if(glfwGetKey(window, GLFW_KEY_F2) == GLFW_PRESS) renderer::saveScreenshot();
if(glfwGetKey(window, GLFW_KEY_F3) == GLFW_PRESS) renderer::saveScreenshot(true); if(glfwGetKey(window, GLFW_KEY_F3) == GLFW_PRESS) renderer::saveScreenshot(true);
if(glfwGetKey(window, GLFW_KEY_M) == GLFW_PRESS) {
cursor = !cursor;
glfwSetInputMode(window, GLFW_CURSOR, cursor ? GLFW_CURSOR_NORMAL : GLFW_CURSOR_DISABLED);
}
} }

View File

@ -5,6 +5,7 @@
#include "chunkmanager.hpp" #include "chunkmanager.hpp"
#include "chunkmesher.hpp" #include "chunkmesher.hpp"
#include "debugwindow.hpp"
#include "globals.hpp" #include "globals.hpp"
#include "stb_image.h" #include "stb_image.h"
#define STB_IMAGE_WRITE_IMPLEMENTATION #define STB_IMAGE_WRITE_IMPLEMENTATION
@ -25,6 +26,9 @@ namespace renderer{
GLuint renderTexFrameBuffer, renderTex, renderTexDepthBuffer, quadVAO, quadVBO; GLuint renderTexFrameBuffer, renderTex, renderTexDepthBuffer, quadVAO, quadVBO;
int screenWidth, screenHeight; int screenWidth, screenHeight;
int crosshair_type{0};
bool wireframe{false};
void init(GLFWwindow* window){ void init(GLFWwindow* window){
// Setup rendering // Setup rendering
// We will render the image to a texture, then display the texture on a quad that fills the // We will render the image to a texture, then display the texture on a quad that fills the
@ -103,6 +107,9 @@ namespace renderer{
glTexParameteri(GL_TEXTURE_2D_ARRAY,GL_TEXTURE_MAG_FILTER,GL_NEAREST); glTexParameteri(GL_TEXTURE_2D_ARRAY,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D_ARRAY,GL_TEXTURE_WRAP_S,GL_REPEAT); glTexParameteri(GL_TEXTURE_2D_ARRAY,GL_TEXTURE_WRAP_S,GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D_ARRAY,GL_TEXTURE_WRAP_T,GL_REPEAT); glTexParameteri(GL_TEXTURE_2D_ARRAY,GL_TEXTURE_WRAP_T,GL_REPEAT);
debug::window::set_parameter("crosshair_type_return", &crosshair_type);
debug::window::set_parameter("wireframe_return", &wireframe);
} }
@ -118,7 +125,11 @@ namespace renderer{
glClearColor(0.431f, 0.694f, 1.0f, 1.0f); glClearColor(0.431f, 0.694f, 1.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
int total{0}, toGpu{0}; /* UPDATE IMGUI */
debug::window::prerender();
/* RENDER THE WORLD TO TEXTURE */
int total{0}, toGpu{0}, oof{0}, vertices{0};
glm::vec4 frustumPlanes[6]; glm::vec4 frustumPlanes[6];
theCamera.getFrustumPlanes(frustumPlanes, true); theCamera.getFrustumPlanes(frustumPlanes, true);
glm::vec3 cameraPos = theCamera.getPos(); glm::vec3 cameraPos = theCamera.getPos();
@ -138,6 +149,9 @@ namespace renderer{
if(dist <= static_cast<float>(RENDER_DISTANCE)){ if(dist <= static_cast<float>(RENDER_DISTANCE)){
if(!c->getState(Chunk::CHUNK_STATE_MESH_LOADED)) continue; if(!c->getState(Chunk::CHUNK_STATE_MESH_LOADED)) continue;
// Increase total vertex count
vertices += c->numVertices;
// reset out-of-vision and unload flags // reset out-of-vision and unload flags
c->setState(Chunk::CHUNK_STATE_OUTOFVISION, false); c->setState(Chunk::CHUNK_STATE_OUTOFVISION, false);
c->setState(Chunk::CHUNK_STATE_UNLOADED, false); c->setState(Chunk::CHUNK_STATE_UNLOADED, false);
@ -174,12 +188,15 @@ namespace renderer{
glBindVertexArray(c->VAO); glBindVertexArray(c->VAO);
glDrawArrays(GL_POINTS, 0, c->numVertices); glDrawArrays(GL_POINTS, 0, c->numVertices);
glBindVertexArray(0); glBindVertexArray(0);
toGpu++;
} }
} }
}else{ }else{
// When the chunk is outside render distance // When the chunk is outside render distance
if(c->getState(Chunk::CHUNK_STATE_OUTOFVISION)){ if(c->getState(Chunk::CHUNK_STATE_OUTOFVISION)){
oof++;
if(glfwGetTime() - c->unload_timer > UNLOAD_TIMEOUT){ if(glfwGetTime() - c->unload_timer > UNLOAD_TIMEOUT){
// If chunk was already out and enough time has passed // If chunk was already out and enough time has passed
// Mark the chunk to be unloaded // Mark the chunk to be unloaded
@ -196,6 +213,14 @@ namespace renderer{
} }
} }
total = chunks_torender.size();
debug::window::set_parameter("render_chunks_total", total);
debug::window::set_parameter("render_chunks_rendered", toGpu);
debug::window::set_parameter("render_chunks_culled", total-toGpu);
debug::window::set_parameter("render_chunks_oof", oof);
debug::window::set_parameter("render_chunks_deleted", (int) (render_todelete.size()));
debug::window::set_parameter("render_chunks_vertices", vertices);
for(auto& c : render_todelete){ for(auto& c : render_todelete){
// we can get away with unsafe erase as access to the container is only done by this // we can get away with unsafe erase as access to the container is only done by this
// thread // thread
@ -205,7 +230,7 @@ namespace renderer{
} }
render_todelete.clear(); render_todelete.clear();
/* DISPLAY TEXTURE ON A QUAD THAT FILLS THE SCREEN */
// Now to render the quad, with the texture on top // Now to render the quad, with the texture on top
// Switch to the default frame buffer // Switch to the default frame buffer
glBindFramebuffer(GL_FRAMEBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0);
@ -217,8 +242,13 @@ namespace renderer{
glDisable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST);
glBindTexture(GL_TEXTURE_2D, renderTex); glBindTexture(GL_TEXTURE_2D, renderTex);
quadShader->use(); quadShader->use();
quadShader->setInt("screenWidth", screenWidth);
quadShader->setInt("screenHeight", screenHeight);
quadShader->setInt("crosshairType", crosshair_type);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glBindVertexArray(0); glBindVertexArray(0);
debug::window::render();
} }
void framebuffer_size_callback(GLFWwindow *window, int width, int height){ void framebuffer_size_callback(GLFWwindow *window, int width, int height){
@ -268,6 +298,7 @@ namespace renderer{
void destroy(){ void destroy(){
delete theShader; delete theShader;
delete quadShader;
} }