62 lines
1.8 KiB
C
62 lines
1.8 KiB
C
#include "display.h"
|
|
|
|
#include <gint/display.h>
|
|
#include <stdlib.h>
|
|
#include "game.h"
|
|
#include "errors.h"
|
|
|
|
int vpos = 0;
|
|
|
|
inline int display_init(void)
|
|
{
|
|
return SUCCESS;
|
|
}
|
|
|
|
inline void display_exit(void)
|
|
{
|
|
#include <gint/keyboard.h>
|
|
dupdate();
|
|
getkey();
|
|
}
|
|
|
|
inline int display_clear(void)
|
|
{
|
|
dclear(C_WHITE);
|
|
return SUCCESS;
|
|
}
|
|
|
|
inline int display_update(void)
|
|
{
|
|
dupdate();
|
|
return SUCCESS;
|
|
}
|
|
|
|
inline int display_draw_texture(texture_t *texture, const rect_t *src_rect, const rect_t *dst_rect, bool flip)
|
|
{
|
|
rect_t display_rect;
|
|
if(dst_rect) display_rect = (rect_t) {
|
|
.x = (dst_rect->x - game.camera.view_rect.x) * (DISPLAY_WIDTH / game.camera.view_rect.w),
|
|
.y = (dst_rect->y - game.camera.view_rect.y) * (DISPLAY_HEIGHT / game.camera.view_rect.h),
|
|
.w = dst_rect->w * (DISPLAY_WIDTH / game.camera.view_rect.w),
|
|
.h = dst_rect->h * (DISPLAY_HEIGHT / game.camera.view_rect.h)
|
|
};
|
|
|
|
dsubimage_rgb16_effect(dst_rect ? display_rect.x : 0, dst_rect ? display_rect.y : 0, texture, (int)src_rect->x, (int)src_rect->y, (int)src_rect->w, (int)src_rect->h, flip ? IMAGE_HFLIP : DIMAGE_NONE);
|
|
|
|
return SUCCESS;
|
|
}
|
|
|
|
inline int display_draw_frect(const frect_t *frect, unsigned int r, unsigned int g, unsigned int b, unsigned int a)
|
|
{
|
|
rect_t display_rect = {
|
|
.x = (frect->x - game.camera.view_rect.x) * (DISPLAY_WIDTH / game.camera.view_rect.w),
|
|
.y = (frect->y - game.camera.view_rect.y) * (DISPLAY_HEIGHT / game.camera.view_rect.h),
|
|
.w = frect->w * (DISPLAY_WIDTH / game.camera.view_rect.w),
|
|
.h = frect->h * (DISPLAY_HEIGHT / game.camera.view_rect.h)
|
|
};
|
|
|
|
drect_border(display_rect.x, display_rect.y, (display_rect.x + display_rect.w), (display_rect.y + display_rect.h), C_NONE, 1, a ? C_RGB(r, g, b) : C_NONE);
|
|
|
|
return SUCCESS;
|
|
}
|