Compare commits
8 Commits
4ce0f0d2f4
...
d3506737f0
Author | SHA1 | Date |
---|---|---|
Archie Hilton | d3506737f0 | |
Archie Hilton | ec0155bc77 | |
Archie Hilton | fb4a412db5 | |
Archie Hilton | 2e5c5fdf8c | |
Archie Hilton | f5883d0219 | |
Archie Hilton | aa8c0f8594 | |
Archie Hilton | 78c38fcc2d | |
Archie Hilton | 50461ad4c8 |
|
@ -3,7 +3,8 @@ cmake_minimum_required(VERSION 3.21)
|
||||||
project(Exponent CXX)
|
project(Exponent CXX)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize=undefined")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize=undefined -g")
|
||||||
|
set(CMAKE_BUILD_TYPE Debug)
|
||||||
|
|
||||||
add_subdirectory(glfw)
|
add_subdirectory(glfw)
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
|
|
2
glfw
2
glfw
|
@ -1 +1 @@
|
||||||
Subproject commit 228e58262e18f2ee61799bd86d0be718b1e31f9f
|
Subproject commit 7b6aead9fb88b3623e3b3725ebb42670cbe4c579
|
|
@ -9,6 +9,7 @@ add_executable(Exponent
|
||||||
target_link_libraries(Exponent PUBLIC glfw glm::glm)
|
target_link_libraries(Exponent PUBLIC glfw glm::glm)
|
||||||
target_include_directories(Exponent PUBLIC ${CMAKE_SOURCE_DIR}/include)
|
target_include_directories(Exponent PUBLIC ${CMAKE_SOURCE_DIR}/include)
|
||||||
|
|
||||||
|
target_compile_definitions(Exponent PUBLIC "$<$<CONFIG:DEBUG>:DEBUG>")
|
||||||
target_compile_definitions(Exponent PRIVATE GLFW_INCLUDE_NONE)
|
target_compile_definitions(Exponent PRIVATE GLFW_INCLUDE_NONE)
|
||||||
|
|
||||||
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/shaders/shader.frag" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/shaders/")
|
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/shaders/shader.frag" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/shaders/")
|
||||||
|
|
|
@ -24,6 +24,8 @@ static GLuint compile_shader(GLenum shader_type, const std::string &path) {
|
||||||
std::string shader_source_str = shader_source_stream.str();
|
std::string shader_source_str = shader_source_stream.str();
|
||||||
const GLchar *shader_source = shader_source_str.c_str();
|
const GLchar *shader_source = shader_source_str.c_str();
|
||||||
|
|
||||||
|
shader_file_handle.close();
|
||||||
|
|
||||||
GLuint shader_id = glCreateShader(shader_type);
|
GLuint shader_id = glCreateShader(shader_type);
|
||||||
|
|
||||||
if (shader_id == 0) {
|
if (shader_id == 0) {
|
||||||
|
@ -77,5 +79,9 @@ GLuint compile_and_link_program(const std::vector<std::pair<GLuint, std::string>
|
||||||
throw GLProgramException(std::format("Program {} link failed:\n{}", program_id, error_log));
|
throw GLProgramException(std::format("Program {} link failed:\n{}", program_id, error_log));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (auto &s:shader_ids) {
|
||||||
|
glDeleteShader(s);
|
||||||
|
}
|
||||||
|
|
||||||
return program_id;
|
return program_id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,4 +19,5 @@ Mesh::Mesh(std::span<glm::vec2> verts) {
|
||||||
|
|
||||||
Mesh::~Mesh() {
|
Mesh::~Mesh() {
|
||||||
glDeleteVertexArrays(1, &vao);
|
glDeleteVertexArrays(1, &vao);
|
||||||
|
glDeleteBuffers(1, &vbo);
|
||||||
}
|
}
|
||||||
|
|
13
src/main.cc
13
src/main.cc
|
@ -90,8 +90,6 @@ static GLuint vertex_buf[2];
|
||||||
static GLuint array_buf[2];
|
static GLuint array_buf[2];
|
||||||
static const GLuint vertex_data_position = 0;
|
static const GLuint vertex_data_position = 0;
|
||||||
|
|
||||||
static Quad *o1;
|
|
||||||
|
|
||||||
static std::vector<Quad *> quads = {};
|
static std::vector<Quad *> quads = {};
|
||||||
|
|
||||||
static std::array<glm::vec2, 6> verts({
|
static std::array<glm::vec2, 6> verts({
|
||||||
|
@ -121,8 +119,8 @@ static void init_opengl() {
|
||||||
dbg_log("Initialising opengl");
|
dbg_log("Initialising opengl");
|
||||||
|
|
||||||
// During init, enable debug output
|
// During init, enable debug output
|
||||||
glEnable ( GL_DEBUG_OUTPUT );
|
glEnable(GL_DEBUG_OUTPUT);
|
||||||
glDebugMessageCallback( MessageCallback, 0 );
|
glDebugMessageCallback(MessageCallback, 0);
|
||||||
|
|
||||||
// Configure the context's capabilities
|
// Configure the context's capabilities
|
||||||
glClearColor(0.0, 0.0, 0.0, 1.0);
|
glClearColor(0.0, 0.0, 0.0, 1.0);
|
||||||
|
@ -172,8 +170,13 @@ int main() {
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
delete(o1);
|
for(auto q: quads) {
|
||||||
|
delete(q);
|
||||||
|
}
|
||||||
|
|
||||||
glfwDestroyWindow(w);
|
glfwDestroyWindow(w);
|
||||||
|
#ifndef DEBUG
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
|
#endif
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue