dp_doom: use 4 bytes per pixel and fix the colors
This commit is contained in:
parent
3c5b3ae4e9
commit
cbe6f76920
2 changed files with 17 additions and 6 deletions
|
@ -16,11 +16,11 @@ extern "C" {
|
|||
typedef pid_t doomid_t; // unique id for each doom instance
|
||||
typedef u16 dmt_t; // for DP_MessageType values
|
||||
|
||||
#define DoomScreenWidth 320u
|
||||
#define DoomScreenHeight 240u
|
||||
#define DoomBytesPerPixel 3u
|
||||
#define DoomFrameSize (DoomScreenWidth * DoomScreenHeight * DoomBytesPerPixel)
|
||||
#define DoomScreenWidth 320
|
||||
#define DoomScreenHeight 240
|
||||
#define DoomBytesPerPixel 4
|
||||
#define DoomFramePitch (DoomScreenWidth * DoomBytesPerPixel)
|
||||
#define DoomFrameSize (DoomScreenWidth * DoomScreenHeight * DoomBytesPerPixel)
|
||||
|
||||
typedef enum DP_MessageType
|
||||
{
|
||||
|
@ -66,7 +66,7 @@ typedef struct __attribute__((packed, aligned(4)))
|
|||
{
|
||||
MessageBase head;
|
||||
doomid_t doomId;
|
||||
u8 frame[DoomScreenWidth * DoomScreenHeight * DoomBytesPerPixel];
|
||||
u8 frame[DoomFrameSize];
|
||||
} MsgDoomFrame;
|
||||
|
||||
typedef struct __attribute__((packed, aligned(4)))
|
||||
|
|
|
@ -286,9 +286,19 @@ void IB_FinishUpdate (void)
|
|||
|
||||
void IB_GetColor(unsigned char *bytes, unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
#if DoomBytesPerPixel == 3
|
||||
// FIXME: might be buggy
|
||||
bytes[0] = red;
|
||||
bytes[1] = green;
|
||||
bytes[2] = blue;
|
||||
#elif DoomBytesPerPixel == 4
|
||||
bytes[0] = blue;
|
||||
bytes[1] = green;
|
||||
bytes[2] = red;
|
||||
bytes[3] = 0xff; // alpha?
|
||||
#else
|
||||
#error Unhandled DoomBytesPerPixel value. How to IB_GetColor?
|
||||
#endif
|
||||
}
|
||||
|
||||
static void I_Quit_Wrapper(int dummy)
|
||||
|
@ -302,6 +312,8 @@ static void I_Quit_Wrapper(int dummy)
|
|||
void IB_InitGraphics(const char *title, size_t screen_width, size_t screen_height, size_t *bytes_per_pixel)
|
||||
{
|
||||
(void) title;
|
||||
log_set_level(LOG_DEBUG);
|
||||
|
||||
g_frameBufferSize = screen_width * screen_height * DoomBytesPerPixel;
|
||||
assert(g_frameBufferSize == DoomFrameSize);
|
||||
g_frameBuffer = malloc(g_frameBufferSize);
|
||||
|
@ -313,7 +325,6 @@ void IB_InitGraphics(const char *title, size_t screen_width, size_t screen_heigh
|
|||
|
||||
signal(SIGINT, I_Quit_Wrapper);
|
||||
|
||||
log_set_level(LOG_DEBUG);
|
||||
|
||||
dp_nng_init_limits(1, 1, 1);
|
||||
|
||||
|
|
Loading…
Reference in a new issue