parent
6013283b00
commit
13e072853f
@ -0,0 +1,2 @@ |
|||||||
|
* Make the Deck::analyze do a more thorough analysis/check. |
||||||
|
* Get the code online. |
||||||
@ -1,2 +1,26 @@ |
|||||||
#include "document.hpp" |
#include "document.hpp" |
||||||
#include <fmt/core.h> |
#include <fmt/core.h> |
||||||
|
|
||||||
|
void Deck::analyze() { |
||||||
|
// Needed work:
|
||||||
|
// * Character mapping for the fonts
|
||||||
|
// * Checks for errors
|
||||||
|
// * Resource prep: images, fonts, font glyphs
|
||||||
|
for(auto& slide : slides) { |
||||||
|
for(auto& node : slide.content) { |
||||||
|
switch(node.type) { |
||||||
|
case NodeType::IMAGE: { |
||||||
|
dbc::check(node.image == nullptr, "Got an image node that's already setup."); |
||||||
|
node.image = std::make_shared<Image>(); |
||||||
|
std::string src = std::any_cast<std::string>(node.config.at("src")); |
||||||
|
node.image->load(src); |
||||||
|
break; |
||||||
|
} |
||||||
|
default: |
||||||
|
fmt::println("Skipping unknown node"); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
analyzed = true; |
||||||
|
} |
||||||
|
|||||||
@ -1,116 +1,20 @@ |
|||||||
#define _USE_MATH_DEFINES |
#define _USE_MATH_DEFINES |
||||||
#include <glm/glm.hpp> |
|
||||||
#include <glm/gtc/matrix_transform.hpp> |
|
||||||
#include <glm/gtc/type_ptr.hpp> |
|
||||||
#include <stb_image.h> |
|
||||||
#include <fmt/core.h> |
#include <fmt/core.h> |
||||||
#include <glad/glad.h> |
|
||||||
#include <GLFW/glfw3.h> |
|
||||||
#include "config.hpp" |
#include "config.hpp" |
||||||
#include "render.hpp" |
#include "render.hpp" |
||||||
#include "bezos.hpp" |
#include "bezos.hpp" |
||||||
|
|
||||||
void framebuffer_size_callback(GLFWwindow *window, int width, int height); |
|
||||||
|
|
||||||
|
|
||||||
void init_glfw() { |
|
||||||
glfwInit(); |
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); |
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); |
|
||||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); |
|
||||||
|
|
||||||
#ifdef __APPLE__ |
|
||||||
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); |
|
||||||
#endif |
|
||||||
} |
|
||||||
|
|
||||||
void framebuffer_size_callback(GLFWwindow *, int width, int height) { |
|
||||||
glViewport(0, 0, width, height); |
|
||||||
} |
|
||||||
|
|
||||||
void mouse_callback(GLFWwindow *window, double xpos, double ypos) { |
|
||||||
Engine* engine = static_cast<Engine*>(glfwGetWindowUserPointer(window)); |
|
||||||
engine->mouse(xpos, ypos); |
|
||||||
} |
|
||||||
|
|
||||||
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) |
|
||||||
{ |
|
||||||
Engine* engine = static_cast<Engine*>(glfwGetWindowUserPointer(window)); |
|
||||||
|
|
||||||
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) { |
|
||||||
glfwSetWindowShouldClose(window, true); |
|
||||||
} |
|
||||||
|
|
||||||
if (key == GLFW_KEY_W && action == GLFW_PRESS) { |
|
||||||
engine->change_slide(-1); |
|
||||||
} |
|
||||||
|
|
||||||
if (key == GLFW_KEY_S && action == GLFW_PRESS) { |
|
||||||
engine->change_slide(1); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
GLFWwindow* create_window() { |
|
||||||
GLFWwindow* window = glfwCreateWindow(SCR_WIDTH, SCR_HEIGHT, "LearnOpenGL", NULL, NULL); |
|
||||||
dbc::check(window != NULL, "failed to open window"); |
|
||||||
|
|
||||||
glfwMakeContextCurrent(window); |
|
||||||
|
|
||||||
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); |
|
||||||
|
|
||||||
auto good = gladLoadGLLoader((GLADloadproc)glfwGetProcAddress); |
|
||||||
dbc::check(good, "failed to load GLAD"); |
|
||||||
|
|
||||||
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); |
|
||||||
|
|
||||||
glfwSetCursorPosCallback(window, mouse_callback); |
|
||||||
glfwSetKeyCallback(window, key_callback); |
|
||||||
|
|
||||||
return window; |
|
||||||
} |
|
||||||
|
|
||||||
void setup() { |
|
||||||
glEnable(GL_DEPTH_TEST); |
|
||||||
glEnable(GL_BLEND); |
|
||||||
glEnable(GL_CULL_FACE); |
|
||||||
glEnable(GL_MULTISAMPLE); |
|
||||||
|
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
|
||||||
|
|
||||||
glDepthFunc(GL_LESS); |
|
||||||
} |
|
||||||
|
|
||||||
void update(GLFWwindow* window) { |
|
||||||
glfwPollEvents(); |
|
||||||
} |
|
||||||
|
|
||||||
void render(GLFWwindow* window, Engine &state) { |
|
||||||
state.render(); |
|
||||||
|
|
||||||
glfwSwapBuffers(window); |
|
||||||
} |
|
||||||
|
|
||||||
void quit(GLFWwindow* window) { |
|
||||||
glfwTerminate(); |
|
||||||
} |
|
||||||
|
|
||||||
int main() { |
int main() { |
||||||
init_glfw(); |
|
||||||
|
|
||||||
auto window = create_window(); |
|
||||||
setup(); |
|
||||||
Deck deck = Bezos::load("lua/builder_test.lua"); |
Deck deck = Bezos::load("lua/builder_test.lua"); |
||||||
|
Engine state{.deck=deck}; |
||||||
|
state.init(); |
||||||
|
|
||||||
Engine state(deck); |
while(state.active()) { |
||||||
|
state.update(); |
||||||
glfwSetWindowUserPointer(window, &state); |
state.render(); |
||||||
|
|
||||||
while(!glfwWindowShouldClose(window)) { |
|
||||||
update(window); |
|
||||||
render(window, state); |
|
||||||
} |
} |
||||||
|
|
||||||
quit(window); |
state.quit(); |
||||||
|
|
||||||
return 0; |
return 0; |
||||||
} |
} |
||||||
|
|||||||
Loading…
Reference in new issue