fill out some of the doom implementation

This commit is contained in:
oxmox 2023-02-19 03:08:56 +01:00
parent 777d766035
commit 0e7eb1f5b8
3 changed files with 31 additions and 3 deletions

View file

@ -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)

View file

@ -20,7 +20,7 @@ int IB_GetTime (void)
//
void IB_Init (void)
{
SDL_Init(0);
SDL_Init(SDL_INIT_TIMER);
}

View file

@ -22,7 +22,9 @@
//
//-----------------------------------------------------------------------------
#include <signal.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
@ -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;
}