2019-09-02 20:24:09 +00:00
|
|
|
#include "textures.h"
|
2019-09-02 02:55:49 +00:00
|
|
|
#include "common.h"
|
|
|
|
#include "SDL_helper.h"
|
|
|
|
|
2019-09-03 22:17:53 +00:00
|
|
|
SDL_Texture *battery_20, *battery_20_charging, *battery_30, *battery_30_charging, *battery_50, *battery_50_charging, \
|
|
|
|
*battery_60, *battery_60_charging, *battery_80, *battery_80_charging, *battery_90, *battery_90_charging, \
|
|
|
|
*battery_full, *battery_full_charging, *battery_low, *battery_unknown, *error, *warning;
|
|
|
|
|
2019-09-02 02:55:49 +00:00
|
|
|
void Textures_Load(void) {
|
2019-09-03 22:17:53 +00:00
|
|
|
/*SDL_LoadImage(RENDERER, &battery_20, "romfs:/resources/images/battery_20.png");
|
2019-09-03 00:01:34 +00:00
|
|
|
SDL_LoadImage(RENDERER, &battery_20_charging, "romfs:/resources/images/battery_20_charging.png");
|
|
|
|
SDL_LoadImage(RENDERER, &battery_30, "romfs:/resources/images/battery_30.png");
|
|
|
|
SDL_LoadImage(RENDERER, &battery_30_charging, "romfs:/resources/images/battery_30_charging.png");
|
|
|
|
SDL_LoadImage(RENDERER, &battery_50, "romfs:/resources/images/battery_50.png");
|
|
|
|
SDL_LoadImage(RENDERER, &battery_50_charging, "romfs:/resources/images/battery_50_charging.png");
|
|
|
|
SDL_LoadImage(RENDERER, &battery_60, "romfs:/resources/images/battery_60.png");
|
|
|
|
SDL_LoadImage(RENDERER, &battery_60_charging, "romfs:/resources/images/battery_60_charging.png");
|
|
|
|
SDL_LoadImage(RENDERER, &battery_80, "romfs:/resources/images/battery_80.png");
|
|
|
|
SDL_LoadImage(RENDERER, &battery_80_charging, "romfs:/resources/images/battery_80_charging.png");
|
|
|
|
SDL_LoadImage(RENDERER, &battery_90, "romfs:/resources/images/battery_90.png");
|
|
|
|
SDL_LoadImage(RENDERER, &battery_90_charging, "romfs:/resources/images/battery_90_charging.png");
|
|
|
|
SDL_LoadImage(RENDERER, &battery_full, "romfs:/resources/images/battery_full.png");
|
|
|
|
SDL_LoadImage(RENDERER, &battery_full_charging, "romfs:/resources/images/battery_full_charging.png");
|
|
|
|
SDL_LoadImage(RENDERER, &battery_low, "romfs:/resources/images/battery_low.png");
|
2019-09-03 22:17:53 +00:00
|
|
|
SDL_LoadImage(RENDERER, &battery_unknown, "romfs:/resources/images/battery_unknown.png");*/
|
|
|
|
//SDL_LoadImage(RENDERER, &error, "romfs:/resources/images/error.png");
|
|
|
|
|
2019-09-20 00:12:38 +00:00
|
|
|
fprintf(stderr, "LOADING WARNING\n");
|
2019-09-03 22:17:53 +00:00
|
|
|
SDL_Surface *imageSurface = IMG_Load("romfs:/resources/images/warning.png");
|
2019-09-20 00:12:38 +00:00
|
|
|
fprintf(stderr, "LOADED WARNING\n");
|
2019-09-03 22:17:53 +00:00
|
|
|
|
2019-09-20 00:12:38 +00:00
|
|
|
if (RENDERER) {
|
|
|
|
if (imageSurface) {
|
|
|
|
fprintf(stderr, "CREATING TEXTURE\n");
|
|
|
|
warning = SDL_CreateTextureFromSurface(RENDERER, imageSurface);
|
|
|
|
fprintf(stderr, "CREATED TEXTURE\n");
|
|
|
|
|
|
|
|
if (warning == NULL) {
|
|
|
|
fprintf(stderr, "CreateTextureFromSurface failed: %s\n", SDL_GetError());
|
|
|
|
exit(1);
|
|
|
|
} else {
|
|
|
|
fprintf(stderr, "Loaded \"romfs:/resources/images/warning.png\"\n");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
fprintf(stderr, "Failed to load image: \"romfs:/resources/images/warning.png\"\n");
|
2019-09-03 22:17:53 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
} else {
|
2019-09-20 00:12:38 +00:00
|
|
|
fprintf(stderr, "Something wrong with RENDERER");
|
|
|
|
exit(1);
|
2019-09-03 22:17:53 +00:00
|
|
|
}
|
2019-09-20 00:12:38 +00:00
|
|
|
|
|
|
|
SDL_FreeSurface(imageSurface);
|
|
|
|
|
|
|
|
|
2019-09-03 22:17:53 +00:00
|
|
|
/*if (imageSurface) {
|
|
|
|
Uint32 colorkey = SDL_MapRGB(imageSurface->format, 0, 0, 0);
|
|
|
|
SDL_SetColorKey(imageSurface, SDL_TRUE, colorkey);
|
|
|
|
warning = SDL_CreateTextureFromSurface(RENDERER, imageSurface);
|
|
|
|
} else {
|
|
|
|
printf("Failed to load image: %c", "romfs:/resources/images/warning.png");
|
|
|
|
}
|
|
|
|
|
|
|
|
SDL_FreeSurface(imageSurface);*/
|
|
|
|
//SDL_LoadImage(RENDERER, &warning, "romfs:/resources/images/warning.png");
|
2019-09-02 02:55:49 +00:00
|
|
|
}
|
|
|
|
|
2019-09-02 20:24:09 +00:00
|
|
|
void Textures_Free(void) {
|
2019-09-03 22:17:53 +00:00
|
|
|
SDL_DestroyTexture(warning);
|
|
|
|
//SDL_DestroyTexture(error);
|
|
|
|
/*SDL_DestroyTexture(battery_unknown);
|
2019-09-02 02:55:49 +00:00
|
|
|
SDL_DestroyTexture(battery_low);
|
|
|
|
SDL_DestroyTexture(battery_full_charging);
|
|
|
|
SDL_DestroyTexture(battery_full);
|
|
|
|
SDL_DestroyTexture(battery_90_charging);
|
|
|
|
SDL_DestroyTexture(battery_80_charging);
|
|
|
|
SDL_DestroyTexture(battery_80);
|
|
|
|
SDL_DestroyTexture(battery_60_charging);
|
|
|
|
SDL_DestroyTexture(battery_60);
|
|
|
|
SDL_DestroyTexture(battery_50_charging);
|
|
|
|
SDL_DestroyTexture(battery_50);
|
|
|
|
SDL_DestroyTexture(battery_30_charging);
|
|
|
|
SDL_DestroyTexture(battery_30);
|
|
|
|
SDL_DestroyTexture(battery_20_charging);
|
2019-09-03 22:17:53 +00:00
|
|
|
SDL_DestroyTexture(battery_20);*/
|
2019-09-02 02:55:49 +00:00
|
|
|
}
|