Added API functions for modulating the colour and alpha of a texture
This commit is contained in:
1 parent
b95cff5f0c
commit
24a86ba6e3
4 files changed
+41
No files matched your search
@@ -74,6 +74,8 @@ void clip_render_rects_to_drawing_area(RenderRect *src, RenderRect *dest);
|
|||||||
|
|
||||||
RenderRect get_texture_asset_rect(AssetID id);
|
RenderRect get_texture_asset_rect(AssetID id);
|
||||||
void render_texture_asset(AssetID id, RenderRect *src, RenderRect *dest);
|
void render_texture_asset(AssetID id, RenderRect *src, RenderRect *dest);
|
||||||
|
void modulate_texture_color(AssetID id, SDL_Color color);
|
||||||
|
void modulate_texture_alpha(AssetID id, u8 alpha);
|
||||||
TextSize get_text_size_from_font_asset(AssetID id, const char *text);
|
TextSize get_text_size_from_font_asset(AssetID id, const char *text);
|
||||||
void render_text_with_font_asset(AssetID id, const char *text, f32 x, f32 y,
|
void render_text_with_font_asset(AssetID id, const char *text, f32 x, f32 y,
|
||||||
SDL_Color color);
|
SDL_Color color);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "SDL_surface.h"
|
#include "SDL_surface.h"
|
||||||
#include "SDL_video.h"
|
#include "SDL_video.h"
|
||||||
#include "aliases.h"
|
#include "aliases.h"
|
||||||
|
#include <aliases.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@@ -43,6 +44,8 @@ Renderer *create_renderer(SDL_Window *window);
|
|||||||
void get_render_output_size(Renderer *renderer, i32 *w, i32 *h);
|
void get_render_output_size(Renderer *renderer, i32 *w, i32 *h);
|
||||||
|
|
||||||
void set_render_draw_color(const Renderer *renderer, SDL_Color color);
|
void set_render_draw_color(const Renderer *renderer, SDL_Color color);
|
||||||
|
void set_texture_color_modulation(SDL_Texture *texture, SDL_Color color);
|
||||||
|
void set_texture_alpha_modulation(SDL_Texture *texture, u8 alpha);
|
||||||
void render_clear(const Renderer *renderer, SDL_Color color);
|
void render_clear(const Renderer *renderer, SDL_Color color);
|
||||||
void draw_rect(const Renderer *renderer, SDL_Color color, f32 x, f32 y, f32 w,
|
void draw_rect(const Renderer *renderer, SDL_Color color, f32 x, f32 y, f32 w,
|
||||||
f32 h);
|
f32 h);
|
||||||
|
|||||||
@@ -326,6 +326,34 @@ void render_texture_asset(AssetID id, RenderRect *src, RenderRect *dest) {
|
|||||||
render_texture(GameEngine.window.renderer, texture, src, dest);
|
render_texture(GameEngine.window.renderer, texture, src, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void modulate_texture_color(AssetID id, SDL_Color color) {
|
||||||
|
if (id < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_Texture *texture = get_texture(GameEngine.asset_manager, id);
|
||||||
|
|
||||||
|
if (!texture) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
set_texture_color_modulation(texture, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
void modulate_texture_alpha(AssetID id, u8 alpha) {
|
||||||
|
if (id < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_Texture *texture = get_texture(GameEngine.asset_manager, id);
|
||||||
|
|
||||||
|
if (!texture) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
set_texture_alpha_modulation(texture, alpha);
|
||||||
|
}
|
||||||
|
|
||||||
TextSize get_text_size_from_font_asset(AssetID id, const char *text) {
|
TextSize get_text_size_from_font_asset(AssetID id, const char *text) {
|
||||||
TextSize output = {};
|
TextSize output = {};
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,14 @@ void set_render_draw_color(const Renderer *renderer, SDL_Color color) {
|
|||||||
color.a);
|
color.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_texture_color_modulation(SDL_Texture *texture, SDL_Color color) {
|
||||||
|
SDL_SetTextureColorMod(texture, color.r, color.g, color.b);
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_texture_alpha_modulation(SDL_Texture *texture, u8 alpha) {
|
||||||
|
SDL_SetTextureAlphaMod(texture, alpha);
|
||||||
|
}
|
||||||
|
|
||||||
void render_clear(const Renderer *renderer, SDL_Color color) {
|
void render_clear(const Renderer *renderer, SDL_Color color) {
|
||||||
if (!renderer || !(renderer->SDL_base_renderer)) {
|
if (!renderer || !(renderer->SDL_base_renderer)) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in new issue
Block a user