mirror of
https://git.shylie.info/shylie/glerminal.git
synced 2024-11-24 09:21:05 +00:00
Add some options for configuration
This commit is contained in:
parent
17ea6a7f0a
commit
b2164b76cf
@ -5,9 +5,18 @@ project(glerminal
|
|||||||
LANGUAGES C CXX
|
LANGUAGES C CXX
|
||||||
)
|
)
|
||||||
|
|
||||||
|
option(GLERMINAL_OPENGL_DEBUG_CONTEXT "" OFF)
|
||||||
|
set(GLERMINAL_GRID_WIDTH 40 CACHE STRING "")
|
||||||
|
set(GLERMINAL_GRID_HEIGHT 25 CACHE STRING "")
|
||||||
|
set(GLERMINAL_LAYER_COUNT 64 CACHE STRING "")
|
||||||
|
set(GLERMINAL_CELL_SCALE 4 CACHE STRING "")
|
||||||
|
|
||||||
|
configure_file(source/glerminal-config.h.in glerminal-config.h @ONLY)
|
||||||
|
|
||||||
add_subdirectory(glfw)
|
add_subdirectory(glfw)
|
||||||
|
|
||||||
add_library(glerminal STATIC
|
add_library(glerminal STATIC
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/glerminal-config.h
|
||||||
include/glerminal.h
|
include/glerminal.h
|
||||||
|
|
||||||
source/glerminal-private.h
|
source/glerminal-private.h
|
||||||
@ -26,6 +35,7 @@ set_target_properties(glerminal
|
|||||||
target_include_directories(glerminal
|
target_include_directories(glerminal
|
||||||
PUBLIC
|
PUBLIC
|
||||||
include
|
include
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
PRIVATE
|
PRIVATE
|
||||||
source
|
source
|
||||||
)
|
)
|
||||||
|
@ -1,18 +1,13 @@
|
|||||||
#ifndef GLERMINAL_H
|
#ifndef GLERMINAL_H
|
||||||
#define GLERMINAL_H
|
#define GLERMINAL_H
|
||||||
|
|
||||||
|
#include <glerminal-config.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
GRID_WIDTH = 40,
|
|
||||||
GRID_HEIGHT = 25,
|
|
||||||
LAYER_COUNT = 64
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef void (*glerminal_init_cb)();
|
typedef void (*glerminal_init_cb)();
|
||||||
typedef void (*glerminal_main_cb)(float dt);
|
typedef void (*glerminal_main_cb)(float dt);
|
||||||
|
|
||||||
|
26
source/glerminal-config.h.in
Normal file
26
source/glerminal-config.h.in
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#ifndef GLERMINAL_CONFIG_H
|
||||||
|
#define GLERMINAL_CONFIG_H
|
||||||
|
|
||||||
|
// THIS FILE IS CONFIGURED BY CMAKE
|
||||||
|
// MODIFY glerminal-config.h.in INSTEAD!
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#cmakedefine GLERMINAL_OPENGL_DEBUG_CONTEXT
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
GRID_WIDTH = @GLERMINAL_GRID_WIDTH@,
|
||||||
|
GRID_HEIGHT = @GLERMINAL_GRID_HEIGHT@,
|
||||||
|
LAYER_COUNT = @GLERMINAL_LAYER_COUNT@,
|
||||||
|
CELL_SCALE = @GLERMINAL_CELL_SCALE@
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif//GLERMINAL_CONFIG_H
|
@ -12,13 +12,14 @@
|
|||||||
|
|
||||||
namespace glerminal
|
namespace glerminal
|
||||||
{
|
{
|
||||||
constexpr unsigned int SCREEN_WIDTH = 1280;
|
|
||||||
constexpr unsigned int SCREEN_HEIGHT = 800;
|
|
||||||
constexpr unsigned int CELL_SIZE = 8;
|
constexpr unsigned int CELL_SIZE = 8;
|
||||||
constexpr unsigned int LAYER_COUNT = ::LAYER_COUNT;
|
|
||||||
constexpr unsigned int GRID_WIDTH = ::GRID_WIDTH;
|
constexpr unsigned int GRID_WIDTH = ::GRID_WIDTH;
|
||||||
constexpr unsigned int GRID_HEIGHT = ::GRID_HEIGHT;
|
constexpr unsigned int GRID_HEIGHT = ::GRID_HEIGHT;
|
||||||
|
constexpr unsigned int LAYER_COUNT = ::LAYER_COUNT;
|
||||||
|
constexpr unsigned int CELL_SCALE = ::CELL_SCALE;
|
||||||
constexpr unsigned int GRID_AREA = GRID_WIDTH * GRID_HEIGHT;
|
constexpr unsigned int GRID_AREA = GRID_WIDTH * GRID_HEIGHT;
|
||||||
|
constexpr unsigned int SCREEN_WIDTH = GRID_WIDTH * CELL_SIZE * CELL_SCALE;
|
||||||
|
constexpr unsigned int SCREEN_HEIGHT = GRID_HEIGHT * CELL_SIZE * CELL_SCALE;
|
||||||
|
|
||||||
class glerminal
|
class glerminal
|
||||||
{
|
{
|
||||||
|
@ -295,7 +295,7 @@ namespace glerminal
|
|||||||
// need to think about how to handle resizing to ensure
|
// need to think about how to handle resizing to ensure
|
||||||
// that the window stays an integer number of "tiles" large
|
// that the window stays an integer number of "tiles" large
|
||||||
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
|
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
|
||||||
#ifdef _DEBUG
|
#ifdef GLERMINAL_OPENGL_DEBUG_CONTEXT
|
||||||
glfwWindowHint(GLFW_CONTEXT_DEBUG, GLFW_TRUE);
|
glfwWindowHint(GLFW_CONTEXT_DEBUG, GLFW_TRUE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -308,7 +308,7 @@ namespace glerminal
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef GLERMINAL_OPENGL_DEBUG_CONTEXT
|
||||||
void glerminal::log(GLenum type, GLuint id, GLenum severity, const char* message) const
|
void glerminal::log(GLenum type, GLuint id, GLenum severity, const char* message) const
|
||||||
{
|
{
|
||||||
glDebugMessageInsert(GL_DEBUG_SOURCE_THIRD_PARTY, type, id, severity, -1, message);
|
glDebugMessageInsert(GL_DEBUG_SOURCE_THIRD_PARTY, type, id, severity, -1, message);
|
||||||
@ -325,7 +325,7 @@ namespace glerminal
|
|||||||
throw std::runtime_error("Failed to initialize GLAD.");
|
throw std::runtime_error("Failed to initialize GLAD.");
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef GLERMINAL_OPENGL_DEBUG_CONTEXT
|
||||||
glEnable(GL_DEBUG_OUTPUT);
|
glEnable(GL_DEBUG_OUTPUT);
|
||||||
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
|
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
|
||||||
glDebugMessageCallback([](GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam)
|
glDebugMessageCallback([](GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam)
|
||||||
|
Loading…
Reference in New Issue
Block a user