]> git.lizzy.rs Git - shadowclad.git/commitdiff
Merge branch 'master' into crossbuild
authoroutfrost <kotlet.bahn@gmail.com>
Thu, 6 Aug 2020 00:41:16 +0000 (02:41 +0200)
committeroutfrost <kotlet.bahn@gmail.com>
Thu, 6 Aug 2020 00:41:16 +0000 (02:41 +0200)
1  2 
Makefile
src/engine/engine.c
src/engine/render.c
src/engine/render.h
src/engine/tga.c

diff --cc Makefile
index 106065543eb10c4245027332f0b8c04bb5efa699,0922628921980f3fd5b96961bd065809a39385b2..6939f7465b99ad28b35cc00dbd0ffa008a1ea1d4
+++ b/Makefile
@@@ -7,9 -4,10 +7,11 @@@ BUILDDIR ?= target/$(PLATFORM
  SRCDIR ?= src
  
  CPPFLAGS ::= -iquotesrc/ $(CPPFLAGS)
- CFLAGS ::= -g -std=c99 -Wall -Wextra -Wpedantic -Werror $(CFLAGS)
+ CFLAGS ::= -g -std=c99 -Wall -Wextra -Wpedantic -Werror \
+            -Wno-error=unused-function -Wno-error=unused-parameter $(CFLAGS)
  LDFLAGS ::= $(LDFLAGS)
- LDLIBS ::= -L/usr/x86_64-w64-mingw32/lib -lopengl32 -lglew32 -lfreeglut -lassimp $(LDLIBS)
 -LDLIBS ::= -lm -lGL -lGLEW -lglfw -lassimp $(LDLIBS)
++#LDLIBS ::= -L/usr/x86_64-w64-mingw32/lib -lopengl32 -lglew32 -lfreeglut -lassimp $(LDLIBS)
++LDLIBS ::= -lm -lopengl32 -lglew32 -lglfw -lassimp $(LDLIBS)
  
  # ######
  # Paths
index 0000000000000000000000000000000000000000,1e7849f7a33dc45cf85d5409406de78a005bd8d7..5ebb975d37c5d05b660198f1a032c815d5e34b02
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,117 +1,117 @@@
 -#include <GL/glxew.h>
+ #include "engine.h"
+ #include <stdlib.h>
+ #include <assimp/version.h>
 -      logInfo("GLSL %s", (const char*) glGetString(GL_SHADING_LANGUAGE_VERSION));
++//#include <GL/glxew.h>
+ #include <GLFW/glfw3.h>
+ #include "_prelude.h"
+ #include "input.h"
+ #include "logger.h"
+ #include "performance.h"
+ #include "render.h"
+ #include "ui.h"
+ // static const int EXIT_OK = 0;
+ static const int EXIT_LIB_FAIL = 1;
+ static const int EXIT_CTX_FAIL = 2;
+ static GLFWwindow* window;
+ static void onGlfwError(int error, const char* description);
+ void init(EngineConfig config) {
+       if (window) {
+               logError("init called more than once");
+               return;
+       }
+       logInfo("Assimp %u.%u", aiGetVersionMajor(), aiGetVersionMinor());
+       logInfo("GLEW %s", (const char*) glewGetString(GLEW_VERSION));
+       logInfo("GLFW %s", glfwGetVersionString());
+       glfwSetErrorCallback(onGlfwError);
+       if (!glfwInit()) {
+               logError("GLFW init failed");
+               exit(EXIT_LIB_FAIL);
+       }
+       // glutInitContextVersion(4,5); TODO establish correct context
+       // glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
+       // glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 5);
+       window = glfwCreateWindow(config.windowWidth,
+                                 config.windowHeight,
+                                 config.windowTitle.cstr,
+                                 NULL,
+                                 NULL);
+       if (!window) {
+               logError("Window or context creation failed");
+               glfwTerminate();
+               exit(EXIT_CTX_FAIL);
+       }
+       glfwMakeContextCurrent(window);
+       logInfo("OpenGL %s", (const char*) glGetString(GL_VERSION));
 -
++//    logInfo("GLSL %s", (const char*) glGetString(GL_SHADING_LANGUAGE_VERSION));
+       logInfo("Renderer: %s", (const char*) glGetString(GL_RENDERER));
 -
++/*
+       GLenum glewInitStatus = glewInit();
+       if (glewInitStatus != GLEW_OK) {
+               logError("GLEW init failed: %s", (const char*) glewGetErrorString(glewInitStatus));
+               exit(EXIT_LIB_FAIL);
+       }
++*/
+       logInfo("Setting swap interval: %d", config.swapInterval);
+       glfwSwapInterval(config.swapInterval);
+       int width, height;
+       glfwGetFramebufferSize(window, &width, &height);
+       resizeStage(window, width, height);
+       glfwSetFramebufferSizeCallback(window, resizeStage);
+       glfwSetKeyCallback(window, onKeyboardEvent);
+       initRender();
+       //initPerformanceMetering();
+ }
+ void run(void (*updateFn) (float)) {
+       if (!updateFn) {
+               logError("No update function provided");
+               return;
+       }
+       float lastTime = glfwGetTime();
+       float delta = 0.0f;
+       while (!glfwWindowShouldClose(window)) {
+               float time = glfwGetTime();
+               delta = time - lastTime;
+               lastTime = time;
+               updateFn(delta);
+               renderFrame(window);
+               glfwPollEvents();
+       }
+ }
+ void terminate() {
+       glfwTerminate();
+ }
+ EngineConfig defaultConfig() {
+       return (EngineConfig) { .windowWidth = 800,
+                               .windowHeight = 600,
+                               .windowTitle = newString(NULL),
+                               .swapInterval = 1 };
+ }
+ static void onGlfwError(int error UNUSED, const char* description) {
+       logError("GLFW error: %s", description);
+ }
index 0281087656c264b66e800efe7fd69e31b50136e3,616b971ce14e4c3fc067796b0a94cbfa81c2cfdc..5d43e16c189a1c95573dc27671d735ce9ef1b857
@@@ -66,10 -65,14 +65,14 @@@ static void renderScene(const Scene* sc
        Transform transform = multiply(scene->transform, baseTransform);
  
        glMatrixMode(GL_MODELVIEW);
 -      glLoadTransposeMatrixf((const GLfloat*) &transform);
 +      glLoadMatrixf((const GLfloat*) &transform);
  
        glDisable(GL_LIGHTING);
-       drawAxes();
+       if (debugScene || scene == playerProjectedMovement) {
+               drawAxes();
+       }
        glEnable(GL_LIGHTING);
  
        if (scene->solid) {
index 25ea9beccbf548ef21a2a799e5221011d7f58f02,f1b40a1061c45b5690d8d6731540991950e6f9da..e916360eb6ece4300c19d49e324ec48ab8045152
@@@ -1,5 -1,8 +1,11 @@@
- #ifndef RENDER_H_
- #define RENDER_H_
+ #ifndef ENGINE_RENDER_H_
+ #define ENGINE_RENDER_H_
+ #include <stdbool.h>
+ #include <GLFW/glfw3.h>
++#define  GL_GLEXT_PROTOTYPES
++#include <GL/glext.h>
++#undef GL_GLEXT_PROTOTYPES
  
  #include "scene.h"
  
Simple merge