return render_res;
}
+#define U_SCREEN_W 1280
+#define U_SCREEN_H 720
+
+struct u_vec2 lrts_get_screen_res(void) {
+ struct lrts_config *cfg = lrts_cfg();
+
+ struct u_vec2 screen_res = cfg->screen_res;
+ if (screen_res.x == 0) {
+ screen_res.x = U_SCREEN_W;
+ }
+ if (screen_res.y == 0) {
+ screen_res.y = U_SCREEN_H;
+ }
+ return screen_res;
+}
+
int lrts_main(int argc, char **argv) {
p_io_init();
lrts_getopt(argc, argv, lrts_cfg());
void p_draw_present(void) {
SDL_Surface* screen = SDL_GetWindowSurface(p_main_window);
- SDL_BlitSurface(r_target, NULL, screen, NULL);
+ SDL_Rect dst;
+
+ dst.x = 0;
+ dst.y = 0;
+ dst.w = screen->w;
+ dst.h = screen->h;
+
+ SDL_BlitSurfaceScaled(r_target, NULL, screen, &dst, SDL_SCALEMODE_PIXELART);
SDL_UpdateWindowSurface(p_main_window);
}
#include "p_window.c"
+#define DEFAULT_COLOR 0x222222FF
+
int p_render_init(void) {
struct lrts_config *cfg = lrts_cfg();
- struct u_vec2 target_res = lrts_get_render_res();
+ struct u_vec2 target_res = lrts_get_screen_res();
if (!SDL_Init(SDL_INIT_VIDEO)) {
u_log(U_LOG_ERR, "Failed to init video: %s\n",
exit(-1);
}
-
+ SDL_FillSurfaceRect(SDL_GetWindowSurface(p_main_window), NULL, DEFAULT_COLOR);
u_log(U_LOG_DEBUG, "Init successful\n");
return 0;
u_log(U_LOG_ERR, "Failed to create surface: %s\n", SDL_GetError());
exit(-1);
}
+
+ SDL_FillSurfaceRect(r_target, NULL, DEFAULT_COLOR);
r_framebuffer.pixels = r_target->pixels;
r_framebuffer.width = r_target->w;
const char *name;
struct u_vec2 render_res;
+ struct u_vec2 screen_res;
char **argv;
int argc;
*/
struct u_vec2 lrts_get_render_res(void);
+/**
+ * Returns the screen resolution
+ */
+struct u_vec2 lrts_get_screen_res(void);
+
#define LRTS_UNUSED(x) (void)(x)