Created
April 29, 2016 18:35
-
-
Save maxwellnewage/e1e77f141b4a4899f4cad5103494da28 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef _H_LTEXTURE | |
#define _H_LTEXTURE | |
#include <SDL.h> | |
#include <iostream> | |
/** | |
* \brief Create a texture with our modifications | |
*/ | |
class LTexture | |
{ | |
public: | |
LTexture(); | |
~LTexture(); | |
/** | |
* \brief Loads image at specified path | |
* \param path | |
* \param gRenderer | |
*/ | |
bool loadFromFile(std::string path, SDL_Renderer *gRenderer); | |
/** | |
* \brief Deallocates texture | |
*/ | |
void free(); | |
/** | |
* \brief Set color modulation | |
* \param red | |
* \param green | |
* \param blue | |
*/ | |
void setColor(Uint8 red, Uint8 green, Uint8 blue); | |
/** | |
* \brief Set blending | |
* \param blending | |
*/ | |
void setBlendMode(SDL_BlendMode blending); | |
/** | |
* \brief Set alpha modulation | |
* \param alpha | |
*/ | |
void setAlpha(Uint8 alpha); | |
/** | |
* \brief Renders texture at given point | |
* \param x | |
* \param y | |
* \param gRenderer | |
* \param clip | |
*/ | |
void render(int x, int y, SDL_Renderer *gRenderer, SDL_Rect* clip = NULL); | |
//Gets image dimensions | |
int getWidth(); | |
int getHeight(); | |
private: | |
SDL_Texture* mTexture; | |
int mWidth; | |
int mHeight; | |
}; | |
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef _H_START | |
#define _H_START | |
#include <SDL.h> | |
#include <iostream> | |
#include <SDL_image.h> | |
#include "LTexture.h" | |
class Start { | |
public: | |
SDL_Window *gWindow; | |
SDL_Renderer *gRenderer; | |
/** | |
* \brief Create the window, prepare texture and image | |
* \param windowTitle | |
* \param posX | |
* \param posY | |
* \param width | |
* \param height | |
* \param flag | |
*/ | |
Start(std::string windowTitle, int posX, int posY, int width, int height, int flag); | |
/** | |
* \brief Create the render and color them | |
* \param r | |
* \param g | |
* \param b | |
* \param a | |
*/ | |
void initRender(int r, int g, int b, int a); | |
/** | |
* \brief Finish the game | |
*/ | |
void close(); | |
/** | |
* \brief Clear the render | |
*/ | |
void clearRender(); | |
/** | |
* \brief Put the texture on the render | |
* \param texture | |
* \param x | |
* \param y | |
* \param clip | |
*/ | |
void textureRender(LTexture texture, int x, int y, SDL_Rect* clip = NULL); | |
/** | |
* \brief Show the render | |
*/ | |
void presentRender(); | |
private: | |
/** | |
* \brief Initialize the image | |
*/ | |
void initIMG(); | |
/** | |
* \brief Initialize the texture | |
*/ | |
void initTexture(); | |
}; | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment