Update trying for a Windows baby
This commit is contained in:
parent
9f36c38570
commit
e184b1c910
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -19,3 +19,6 @@
|
|||||||
[submodule "include/imgui"]
|
[submodule "include/imgui"]
|
||||||
path = include/imgui
|
path = include/imgui
|
||||||
url = https://github.com/ocornut/imgui
|
url = https://github.com/ocornut/imgui
|
||||||
|
[submodule "include/CLog"]
|
||||||
|
path = include/CLog
|
||||||
|
url = https://github.com/williamistGitHub/CLog.git
|
||||||
|
@ -19,17 +19,27 @@ if(CMAKE_BIANRY_DIR MATCHES " ")
|
|||||||
message("Spaces in the build dir can cause errors, thou art been warned")
|
message("Spaces in the build dir can cause errors, thou art been warned")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(LINUX)
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT ${PROJECT_SOURCE_DIR}/include/glew/src/glew.c
|
OUTPUT ${PROJECT_SOURCE_DIR}/include/glew/src/glew.c
|
||||||
${PROJECT_SOURCE_DIR}/include/glewinfo.c
|
${PROJECT_SOURCE_DIR}/include/glewinfo.c
|
||||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/include/glew/auto
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/include/glew/auto
|
||||||
COMMAND ${CMAKE_MAKE_PROGRAM})
|
COMMAND ${CMAKE_MAKE_PROGRAM})
|
||||||
|
endif()
|
||||||
|
if(WIN32)
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${PROJECT_SOURCE_DIR}/include (glew) /src/glew.c
|
||||||
|
${PROJECT_SOURCE_DIR}/include/glewinfo.c
|
||||||
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/include/glew/build/vc15
|
||||||
|
COMMAND ${CMAKE_VS_MSBUILD_COMMAND})
|
||||||
|
endif()
|
||||||
|
|
||||||
add_subdirectory(include/glm)
|
add_subdirectory(include/glm)
|
||||||
add_subdirectory(include/glew/build/cmake)
|
add_subdirectory(include/glew/build/cmake)
|
||||||
add_subdirectory(include/glfw)
|
add_subdirectory(include/glfw)
|
||||||
add_subdirectory(include/SOIL2)
|
add_subdirectory(include/SOIL2)
|
||||||
add_subdirectory(include/assimp)
|
add_subdirectory(include/assimp)
|
||||||
|
add_subdirectory(include/CLog)
|
||||||
|
|
||||||
include_directories(include/imgui)
|
include_directories(include/imgui)
|
||||||
add_library(
|
add_library(
|
||||||
@ -52,4 +62,5 @@ target_link_libraries(
|
|||||||
glfw
|
glfw
|
||||||
soil2
|
soil2
|
||||||
assimp
|
assimp
|
||||||
imgui)
|
imgui
|
||||||
|
clog)
|
||||||
|
13
engine.cpp
13
engine.cpp
@ -9,6 +9,7 @@
|
|||||||
#include <glm/gtc/matrix_transform.hpp>
|
#include <glm/gtc/matrix_transform.hpp>
|
||||||
#include <glm/trigonometric.hpp>
|
#include <glm/trigonometric.hpp>
|
||||||
|
|
||||||
|
#include <clog/clog.h>
|
||||||
#include <backends/imgui_impl_glfw.h>
|
#include <backends/imgui_impl_glfw.h>
|
||||||
#include <backends/imgui_impl_opengl3.h>
|
#include <backends/imgui_impl_opengl3.h>
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
@ -28,7 +29,7 @@ extern "C" {
|
|||||||
#define HEIGHT 768
|
#define HEIGHT 768
|
||||||
|
|
||||||
static void glfwErrorCallback(int e, const char *description) {
|
static void glfwErrorCallback(int e, const char *description) {
|
||||||
fprintf(stderr, "GLFW Error %d: %s", e, description);
|
clog_log(CLOG_LEVEL_ERROR, "GLFW Error %d: %s", e, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool loadModel(const char *path, std::vector<unsigned short> &indices,
|
bool loadModel(const char *path, std::vector<unsigned short> &indices,
|
||||||
@ -40,7 +41,7 @@ bool loadModel(const char *path, std::vector<unsigned short> &indices,
|
|||||||
path, aiProcess_Triangulate | aiProcess_JoinIdenticalVertices |
|
path, aiProcess_Triangulate | aiProcess_JoinIdenticalVertices |
|
||||||
aiProcess_SortByPType);
|
aiProcess_SortByPType);
|
||||||
if (!scene) {
|
if (!scene) {
|
||||||
fprintf(stderr, "%s\n", importer.GetErrorString());
|
clog_log(CLOG_LEVEL_ERROR, "%s", importer.GetErrorString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const aiMesh *mesh = scene->mMeshes[0];
|
const aiMesh *mesh = scene->mMeshes[0];
|
||||||
@ -72,7 +73,7 @@ int initWindow() {
|
|||||||
|
|
||||||
glewExperimental = true;
|
glewExperimental = true;
|
||||||
if (!glfwInit()) {
|
if (!glfwInit()) {
|
||||||
fprintf(stderr, "GLFW went shitty time\n");
|
clog_log(CLOG_LEVEL_ERROR, "GLFW went shitty time (failed to init)");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +86,7 @@ int initWindow() {
|
|||||||
GLFWwindow *window;
|
GLFWwindow *window;
|
||||||
window = glfwCreateWindow(WIDTH, HEIGHT, "Fred", NULL, NULL);
|
window = glfwCreateWindow(WIDTH, HEIGHT, "Fred", NULL, NULL);
|
||||||
if (window == NULL) {
|
if (window == NULL) {
|
||||||
fprintf(stderr, "Failed to open window.\n");
|
clog_log(CLOG_LEVEL_ERROR, "Failed to open window.");
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -94,7 +95,7 @@ int initWindow() {
|
|||||||
glfwSwapInterval(1);
|
glfwSwapInterval(1);
|
||||||
int code;
|
int code;
|
||||||
if ((code = glewInit()) != GLEW_OK) {
|
if ((code = glewInit()) != GLEW_OK) {
|
||||||
fprintf(stderr, "Failed to init GLEW: %s\n", glewGetErrorString(code));
|
clog_log(CLOG_LEVEL_ERROR, "Failed to init GLEW: %s", glewGetErrorString(code));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,7 +153,7 @@ int initWindow() {
|
|||||||
SOIL_CREATE_NEW_ID,
|
SOIL_CREATE_NEW_ID,
|
||||||
SOIL_FLAG_MIPMAPS | SOIL_FLAG_NTSC_SAFE_RGB | SOIL_FLAG_COMPRESS_TO_DXT);
|
SOIL_FLAG_MIPMAPS | SOIL_FLAG_NTSC_SAFE_RGB | SOIL_FLAG_COMPRESS_TO_DXT);
|
||||||
if (texture == 0) {
|
if (texture == 0) {
|
||||||
printf("Texture failed to load\n");
|
clog_log(CLOG_LEVEL_WARN, "Texture failed to load");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
1
include/CLog
Submodule
1
include/CLog
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 5a8dc48b060619da1b6fbbacd18630c4d2c92182
|
24
shader.c
24
shader.c
@ -3,7 +3,15 @@
|
|||||||
|
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
#ifdef __linux__
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <io.h>
|
||||||
|
#define lseek _lseek
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <clog/clog.h>
|
||||||
|
|
||||||
GLuint loadShaders(const char *vertex_file_path,
|
GLuint loadShaders(const char *vertex_file_path,
|
||||||
const char *fragment_file_path) {
|
const char *fragment_file_path) {
|
||||||
@ -14,7 +22,7 @@ GLuint loadShaders(const char *vertex_file_path,
|
|||||||
vertexShaderFD = fopen(vertex_file_path, "rb");
|
vertexShaderFD = fopen(vertex_file_path, "rb");
|
||||||
if (vertexShaderFD == NULL) {
|
if (vertexShaderFD == NULL) {
|
||||||
fclose(vertexShaderFD);
|
fclose(vertexShaderFD);
|
||||||
fprintf(stderr, "Failed to open Vertex Shader");
|
clog_log(CLOG_LEVEL_ERROR, "Failed to open Vertex Shader");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
int vertexShaderLength = lseek(fileno(vertexShaderFD), 0L, SEEK_END) + 1;
|
int vertexShaderLength = lseek(fileno(vertexShaderFD), 0L, SEEK_END) + 1;
|
||||||
@ -28,7 +36,7 @@ GLuint loadShaders(const char *vertex_file_path,
|
|||||||
fragmentShaderFD = fopen(fragment_file_path, "rb");
|
fragmentShaderFD = fopen(fragment_file_path, "rb");
|
||||||
if (fragmentShaderFD == NULL) {
|
if (fragmentShaderFD == NULL) {
|
||||||
fclose(fragmentShaderFD);
|
fclose(fragmentShaderFD);
|
||||||
fprintf(stderr, "Failed to open Fragment Shader");
|
clog_log(CLOG_LEVEL_ERROR, "Failed to open Fragment Shader");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
int fragmentShaderLength = lseek(fileno(fragmentShaderFD), 0L, SEEK_END) + 1;
|
int fragmentShaderLength = lseek(fileno(fragmentShaderFD), 0L, SEEK_END) + 1;
|
||||||
@ -41,7 +49,7 @@ GLuint loadShaders(const char *vertex_file_path,
|
|||||||
GLint result = GL_FALSE;
|
GLint result = GL_FALSE;
|
||||||
int infoLogLength;
|
int infoLogLength;
|
||||||
|
|
||||||
printf("Compiling shader: %s\n", vertex_file_path);
|
clog_log(CLOG_LEVEL_DEBUG, "Compiling shader: %s", vertex_file_path);
|
||||||
char const *vertexShaderCodeConst = vertexShaderCode;
|
char const *vertexShaderCodeConst = vertexShaderCode;
|
||||||
glShaderSource(vertexShaderID, 1, &vertexShaderCodeConst, NULL);
|
glShaderSource(vertexShaderID, 1, &vertexShaderCodeConst, NULL);
|
||||||
glCompileShader(vertexShaderID);
|
glCompileShader(vertexShaderID);
|
||||||
@ -52,10 +60,10 @@ GLuint loadShaders(const char *vertex_file_path,
|
|||||||
char *vertexShaderErrorMessage[infoLogLength + 1];
|
char *vertexShaderErrorMessage[infoLogLength + 1];
|
||||||
glGetShaderInfoLog(vertexShaderID, infoLogLength, NULL,
|
glGetShaderInfoLog(vertexShaderID, infoLogLength, NULL,
|
||||||
*vertexShaderErrorMessage);
|
*vertexShaderErrorMessage);
|
||||||
printf("%s\n", *vertexShaderErrorMessage);
|
clog_log(CLOG_LEVEL_ERROR, "%s", *vertexShaderErrorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Compiling shader: %s\n", fragment_file_path);
|
clog_log(CLOG_LEVEL_DEBUG, "Compiling shader: %s", fragment_file_path);
|
||||||
char const *fragmentShaderCodeConst = fragmentShaderCode;
|
char const *fragmentShaderCodeConst = fragmentShaderCode;
|
||||||
glShaderSource(fragmentShaderID, 1, &fragmentShaderCodeConst, NULL);
|
glShaderSource(fragmentShaderID, 1, &fragmentShaderCodeConst, NULL);
|
||||||
glCompileShader(fragmentShaderID);
|
glCompileShader(fragmentShaderID);
|
||||||
@ -66,10 +74,10 @@ GLuint loadShaders(const char *vertex_file_path,
|
|||||||
char *fragmentShaderErrorMessage[infoLogLength + 1];
|
char *fragmentShaderErrorMessage[infoLogLength + 1];
|
||||||
glGetShaderInfoLog(fragmentShaderID, infoLogLength, NULL,
|
glGetShaderInfoLog(fragmentShaderID, infoLogLength, NULL,
|
||||||
*fragmentShaderErrorMessage);
|
*fragmentShaderErrorMessage);
|
||||||
printf("%s\n", *fragmentShaderErrorMessage);
|
clog_log(CLOG_LEVEL_ERROR, "%s", *fragmentShaderErrorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Linking program\n");
|
clog_log(CLOG_LEVEL_DEBUG, "Linking shader program");
|
||||||
GLuint programID = glCreateProgram();
|
GLuint programID = glCreateProgram();
|
||||||
glAttachShader(programID, vertexShaderID);
|
glAttachShader(programID, vertexShaderID);
|
||||||
glAttachShader(programID, fragmentShaderID);
|
glAttachShader(programID, fragmentShaderID);
|
||||||
@ -80,7 +88,7 @@ GLuint loadShaders(const char *vertex_file_path,
|
|||||||
if (infoLogLength > 0) {
|
if (infoLogLength > 0) {
|
||||||
char *programErrorMessage[infoLogLength + 1];
|
char *programErrorMessage[infoLogLength + 1];
|
||||||
glGetProgramInfoLog(programID, infoLogLength, NULL, *programErrorMessage);
|
glGetProgramInfoLog(programID, infoLogLength, NULL, *programErrorMessage);
|
||||||
printf("%s\n", *programErrorMessage);
|
clog_log(CLOG_LEVEL_ERROR, "%s", *programErrorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
glDetachShader(programID, vertexShaderID);
|
glDetachShader(programID, vertexShaderID);
|
||||||
|
Loading…
Reference in New Issue
Block a user