Files
cuber/scenes/sphere.hpp
T
portersky a4ef4adfc7 feat: add window resize support
Added width/height tracking to the window class via a GLFW
resize callback. The callback stores the current size and
forwards it to a user-provided std::function.

Added context::set_size() to update the GL viewport when
the window is resized.

Changed scene::render() to accept (int width, int height)
parameters so scenes can compute the correct aspect ratio
for their projection matrix instead of hardcoding 1280/720.

Fixed parameter shadowing in resize_callback_impl
(glfw_window instead of window).
2026-05-06 00:06:59 +02:00

40 lines
783 B
C++

#pragma once
#include <chrono>
#include "glm/glm.hpp"
#include "cbt/scene.hpp"
#include "cbt/opengl/buffer.hpp"
#include "cbt/opengl/shader.hpp"
#include "cbt/opengl/vao.hpp"
namespace cbt::scenes {
class sphere final : public scene {
public:
sphere();
auto init() -> bool override;
auto update(float delta_time) -> void override;
auto render(int width, int height) -> void override;
private:
opengl::shader m_prog;
opengl::buffer m_vbo;
opengl::buffer m_ebo{opengl::buffer_type::index};
opengl::vao m_vao;
GLint m_loc_proj = -1;
GLint m_loc_view = -1;
GLint m_loc_model = -1;
GLsizei m_index_count = 0;
std::chrono::steady_clock::time_point m_start;
auto build_mesh() -> void;
auto build_shader() -> bool;
};
}