mirror of
https://gitlab.com/octospacc/BloccSpacc
synced 2025-06-05 21:39:15 +02:00
First commit (nothing works)
This commit is contained in:
39
Source/Util.c
Normal file
39
Source/Util.c
Normal file
@@ -0,0 +1,39 @@
|
||||
#include "SDL/SDL.h"
|
||||
#include "SDL/SDL_image.h"
|
||||
|
||||
SDL_Surface * LoadImage ( char * FilePath ) {
|
||||
SDL_Surface * a = NULL;
|
||||
SDL_Surface * b = NULL;
|
||||
a = IMG_Load ( FilePath );
|
||||
if ( a == NULL ) {
|
||||
printf("[E] Error reading image %s.\n", FilePath);
|
||||
} else {
|
||||
b = SDL_DisplayFormat ( a );
|
||||
SDL_FreeSurface ( a );
|
||||
if ( b == NULL ) {
|
||||
printf("[E] Error adapting image %s.\n", FilePath);
|
||||
} else {
|
||||
Uint32 ColorKey = SDL_MapRGB( b->format, 0xFF, 0x00, 0xFF ); // Magenta
|
||||
SDL_SetColorKey( b, SDL_SRCCOLORKEY, ColorKey );
|
||||
}
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
void DrawSurf ( int x, int y, SDL_Surface * Src, SDL_Rect * Clip, SDL_Surface * Dst ) {
|
||||
SDL_Rect Offset;
|
||||
Offset.x = x;
|
||||
Offset.y = y;
|
||||
SDL_BlitSurface( Src, Clip, Dst, &Offset );
|
||||
}
|
||||
|
||||
SDL_Surface * ScreenSet ( int Width, int Height, int Bits, SDL_Surface * Screen ) {
|
||||
Screen = SDL_SetVideoMode ( Width, Height, Bits,
|
||||
//SDL_SWSURFACE //|
|
||||
SDL_HWSURFACE |
|
||||
SDL_DOUBLEBUF //|
|
||||
//SDL_RESIZABLE //|
|
||||
//SDL_FULLSCREEN //|
|
||||
);
|
||||
return Screen;
|
||||
}
|
Reference in New Issue
Block a user