From 270ae8baa0504e555f16134bbf70e69ee94b13a9 Mon Sep 17 00:00:00 2001 From: octospacc Date: Sat, 6 Aug 2022 20:34:46 +0200 Subject: [PATCH] Edit README, some work on SDL 2.0 --- LibMultiSpacc/MultiSpacc.h | 1 + LibMultiSpacc/SDL12/SDL.c | 21 +++++++++------------ LibMultiSpacc/SDL12/SDL.h | 9 +++++---- LibMultiSpacc/SDL20/SDL.c | 28 ++++++++++++++++++++++++++++ LibMultiSpacc/SDL20/SDL.h | 8 ++++++++ README.md | 8 +++++--- 6 files changed, 56 insertions(+), 19 deletions(-) create mode 100644 LibMultiSpacc/SDL20/SDL.c diff --git a/LibMultiSpacc/MultiSpacc.h b/LibMultiSpacc/MultiSpacc.h index c7ccf95..ea1a1ce 100644 --- a/LibMultiSpacc/MultiSpacc.h +++ b/LibMultiSpacc/MultiSpacc.h @@ -1,5 +1,6 @@ #pragma once #include +#include #ifdef MultiSpacc_Target_SDL12 #include "SDL12/SDL.h" diff --git a/LibMultiSpacc/SDL12/SDL.c b/LibMultiSpacc/SDL12/SDL.c index 20c856c..4ccb61a 100644 --- a/LibMultiSpacc/SDL12/SDL.c +++ b/LibMultiSpacc/SDL12/SDL.c @@ -1,15 +1,20 @@ -#include #include "../MultiSpacc.h" #include "SDL/SDL.h" #include "SDL/SDL_image.h" #include "SDL/SDL_mixer.h" #include "SDL/SDL_ttf.h" -void MultiSpacc_SetAppTitle( const char *Title ) { - SDL_WM_SetCaption( Title, NULL ); +SDL_Surface *MultiSpacc_GetWindow( int Width, int Height, int Bits, Uint32 Flags ) { + return SDL_SetVideoMode( Width, Height, Bits, Flags ); +} +SDL_Surface *MultiSpacc_GetWindowSurface( SDL_Surface *Window ) { + return Window; } -void MultiSpacc_SetAppIcon( SDL_Surface *Icon ) { +void MultiSpacc_SetAppTitle( SDL_Surface *Window, const char *Title ) { + SDL_WM_SetCaption( Title, NULL ); +} +void MultiSpacc_SetAppIcon( SDL_Surface *Window, SDL_Surface *Icon ) { SDL_WM_SetIcon( Icon, NULL ); } @@ -21,11 +26,3 @@ int MultiSpacc_SetColorKey( SDL_Surface *Surface, bool Flag, Uint32 Key ) { return SDL_SetColorKey( Surface, 0, Key ); } } - -SDL_Surface *MultiSpacc_GetWindow( int Width, int Height, int Bits, Uint32 Flags ) { - return SDL_SetVideoMode( Width, Height, Bits, Flags ); -} - -SDL_Surface *MultiSpacc_GetWindowSurface( SDL_Surface *Window ) { - return Window; -} diff --git a/LibMultiSpacc/SDL12/SDL.h b/LibMultiSpacc/SDL12/SDL.h index 161f639..b978034 100644 --- a/LibMultiSpacc/SDL12/SDL.h +++ b/LibMultiSpacc/SDL12/SDL.h @@ -4,15 +4,16 @@ #define MultiSpacc_Target_SDL12 #endif -#include #include "../MultiSpacc.h" #include "SDL/SDL.h" #include "SDL/SDL_image.h" #include "SDL/SDL_mixer.h" #include "SDL/SDL_ttf.h" -void MultiSpacc_SetAppTitle( const char *Title ); -void MultiSpacc_SetAppIcon( SDL_Surface *Icon ); -int MultiSpacc_SetColorKey( SDL_Surface *Surface, bool Flag, Uint32 Key ); SDL_Surface *MultiSpacc_GetWindow( int Width, int Height, int Bits, Uint32 Flags ); SDL_Surface *MultiSpacc_GetWindowSurface( SDL_Surface *Window ); + +void MultiSpacc_SetAppTitle( SDL_Surface *Window, const char *Title ); +void MultiSpacc_SetAppIcon( SDL_Surface *Window, SDL_Surface *Icon ); + +int MultiSpacc_SetColorKey( SDL_Surface *Surface, bool Flag, Uint32 Key ); diff --git a/LibMultiSpacc/SDL20/SDL.c b/LibMultiSpacc/SDL20/SDL.c new file mode 100644 index 0000000..6fc013c --- /dev/null +++ b/LibMultiSpacc/SDL20/SDL.c @@ -0,0 +1,28 @@ +#include "../MultiSpacc.h" +#include "SDL2/SDL.h" +#include "SDL2/SDL_image.h" +#include "SDL2/SDL_mixer.h" +#include "SDL2/SDL_ttf.h" + +SDL_Window *MultiSpacc_GetWindow( int Width, int Height, int Bits, Uint32 Flags ) { + return SDL_CreateWindow(NULL, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, Width, Height, Flags); +} +SDL_Surface *MultiSpacc_GetWindowSurface( SDL_Surface *Window ) { + return SDL_GetWindowSurface( Window ); +} + +void MultiSpacc_SetAppTitle( SDL_Surface *Window, const char *Title ) { + SDL_SetWindowTitle( Window, Title ); +} +void MultiSpacc_SetAppIcon( SDL_Surface *Window, SDL_Surface *Icon ) { + SDL_SetWindowIcon( Window, Icon ); +} + +int MultiSpacc_SetColorKey( SDL_Surface *Surface, bool Flag, Uint32 Key ) { + if ( Flag ) { + return SDL_SetColorKey( Surface, SDL_TRUE, Key ); + } + else { + return SDL_SetColorKey( Surface, SDL_FALSE, Key ); + } +} diff --git a/LibMultiSpacc/SDL20/SDL.h b/LibMultiSpacc/SDL20/SDL.h index dd9969b..f16aaeb 100644 --- a/LibMultiSpacc/SDL20/SDL.h +++ b/LibMultiSpacc/SDL20/SDL.h @@ -9,3 +9,11 @@ #include "SDL2/SDL_image.h" #include "SDL2/SDL_mixer.h" #include "SDL2/SDL_ttf.h" + +SDL_Window *MultiSpacc_GetWindow( int Width, int Height, int Bits, Uint32 Flags ); +SDL_Surface *MultiSpacc_GetWindowSurface( SDL_Surface *Window ); + +void MultiSpacc_SetAppTitle( SDL_Surface *Window, const char *Title ); +void MultiSpacc_SetAppIcon( SDL_Surface *Window, SDL_Surface *Icon ); + +int MultiSpacc_SetColorKey( SDL_Surface *Surface, bool Flag, Uint32 Key ); diff --git a/README.md b/README.md index c138283..96353dc 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,15 @@ LibMultiSpacc is a library aiming to provide cross-platform abstractions for a number of less-cross-platform libraries. -The list of backend libraries supported follows: +The idea is simple: to build an universal abstraction layer on top of other existing libraries, that developers can use in their code instead of the platform-specific calls, to make it possible for an application to get build-time support for a major number of previously incompatible platforms. + +The list of supported (or planned) backend libraries follows: - SDL 1.2 (WIP) -- SDL 2.0 (planned) +- SDL 2.0 (WIP) Example programs (and makefiles) will come soon. ### Licensing -I have yet to choose a license for this. I would like for the library to be usable by as many people as possible (and, for that, the Unlicense o zlib license would be the best), but I have yet to understand legal compatibility with all the different libraries mine is made to work on top of. +I have yet to choose a license for this. I would like for the library to be usable by as many people as possible (and, for that, the Unlicense o zlib license would be the best), and possibly to also demand that credit is given to me (citing my library name), but I have yet to understand legal compatibility with all the different libraries mine is made to work on top of.