Skip to content

Commit

Permalink
Video enum cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
katajakasa committed May 2, 2023
1 parent b7592e0 commit 1e3c784
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
8 changes: 4 additions & 4 deletions src/video/enums.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#ifndef VIDEO_ENUMS_H
#define VIDEO_ENUMS_H

enum VIDEO_BLEND_MODE
typedef enum
{
BLEND_ADDITIVE = 0,
BLEND_ALPHA
};
} VIDEO_BLEND_MODE;

enum VIDEO_FLIP_MODE
typedef enum
{
FLIP_NONE = 0,
FLIP_HORIZONTAL = 0x1,
FLIP_VERTICAL = 0x2,
};
} VIDEO_FLIP_MODE;

#endif // VIDEO_ENUMS_H
18 changes: 7 additions & 11 deletions src/video/video.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ void video_render_background(surface *sur) {
}
}

static void render_sprite_fsot(video_state *state, surface *sur, SDL_Rect *dst, SDL_BlendMode blend_mode,
static void render_sprite_fsot(video_state *state, surface *sur, SDL_Rect *dst, VIDEO_BLEND_MODE blend_mode,
int pal_offset, unsigned int flip_mode, uint8_t opacity, color color_mod) {

uint16_t tx, ty, tw, th;
Expand All @@ -234,15 +234,14 @@ void video_render_sprite_tint(surface *sur, int sx, int sy, color c, int pal_off
}

// Wrapper
void video_render_sprite(surface *sur, int sx, int sy, unsigned int rendering_mode, int pal_offset) {

video_render_sprite_flip_scale_opacity(sur, sx, sy, rendering_mode, pal_offset, FLIP_NONE, 1.0f, 1.0f, 255);
void video_render_sprite(surface *sur, int sx, int sy, VIDEO_BLEND_MODE blend_mode, int pal_offset) {
video_render_sprite_flip_scale_opacity(sur, sx, sy, blend_mode, pal_offset, FLIP_NONE, 1.0f, 1.0f, 255);
}

void video_render_sprite_flip_scale_opacity(surface *sur, int sx, int sy, unsigned int rendering_mode, int pal_offset,
void video_render_sprite_flip_scale_opacity(surface *sur, int sx, int sy, VIDEO_BLEND_MODE blend_mode, int pal_offset,
unsigned int flip_mode, float x_percent, float y_percent, uint8_t opacity) {

video_render_sprite_flip_scale_opacity_tint(sur, sx, sy, rendering_mode, pal_offset, flip_mode, x_percent,
video_render_sprite_flip_scale_opacity_tint(sur, sx, sy, blend_mode, pal_offset, flip_mode, x_percent,
y_percent, opacity, color_create(0xFF, 0xFF, 0xFF, 0xFF));
}

Expand All @@ -254,11 +253,11 @@ void video_render_sprite_size(surface *sur, int sx, int sy, int sw, int sh) {
dst.y = sy;

// Render
render_sprite_fsot(&g_video_state, sur, &dst, SDL_BLENDMODE_BLEND, 0, 0, 0xFF,
render_sprite_fsot(&g_video_state, sur, &dst, BLEND_ALPHA, 0, 0, 0xFF,
color_create(0xFF, 0xFF, 0xFF, 0xFF)); // tint
}

void video_render_sprite_flip_scale_opacity_tint(surface *sur, int sx, int sy, unsigned int rendering_mode,
void video_render_sprite_flip_scale_opacity_tint(surface *sur, int sx, int sy, VIDEO_BLEND_MODE blend_mode,
int pal_offset, unsigned int flip_mode, float x_percent,
float y_percent, uint8_t opacity, color tint) {

Expand All @@ -269,8 +268,5 @@ void video_render_sprite_flip_scale_opacity_tint(surface *sur, int sx, int sy, u
dst.x = sx;
dst.y = sy + (sur->h - dst.h) / 2;

// Select SDL blend mode
SDL_BlendMode blend_mode = (rendering_mode == BLEND_ALPHA) ? SDL_BLENDMODE_BLEND : SDL_BLENDMODE_ADD;

render_sprite_fsot(&g_video_state, sur, &dst, blend_mode, pal_offset, flip_mode, opacity, tint);
}
6 changes: 3 additions & 3 deletions src/video/video.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ void video_reinit_renderer();
void video_get_state(int *w, int *h, int *fs, int *vsync);
void video_move_target(int x, int y);

void video_render_sprite(surface *sur, int x, int y, unsigned int render_mode, int pal_offset);
void video_render_sprite(surface *sur, int x, int y, VIDEO_BLEND_MODE blend_mode, int pal_offset);

void video_render_sprite_size(surface *sur, int sx, int sy, int sw, int sh);

void video_render_sprite_tint(surface *sur, int x, int y, color c, int pal_offset);

void video_render_sprite_flip_scale_opacity(surface *sur, int x, int y, unsigned int render_mode, int pal_offset,
void video_render_sprite_flip_scale_opacity(surface *sur, int x, int y, VIDEO_BLEND_MODE blend_mode, int pal_offset,
unsigned int flip_mode, float x_percent, float y_percent, uint8_t opacity);

void video_render_sprite_flip_scale_opacity_tint(surface *sur, int x, int y, unsigned int render_mode, int pal_offset,
void video_render_sprite_flip_scale_opacity_tint(surface *sur, int x, int y, VIDEO_BLEND_MODE blend_mode, int pal_offset,
unsigned int flip_mode, float x_percent, float y_percent,
uint8_t opacity, color tint);

Expand Down

0 comments on commit 1e3c784

Please sign in to comment.