Setup library for actual use
This commit is contained in:
@@ -2,11 +2,5 @@ cmake_minimum_required(VERSION 3.0)
|
|||||||
|
|
||||||
project(Hydrogen)
|
project(Hydrogen)
|
||||||
|
|
||||||
find_package(SDL2 REQUIRED)
|
add_subdirectory(lib)
|
||||||
|
add_subdirectory(games)
|
||||||
set(SOURCE
|
|
||||||
src/main.c)
|
|
||||||
|
|
||||||
add_executable(Hydrogen ${SOURCE})
|
|
||||||
target_include_directories(Hydrogen PRIVATE ${SDL2_INCLUDE_DIRS})
|
|
||||||
target_link_libraries(Hydrogen PRIVATE ${SDL2_LIBRARIES})
|
|
||||||
|
|||||||
1
games/CMakeLists.txt
Normal file
1
games/CMakeLists.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
add_subdirectory(example)
|
||||||
6
games/example/CMakeLists.txt
Normal file
6
games/example/CMakeLists.txt
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
set(SOURCE
|
||||||
|
src/main.c)
|
||||||
|
|
||||||
|
add_executable(example ${SOURCE})
|
||||||
|
target_include_directories(example PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||||
|
target_link_libraries(example PRIVATE Hydrogen)
|
||||||
7
games/example/src/main.c
Normal file
7
games/example/src/main.c
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#include <hydrogen/hydrogen.h>
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
test();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
13
lib/CMakeLists.txt
Normal file
13
lib/CMakeLists.txt
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.0)
|
||||||
|
|
||||||
|
project(Hydrogen)
|
||||||
|
|
||||||
|
find_package(SDL2 REQUIRED)
|
||||||
|
|
||||||
|
set(SOURCE
|
||||||
|
src/hydrogen.c)
|
||||||
|
|
||||||
|
add_library(Hydrogen STATIC ${SOURCE})
|
||||||
|
target_include_directories(Hydrogen PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||||
|
target_include_directories(Hydrogen PRIVATE ${SDL2_INCLUDE_DIRS})
|
||||||
|
target_link_libraries(Hydrogen PRIVATE ${SDL2_LIBRARIES})
|
||||||
6
lib/include/hydrogen/constants.h
Normal file
6
lib/include/hydrogen/constants.h
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#ifndef HYDROGEN_CONSTANTS_H
|
||||||
|
#define HYDROGEN_CONSTANTS_H
|
||||||
|
|
||||||
|
// TODO: Put stuff here lol
|
||||||
|
|
||||||
|
#endif//HYDROGEN_CONSTANTS_H
|
||||||
36
lib/include/hydrogen/hydrogen.h
Normal file
36
lib/include/hydrogen/hydrogen.h
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
#ifndef HYDROGEN_MAIN_INC_H
|
||||||
|
#define HYDROGEN_MAIN_INC_H
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
extern unsigned int HYDROGEN_VERSION_MAJOR;
|
||||||
|
extern unsigned int HYDROGEN_VERSION_MINOR;
|
||||||
|
extern unsigned int HYDROGEN_VERSION_PATCH;
|
||||||
|
|
||||||
|
#include<hydrogen/constants.h>
|
||||||
|
|
||||||
|
/* Common Typedefs using Rust idioms because why not? */
|
||||||
|
typedef uint_least8_t u8;
|
||||||
|
typedef uint_least16_t u16;
|
||||||
|
typedef uint_least32_t u32;
|
||||||
|
typedef uint_least64_t u64;
|
||||||
|
typedef int_least8_t i8;
|
||||||
|
typedef int_least16_t i16;
|
||||||
|
typedef int_least32_t i32;
|
||||||
|
typedef int_least64_t i64;
|
||||||
|
typedef size_t usize;
|
||||||
|
|
||||||
|
typedef float f32;
|
||||||
|
typedef double f64;
|
||||||
|
|
||||||
|
#ifdef HYDROGEN_REAL_FLOAT
|
||||||
|
typedef f32 real;
|
||||||
|
#else
|
||||||
|
typedef f64 real;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void test();
|
||||||
|
|
||||||
|
|
||||||
|
#endif//HYDROGEN_MAIN_INC_H
|
||||||
9
lib/src/hydrogen.c
Normal file
9
lib/src/hydrogen.c
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#include <hydrogen/hydrogen.h>
|
||||||
|
|
||||||
|
unsigned int HYDROGEN_VERSION_MAJOR = 0;
|
||||||
|
unsigned int HYDROGEN_VERSION_MINOR = 1;
|
||||||
|
unsigned int HYDROGEN_VERSION_PATCH = 0;
|
||||||
|
|
||||||
|
void test() {
|
||||||
|
puts("This is a test.");
|
||||||
|
}
|
||||||
27
src/main.c
27
src/main.c
@@ -1,27 +0,0 @@
|
|||||||
#include "SDL.h"
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
SDL_Init(SDL_INIT_VIDEO);
|
|
||||||
|
|
||||||
SDL_Window *window = SDL_CreateWindow(
|
|
||||||
"SDL2Test",
|
|
||||||
SDL_WINDOWPOS_UNDEFINED,
|
|
||||||
SDL_WINDOWPOS_UNDEFINED,
|
|
||||||
640,
|
|
||||||
480,
|
|
||||||
0
|
|
||||||
);
|
|
||||||
|
|
||||||
SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_SOFTWARE);
|
|
||||||
SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE);
|
|
||||||
SDL_RenderClear(renderer);
|
|
||||||
SDL_RenderPresent(renderer);
|
|
||||||
|
|
||||||
SDL_Delay(3000);
|
|
||||||
|
|
||||||
SDL_DestroyWindow(window);
|
|
||||||
SDL_Quit();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user