Pasaeta de "include-what-you-use" per arreglar els includes
Renombrats alguns fitxers per consistencia
This commit is contained in:
@@ -1,12 +1,17 @@
|
||||
|
||||
#include "texture.h"
|
||||
#include <SDL2/SDL_error.h> // for SDL_GetError
|
||||
#include <SDL2/SDL_surface.h> // for SDL_CreateRGBSurfaceWithFormatFrom
|
||||
#include <fcntl.h> // for SEEK_END, SEEK_SET
|
||||
#include <stdio.h> // for fseek, fclose, fopen, fread, ftell, NULL
|
||||
#include <stdlib.h> // for malloc, free, exit
|
||||
#include <iostream> // for basic_ostream, operator<<, cout, endl
|
||||
#include "gif.c" // for LoadGif, LoadPalette
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#include "stb_image.h"
|
||||
#include "gif.c"
|
||||
#include <iostream>
|
||||
#include "stb_image.h" // for stbi_failure_reason, stbi_image_free
|
||||
|
||||
// Constructor
|
||||
Texture::Texture(SDL_Renderer *renderer, std::string path, bool verbose)
|
||||
Texture::Texture(SDL_Renderer *renderer, std::string path)
|
||||
{
|
||||
// Copia punteros
|
||||
this->renderer = renderer;
|
||||
@@ -29,7 +34,7 @@ Texture::Texture(SDL_Renderer *renderer, std::string path, bool verbose)
|
||||
// .png
|
||||
if (extension == "png")
|
||||
{
|
||||
loadFromFile(path, verbose);
|
||||
loadFromFile(path);
|
||||
}
|
||||
|
||||
// .gif
|
||||
@@ -53,7 +58,7 @@ Texture::~Texture()
|
||||
}
|
||||
|
||||
// Carga una imagen desde un fichero
|
||||
bool Texture::loadFromFile(std::string path, bool verbose)
|
||||
bool Texture::loadFromFile(std::string path)
|
||||
{
|
||||
const std::string filename = path.substr(path.find_last_of("\\/") + 1);
|
||||
int req_format = STBI_rgb_alpha;
|
||||
@@ -61,15 +66,16 @@ bool Texture::loadFromFile(std::string path, bool verbose)
|
||||
unsigned char *data = stbi_load(path.c_str(), &width, &height, &orig_format, req_format);
|
||||
if (data == nullptr)
|
||||
{
|
||||
SDL_Log("Loading image failed: %s", stbi_failure_reason());
|
||||
#ifdef VERBOSE
|
||||
std::cout << "Loading image failed: " << stbi_failure_reason() << std::endl;
|
||||
#endif
|
||||
exit(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (verbose)
|
||||
{
|
||||
std::cout << "Image loaded: " << filename.c_str() << std::endl;
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
std::cout << "Image loaded: " << filename.c_str() << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
int depth, pitch;
|
||||
@@ -97,10 +103,9 @@ bool Texture::loadFromFile(std::string path, bool verbose)
|
||||
SDL_Surface *loadedSurface = SDL_CreateRGBSurfaceWithFormatFrom((void *)data, width, height, depth, pitch, pixel_format);
|
||||
if (loadedSurface == nullptr)
|
||||
{
|
||||
if (verbose)
|
||||
{
|
||||
std::cout << "Unable to load image " << path.c_str() << std::endl;
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
std::cout << "Unable to load image " << path.c_str() << std::endl;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -108,10 +113,9 @@ bool Texture::loadFromFile(std::string path, bool verbose)
|
||||
newTexture = SDL_CreateTextureFromSurface(renderer, loadedSurface);
|
||||
if (newTexture == nullptr)
|
||||
{
|
||||
if (verbose)
|
||||
{
|
||||
std::cout << "Unable to create texture from " << path.c_str() << "! SDL Error: " << SDL_GetError() << std::endl;
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
std::cout << "Unable to create texture from " << path.c_str() << "! SDL Error: " << SDL_GetError() << std::endl;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -227,7 +231,7 @@ int Texture::getHeight()
|
||||
// Recarga la textura
|
||||
bool Texture::reLoad()
|
||||
{
|
||||
return loadFromFile(path, renderer);
|
||||
return loadFromFile(path);
|
||||
}
|
||||
|
||||
// Obtiene la textura
|
||||
|
||||
Reference in New Issue
Block a user