afegida (altra volta) la classe Surface
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
typedef struct jSurface_s *jSurface;
|
||||
|
||||
class Surface
|
||||
{
|
||||
private:
|
||||
// Variables
|
||||
jSurface surface;
|
||||
jSurface destSurface;
|
||||
SDL_Texture *texture;
|
||||
Uint32 palette[256];
|
||||
int transparentColor;
|
||||
|
||||
// Escribe pixels en destSurface
|
||||
void putPixel(int x, int y, Uint8 color);
|
||||
|
||||
// Lee pixels en surface
|
||||
Uint8 getPixel(int x, int y);
|
||||
|
||||
// Limpia la paleta
|
||||
void clearPalette(Uint32 color);
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Surface(const char *filename, jSurface dest);
|
||||
Surface(int width, int height, SDL_Texture *tex);
|
||||
|
||||
// Destructor
|
||||
~Surface();
|
||||
|
||||
// Crea una surface
|
||||
jSurface newSurface(int w, int h);
|
||||
|
||||
// Borra una surface
|
||||
void deleteSurface(jSurface surf);
|
||||
|
||||
// Establece una surface de destino donde hacer el blit
|
||||
void setDest(jSurface surf);
|
||||
|
||||
// Establece una textura donde hacer el flip
|
||||
void setTexture(SDL_Texture *tex);
|
||||
|
||||
// Crea una surface a partir de un fichero .gif
|
||||
jSurface loadSurface(const char *filename);
|
||||
|
||||
// Carga una paleta desde un fichero .gif
|
||||
void loadPalette(const char *filename);
|
||||
|
||||
// Copia pixels desde surface a destSurface
|
||||
void blit(int dx, int dy, int sx, int sy, int w, int h);
|
||||
|
||||
// Cambia un color de la paleta
|
||||
void setPaletteColor(int index, Uint32 color);
|
||||
|
||||
// Limpia la surface
|
||||
void cls(Uint8 color);
|
||||
|
||||
// Volca la surface a una textura
|
||||
void flip(SDL_Texture *texture);
|
||||
};
|
||||
Reference in New Issue
Block a user