Create const variables for window dimensions

This commit is contained in:
Jack Christensen 2024-08-13 17:58:49 -04:00
parent 590982cde3
commit 74ac6aec9a
3 changed files with 17 additions and 13 deletions

View File

@ -8,7 +8,7 @@
class Scene { class Scene {
public: public:
Scene(); Scene(int width, int height);
~Scene(); ~Scene();
void Init(); void Init();

View File

@ -39,6 +39,9 @@
namespace { namespace {
const int kInitWindowWidth = 1280;
const int kInitWindowHeight = 720;
const int kTargetFps = 60; const int kTargetFps = 60;
const auto kFrameDuration = std::chrono::milliseconds(1000 / kTargetFps); const auto kFrameDuration = std::chrono::milliseconds(1000 / kTargetFps);
@ -55,7 +58,7 @@ GLFWwindow* CreateGlfwWindow() {
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE); glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE);
#endif #endif
GLFWwindow* window = glfwCreateWindow(1280, 720, "TerraVisor", nullptr, nullptr); GLFWwindow* window = glfwCreateWindow(kInitWindowWidth, kInitWindowHeight, "TerraVisor", nullptr, nullptr);
if (!window) { if (!window) {
std::cerr << "Failed to create GLFW window" << std::endl; std::cerr << "Failed to create GLFW window" << std::endl;
glfwTerminate(); glfwTerminate();
@ -123,7 +126,7 @@ int main() {
if (!InitializeGlew()) return -1; if (!InitializeGlew()) return -1;
Scene scene; Scene scene(kInitWindowWidth, kInitWindowHeight);
scene.Init(); scene.Init();
InitializeImGui(window); InitializeImGui(window);

View File

@ -29,16 +29,17 @@ const std::string kFragmentShaderPath = "shaders/fragment.glsl";
} // namespace } // namespace
Scene::Scene() : window_width(1280), Scene::Scene(int width, int height)
window_height(720), : window_width(width),
shader_program_(-1), window_height(height),
vao_(-1), shader_program_(-1),
angle_(0.0f), vao_(-1),
scale_(1.0f), angle_(0.0f),
aspect_(1280.0f / 720.0f), scale_(1.0f),
near_z_(0.1f), far_z_(100.0f), aspect_(1280.0f / 720.0f),
fov_(glm::pi<float>() / 4.0f) near_z_(0.1f), far_z_(100.0f),
{}; fov_(glm::pi<float>() / 4.0f)
{}
Scene::~Scene() { Scene::~Scene() {
glDeleteProgram(shader_program_); glDeleteProgram(shader_program_);