glerminal/source/glerminal-private.h

81 lines
1.9 KiB
C
Raw Normal View History

2024-05-09 19:42:12 +00:00
#ifndef TERMG_PRIVATE_H
#define TERMG_PRIVATE_H
#include "glerminal.h"
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <stdexcept>
#ifdef _DEBUG
#include <fstream>
#endif
2024-05-09 19:42:12 +00:00
namespace glerminal
{
constexpr unsigned int SCREEN_WIDTH = 1280;
constexpr unsigned int SCREEN_HEIGHT = 800;
constexpr unsigned int CELL_SIZE = GLERMINAL_CELL_SIZE;
constexpr unsigned int CELL_SCALE = 5;
constexpr unsigned int GRID_WIDTH = SCREEN_WIDTH / (CELL_SIZE * CELL_SCALE);
constexpr unsigned int GRID_HEIGHT = SCREEN_HEIGHT / (CELL_SIZE * CELL_SCALE);
constexpr unsigned int GRID_AREA = GRID_WIDTH * GRID_HEIGHT;
constexpr unsigned int LAYER_COUNT = 16;
2024-05-09 19:42:12 +00:00
class glerminal
{
public:
glerminal(glerminal_main_cb main);
~glerminal();
glerminal(const glerminal&) = delete;
glerminal(glerminal&&) = delete;
glerminal& operator=(const glerminal&) = delete;
glerminal& operator=(glerminal&&) = delete;
void run();
void flush();
void set(unsigned char x, unsigned char y, unsigned char layer, unsigned char sprite);
unsigned char get(unsigned char x, unsigned char y, unsigned char layer) const;
2024-05-09 19:42:12 +00:00
private:
GLFWwindow* m_window;
unsigned int m_vbo;
unsigned int m_instance_vbo;
2024-05-09 19:42:12 +00:00
unsigned int m_vao;
unsigned int m_program;
unsigned int m_screen_vao;
unsigned int m_screen_program;
unsigned int m_sprites_texture;
unsigned int m_framebuffer;
unsigned int m_framebuffer_backing_texture;
unsigned int m_screen_size_uniform_location;
unsigned int m_palette_uniform_location;
unsigned char m_cells[GRID_AREA * LAYER_COUNT];
unsigned char m_sprites[CELL_SIZE * CELL_SIZE * 256];
float m_palette[64];
2024-05-09 19:42:12 +00:00
glerminal_main_cb m_main;
#ifdef _DEBUG
mutable std::ofstream m_log;
void log(GLenum type, GLuint id, GLenum severity, const char* message) const;
#endif
2024-05-09 19:42:12 +00:00
void init_glfw();
void init_gl();
void deinit_glfw();
void deinit_gl();
void update_sprites();
void update_palette();
2024-05-09 19:42:12 +00:00
};
}
#endif//TERMG_PRIVATE_H