feat: add RAII window class with OpenGL 4.1 context
- Add cbt::window class in cbt/ directory with RAII lifecycle - Add setup_opengl and info_opengl for glad init and GL info - Add Q key to quit the application - Update CMakeLists.txt with glfw3 and glad dependencies - Update AGENTS.md with snake_case naming and shell conventions
This commit is contained in:
@@ -1,26 +1,27 @@
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
#define GLFW_INCLUDE_NONE
|
||||
#include "GLFW/glfw3.h"
|
||||
|
||||
#include "fmt/std.h"
|
||||
#include "cbt/window.hpp"
|
||||
|
||||
auto main(int argc, char const* argv[]) -> int {
|
||||
using namespace std::chrono;
|
||||
using namespace std::literals;
|
||||
#include "glad/glad.h"
|
||||
|
||||
auto start = steady_clock::now();
|
||||
auto main(int, char const*[]) -> int {
|
||||
auto w = cbt::window("cuber", 1280, 720);
|
||||
|
||||
while (true) {
|
||||
auto elapsed = steady_clock::now() - start;
|
||||
auto totalSec = duration_cast<seconds>(elapsed).count();
|
||||
auto h = totalSec / 3600;
|
||||
auto m = (totalSec % 3600) / 60;
|
||||
auto s = totalSec % 60;
|
||||
auto ms = duration_cast<milliseconds>(elapsed % 1s).count();
|
||||
if (!w.valid()) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
fmt::print("\033[32m{:02}:{:02}:{:02}\033[0m.\033[90m{:03}\033[0m\r",
|
||||
h, m, s, ms);
|
||||
while (!w.should_close()) {
|
||||
if (glfwGetKey(static_cast<GLFWwindow*>(w.raw()), GLFW_KEY_Q) == GLFW_PRESS) {
|
||||
break;
|
||||
}
|
||||
|
||||
std::this_thread::sleep_for(10ms);
|
||||
glClearColor(0.6f, 0.8f, 1.0f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
w.swap_buffers();
|
||||
w.poll_events();
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user