separate stream sdl rwops into their own header
this allows us to avoid globally including SDL.h
This commit is contained in:
parent
9bc4942489
commit
085e61148f
5 changed files with 20 additions and 10 deletions
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include "command.hh"
|
||||
|
||||
#include <cctype>
|
||||
|
||||
#include <sauerlib/encoding.hh>
|
||||
|
||||
#include <shared/igame.hh>
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <shared/command.hh>
|
||||
#include <shared/igame.hh>
|
||||
#include <shared/rwops.hh>
|
||||
|
||||
#include "command.hh" // identflags
|
||||
#include "console.hh" /* conoutf */
|
||||
|
@ -1479,7 +1480,7 @@ static SDL_Surface *loadsurface(const char *name)
|
|||
stream *z = openzipfile(name, "rb");
|
||||
if(z)
|
||||
{
|
||||
SDL_RWops *rw = z->rwops();
|
||||
SDL_RWops *rw = stream_rwops(z);
|
||||
if(rw)
|
||||
{
|
||||
const char *ext = strrchr(name, '.');
|
||||
|
@ -3869,12 +3870,12 @@ static void saveimage(const char *filename, int format, ImageData &image, bool f
|
|||
switch(format) {
|
||||
case IMG_JPG:
|
||||
#if SDL_IMAGE_VERSION_ATLEAST(2, 0, 2)
|
||||
IMG_SaveJPG_RW(s, f->rwops(), 1, screenshotquality);
|
||||
IMG_SaveJPG_RW(s, stream_rwops(f), 1, screenshotquality);
|
||||
#else
|
||||
conoutf(CON_ERROR, "JPG screenshot support requires SDL_image 2.0.2");
|
||||
#endif
|
||||
break;
|
||||
default: SDL_SaveBMP_RW(s, f->rwops(), 1); break;
|
||||
default: SDL_SaveBMP_RW(s, stream_rwops(f), 1); break;
|
||||
}
|
||||
delete f;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
|
||||
#include <new>
|
||||
|
||||
#include <SDL.h>
|
||||
#include <zlib.h>
|
||||
|
||||
typedef unsigned char uchar;
|
||||
|
@ -1211,10 +1210,6 @@ struct stream
|
|||
template<class T> T get() { T n; return read(&n, sizeof(n)) == sizeof(n) ? n : 0; }
|
||||
template<class T> T getlil() { return lilswap(get<T>()); }
|
||||
template<class T> T getbig() { return bigswap(get<T>()); }
|
||||
|
||||
#ifndef STANDALONE
|
||||
SDL_RWops *rwops();
|
||||
#endif
|
||||
};
|
||||
|
||||
template<class T>
|
||||
|
|
10
src/shared/rwops.hh
Normal file
10
src/shared/rwops.hh
Normal file
|
@ -0,0 +1,10 @@
|
|||
#ifndef SHARED_RWOPS_HH
|
||||
#define SHARED_RWOPS_HH
|
||||
|
||||
#include <SDL.h>
|
||||
|
||||
#include "tools.hh"
|
||||
|
||||
SDL_RWops *stream_rwops(stream *s);
|
||||
|
||||
#endif
|
|
@ -1,5 +1,7 @@
|
|||
#include <new>
|
||||
|
||||
#include <SDL.h>
|
||||
|
||||
#include <sauerlib/encoding.hh>
|
||||
|
||||
#include "command.hh"
|
||||
|
@ -566,11 +568,11 @@ static int rwopsclose(SDL_RWops *rw)
|
|||
return 0;
|
||||
}
|
||||
|
||||
SDL_RWops *stream::rwops()
|
||||
SDL_RWops *stream_rwops(stream *s)
|
||||
{
|
||||
SDL_RWops *rw = SDL_AllocRW();
|
||||
if(!rw) return nullptr;
|
||||
rw->hidden.unknown.data1 = this;
|
||||
rw->hidden.unknown.data1 = s;
|
||||
rw->seek = rwopsseek;
|
||||
rw->read = rwopsread;
|
||||
rw->write = rwopswrite;
|
||||
|
|
Loading…
Reference in a new issue