Browse Source

Build with raylib of ncurses. Not sure about this.

This seems like a big overhead. I think I will focus on one target and
keep the possibility to work on another later.
main
KikooDX 10 months ago
parent
commit
c559481af9
  1. 27
      CMakeLists.txt
  2. 7
      include/conf.h
  3. 6
      include/renderer/init.h
  4. 4
      src/main.c
  5. 21
      src/ncurses/init.c
  6. 14
      src/raylib/init.c

27
CMakeLists.txt

@ -1,5 +1,6 @@
cmake_minimum_required(VERSION 3.18)
project(kblec C)
# Add render targets here.
project(kble C)
include_directories(include)
@ -8,10 +9,26 @@ set(SOURCES
src/level.c
)
add_executable(${PROJECT_NAME} ${SOURCES})
target_compile_options(${PROJECT_NAME} PRIVATE
set(SOURCES_NCURSES
src/ncurses/init.c
)
set(SOURCES_RAYLIB
src/raylib/init.c
)
set(FLAGS
-Wall -Wextra -Wshadow -Wswitch-default -Wswitch-enum
-Wunreachable-code -Wstrict-prototypes -Wmissing-prototypes
-Wold-style-definition -Werror-implicit-function-declaration
-ansi -pedantic-errors -g -Os)
#target_link_libraries(${PROJECT_NAME} raylib)
-g -Os
)
add_executable(kble-ncurses ${SOURCES} ${SOURCES_NCURSES})
add_executable(kble-raylib ${SOURCES} ${SOURCES_RAYLIB})
target_compile_options(kble-ncurses PRIVATE ${FLAGS} -DNCURSES)
target_compile_options(kble-raylib PRIVATE ${FLAGS} -DRAYLIB)
target_link_libraries(kble-ncurses ncurses)
target_link_libraries(kble-raylib raylib)

7
include/conf.h

@ -0,0 +1,7 @@
#pragma once
#if defined(RAYLIB)
# define WINDOW_WIDTH 640
# define WINDOW_HEIGHT 480
# define TARGET_FPS 60
#endif

6
include/renderer/init.h

@ -0,0 +1,6 @@
#pragma once
/* Initialize renderer. */
void renderer_init(void);
/* Deinitialize renderer. */
void renderer_deinit(void);

4
src/main.c

@ -5,6 +5,7 @@
#include <stdlib.h>
#include "level.h"
#include "renderer/init.h"
int main(int argc, char **argv) {
struct Level level;
@ -16,8 +17,11 @@ int main(int argc, char **argv) {
}
level_read(&level, argv[1]);
renderer_init();
level_write(level, argv[2]);
level_free(&level);
renderer_deinit();
return EXIT_SUCCESS;
}

21
src/ncurses/init.c

@ -0,0 +1,21 @@
#include <locale.h>
#include <ncurses.h>
#include <unistd.h>
#include "renderer/init.h"
void renderer_init(void) {
setlocale(LC_ALL, "");
initscr();
cbreak();
noecho();
nonl();
intrflush(stdscr, FALSE);
keypad(stdscr, TRUE);
curs_set(TRUE);
}
void renderer_deinit(void) {
endwin();
}

14
src/raylib/init.c

@ -0,0 +1,14 @@
#include <raylib.h>
#include "conf.h"
#include "renderer/init.h"
void renderer_init(void) {
InitWindow(WINDOW_WIDTH, WINDOW_HEIGHT, "KBLE");
SetTargetFPS(TARGET_FPS);
}
void renderer_deinit(void) {
CloseWindow();
}
Loading…
Cancel
Save