init
This commit is contained in:
commit
2f372ede93
212 changed files with 50289 additions and 0 deletions
34
src/texture.cpp
Normal file
34
src/texture.cpp
Normal file
|
@ -0,0 +1,34 @@
|
|||
#include "config.hpp"
|
||||
#include <SDL.h>
|
||||
#include <SDL_image.h>
|
||||
#include <SDL_log.h>
|
||||
#include <state.hpp>
|
||||
#include <texture.hpp>
|
||||
|
||||
PhoenixTexture PLoadTexture(std::string filePath) {
|
||||
SDL_Log("Loading texture from path: %s", filePath.c_str());
|
||||
|
||||
PhoenixTexture texture{};
|
||||
texture.texture = IMG_LoadTexture(state.renderer, filePath.c_str());
|
||||
|
||||
if (texture.texture == NULL) {
|
||||
SDL_Log("Failed to load image: %s", SDL_GetError());
|
||||
abort();
|
||||
}
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
void PDestroyTexture(PhoenixTexture *texture) {
|
||||
SDL_DestroyTexture(texture->texture);
|
||||
}
|
||||
|
||||
void PRenderTexture(PhoenixTexture *texture, int x, int y) {
|
||||
SDL_Rect dstRect{};
|
||||
dstRect.x = x;
|
||||
dstRect.y = y;
|
||||
dstRect.w = TEXTURE_WIDTH;
|
||||
dstRect.h = TEXTURE_HEIGHT;
|
||||
|
||||
SDL_RenderCopy(state.renderer, texture->texture, NULL, &dstRect);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue