refactor file structure
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
#include <dangerzone/engine.h>
|
||||
#include <dangerzone/render/misc.h>
|
||||
#include <dangerzone/render/rect.h>
|
||||
|
||||
#include "internal/util/error.h"
|
||||
#include <stdint.h>
|
||||
|
||||
// alter a pixel at an imaginary x & y coordinates
|
||||
void
|
||||
put_pixel(
|
||||
unsigned int x,
|
||||
unsigned int y,
|
||||
uint32_t color
|
||||
) {
|
||||
uint16_t w = game_state->width;
|
||||
uint16_t h = game_state->height;
|
||||
|
||||
if (x < 0 || x >= w || y < 0 || y >= h) {
|
||||
eprintf(
|
||||
"CRITICAL: attempted buffer overflow in put_pixel\n"
|
||||
"at x = %d, y = %d", x, y
|
||||
);
|
||||
} else {
|
||||
game_state->framebuffer[game_state->width * y + x]
|
||||
= color;
|
||||
|
||||
mark_dirty_rect(x, y, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// fill the entire framebuffer with a given color
|
||||
void
|
||||
clear_framebuffer(
|
||||
uint32_t color
|
||||
) {
|
||||
for (size_t i = 0;
|
||||
i < (size_t)game_state->width * game_state->height;
|
||||
++i) {
|
||||
game_state->framebuffer[i] = color;
|
||||
}
|
||||
|
||||
mark_dirty_rect(
|
||||
0,
|
||||
0,
|
||||
game_state->width,
|
||||
game_state->height
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user