diff --git a/src/dp_doom/CMakeLists.txt b/src/dp_doom/CMakeLists.txt index 5272018..0bbb08c 100644 --- a/src/dp_doom/CMakeLists.txt +++ b/src/dp_doom/CMakeLists.txt @@ -214,8 +214,8 @@ elseif(BACKEND STREQUAL "SDL2") elseif(BACKEND STREQUAL "nng") target_sources(dp_doom PRIVATE "linuxdoom-1.10/ib_sound/sdl.c" - "linuxdoom-1.10/ib_system/nng.c" - "linuxdoom-1.10/ib_video/nng.c" + "linuxdoom-1.10/ib_system/ib_system_nng.c" + "linuxdoom-1.10/ib_video/ib_video_nng.c" ) find_package(SDL2 REQUIRED) diff --git a/src/dp_doom/linuxdoom-1.10/ib_system/nng.c b/src/dp_doom/linuxdoom-1.10/ib_system/ib_system_nng.c similarity index 93% rename from src/dp_doom/linuxdoom-1.10/ib_system/nng.c rename to src/dp_doom/linuxdoom-1.10/ib_system/ib_system_nng.c index 5b18297..88546bc 100644 --- a/src/dp_doom/linuxdoom-1.10/ib_system/nng.c +++ b/src/dp_doom/linuxdoom-1.10/ib_system/ib_system_nng.c @@ -20,7 +20,7 @@ int IB_GetTime (void) // void IB_Init (void) { - SDL_Init(0); + SDL_Init(SDL_INIT_TIMER); } diff --git a/src/dp_doom/linuxdoom-1.10/ib_video/nng.c b/src/dp_doom/linuxdoom-1.10/ib_video/ib_video_nng.c similarity index 70% rename from src/dp_doom/linuxdoom-1.10/ib_video/nng.c rename to src/dp_doom/linuxdoom-1.10/ib_video/ib_video_nng.c index 8ebb53f..16f898b 100644 --- a/src/dp_doom/linuxdoom-1.10/ib_video/nng.c +++ b/src/dp_doom/linuxdoom-1.10/ib_video/ib_video_nng.c @@ -22,7 +22,9 @@ // //----------------------------------------------------------------------------- +#include #include +#include #include #include @@ -36,6 +38,12 @@ #include "../ib_video.h" +#define BYTES_PER_PIXEL 3 + +//uint8_t frameBuffer[SCREENWIDTH * SCREENHEIGHT * BYTES_PER_PIXEL]; +static uint8_t *g_frameBuffer; +static size_t g_pitch; + // // IB_StartTic // @@ -45,6 +53,8 @@ void IB_StartTic (void) void IB_GetFramebuffer(unsigned char **pixels, size_t *pitch) { + *pixels = g_frameBuffer; + *pitch = g_pitch; } void IB_FinishUpdate (void) @@ -53,16 +63,34 @@ void IB_FinishUpdate (void) void IB_GetColor(unsigned char *bytes, unsigned char red, unsigned char green, unsigned char blue) { + bytes[0] = red; + bytes[1] = green; + bytes[2] = blue; +} + +static void I_Quit_Wrapper(int dummy) +{ + (void)dummy; + + I_Quit(); } void IB_InitGraphics(const char *title, size_t screen_width, size_t screen_height, size_t *bytes_per_pixel) { + (void) title; + g_frameBuffer = malloc(screen_width * screen_height * BYTES_PER_PIXEL); + g_pitch = screen_width * BYTES_PER_PIXEL; + *bytes_per_pixel = BYTES_PER_PIXEL; + + signal(SIGINT, I_Quit_Wrapper); } void IB_ShutdownGraphics(void) { + free(g_frameBuffer); } void IB_GrabMouse(boolean grab) { + (void) grab; }