Managed to get compiling under ubuntu

This commit is contained in:
Dominic
2021-08-14 13:38:57 -07:00
parent 2d977e041c
commit 5cf7da5ee0
7 changed files with 39 additions and 22 deletions

View File

@ -22,6 +22,8 @@ set(SETTING_PLATFORM_GLFW 1)
set(SETTING_PLATFORM_SDL 2)
set(SETTING_PLATFORM SETTING_PLATFORM_SDL)
set(SETTING_USE_GLAD 0)
# Game Settings
set(SETTING_GAME_POKER 1)
set(SETTING_GAME_DAWN 2)
@ -66,11 +68,18 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_executable(${PROJECT_NAME} ${HEADER_FILES} ${SOURCE_FILES})
################################# STATIC LIBS ##################################
# GLFW and GLAD
if(${SETTING_PLATFORM} EQUAL ${SETTING_PLATFORM_GLFW})
# Math
target_link_libraries(${PROJECT_NAME} m)
# GLAD
if(${SETTING_USE_GLAD} EQUAL 1)
add_subdirectory(${CMAKE_SOURCE_DIR}/lib/glad)
target_link_libraries(${PROJECT_NAME} glad)
endif()
# GLFW and GLAD
if(${SETTING_PLATFORM} EQUAL ${SETTING_PLATFORM_GLFW})
if(NOT glfw3_FOUND)
FetchContent_Declare(
glfw
@ -84,8 +93,8 @@ endif()
# SDL
if(${SETTING_PLATFORM} EQUAL ${SETTING_PLATFORM_SDL})
add_subdirectory(${CMAKE_SOURCE_DIR}/lib/glad)
target_link_libraries(${PROJECT_NAME} glad)
# add_subdirectory(${CMAKE_SOURCE_DIR}/lib/glad)
# target_link_libraries(${PROJECT_NAME} glad)
find_package(SDL2 REQUIRED)
include_directories(${SDL2_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} ${SDL2_LIBRARIES})

View File

@ -10,6 +10,8 @@
#cmakedefine SETTING_PLATFORM_SDL @SETTING_PLATFORM_SDL@
#cmakedefine SETTING_PLATFORM @SETTING_PLATFORM@
#cmakedefine SETTING_USE_GLAD @SETTING_USE_GLAD@
// Game Settings
#cmakedefine SETTING_GAME_POKER @SETTING_GAME_POKER@
#cmakedefine SETTING_GAME_DAWN @SETTING_GAME_DAWN@

View File

@ -11,10 +11,12 @@
// Static Libs
#include <cglm/cglm.h>
#if SETTING_USE_GLAD == 1
#include <glad/glad.h>
#endif
#if SETTING_PLATFORM == SETTING_PLATFORM_GLFW
#include <glad/glad.h>
#elif SETTING_PLATFORM == SETTING_PLATFORM_SDL
#include <glad/glad.h>
#include <SDL.h>
#include <SDL_opengl.h>
#include <SDL_opengles2.h>
@ -29,6 +31,7 @@
#include <stdbool.h>
#include <malloc.h>
#include <string.h>
#include <math.h>
#if defined(_WIN32) || defined(_WIN64)
// Windows Fixes

View File

@ -6,7 +6,9 @@
#pragma once
// I load GLAD and GLFW Here because they need to be included in specific orders
#if SETTING_USE_GLAD == 1
#include <glad/glad.h>
#endif
#include <GLFW/glfw3.h>
#include <dawn/dawn.h>
#include "../../src/display/render.h"

View File

@ -9,7 +9,7 @@
game_t *GAME_STATE;
int main(int argc, char *argv[]) {
int32_t main(int32_t argc, char *argv[]) {
game_t *game;
input_t *input;
SDL_GLContext context;
@ -57,11 +57,13 @@ int main(int argc, char *argv[]) {
return 1;
}
#if SETTING_USE_GLAD == 1
// Load glad
if (!gladLoadGLLoader((GLADloadproc) SDL_GL_GetProcAddress)) {
printf("Failed to initialize the OpenGL context.\n");
return 1;
}
#endif
// Bind the GL Context
SDL_GL_MakeCurrent(displayWindow, context);

View File

@ -7,10 +7,6 @@
#pragma once
#include <dawn/dawn.h>
#include <glad/glad.h>
#include <SDL.h>
#include <SDL_opengl.h>
#include <SDL_opengles2.h>
#include "../../src/display/render.h"
#include "../../src/game/game.h"
#include "../../src/input/input.h"
@ -21,4 +17,4 @@
#define OPENGL_MAJOR_VERSION 2
#define OPENGL_MINOR_VERSION 1
int main(int argc, char *argv[]);
int32_t main(int32_t argc, char *argv[]);

View File

@ -14,9 +14,12 @@ void shaderInit(shader_t *shader,
char *error;
GLuint shaderVertex, shaderFragment, shaderProgram;
GLchar const* filesVertex[] = { vertexShaderSource };
GLchar const* filesFragment[] = { fragmentShaderSource };
// Load the vertex shader first
shaderVertex = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(shaderVertex, 1, &vertexShaderSource, 0);
glShaderSource(shaderVertex, 1, filesVertex, 0);
glCompileShader(shaderVertex);
// Validate
@ -32,7 +35,7 @@ void shaderInit(shader_t *shader,
// Now load the Frag shader
shaderFragment = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(shaderFragment, 1, &fragmentShaderSource, 0);
glShaderSource(shaderFragment, 1, filesFragment, 0);
glCompileShader(shaderFragment);
glGetShaderiv(shaderFragment, GL_COMPILE_STATUS, &isSuccess);
if(!isSuccess) {