diff options
author | Chris Xiong <chirs241097@gmail.com> | 2016-10-25 22:28:57 +0800 |
---|---|---|
committer | Chris Xiong <chirs241097@gmail.com> | 2016-10-25 22:28:57 +0800 |
commit | 6206029f2d0af3ef76a0a61ef024ca758307ba19 (patch) | |
tree | 3c5d558a8f2d8271cbf0cc5b827e3f2165402dc7 /smelt/sdl | |
parent | 12ac4db50e8c2b131d992733bb93b554e2cbd7d0 (diff) | |
download | SMELT-6206029f2d0af3ef76a0a61ef024ca758307ba19.tar.xz |
Add more options to the config file.
Diffstat (limited to 'smelt/sdl')
-rw-r--r-- | smelt/sdl/makefile | 16 | ||||
-rw-r--r-- | smelt/sdl/sfx_dumb.cpp | 13 | ||||
-rw-r--r-- | smelt/sdl/sfx_sdl.cpp | 12 | ||||
-rw-r--r-- | smelt/sdl/smelt_config.hpp | 10 | ||||
-rw-r--r-- | smelt/sdl/smelt_internal.hpp | 8 | ||||
-rw-r--r-- | smelt/sdl/sys_sdl.cpp | 1 |
6 files changed, 38 insertions, 22 deletions
diff --git a/smelt/sdl/makefile b/smelt/sdl/makefile index fc513d5..d58f077 100644 --- a/smelt/sdl/makefile +++ b/smelt/sdl/makefile @@ -1,29 +1,27 @@ CC= g++ CXXFLAGS= -c -g -O2 -std=c++11 -Wall -I/usr/include/SDL/ -I../include -D_LINUX -fPIC +TARGET= libsmelt.a all: objects-normal archive-normal -dumb: objects-dumb archive-dumb +dumb: CXXFLAGS += -DENABLE_DUMB +dumb: TARGET= libsmelt-dumb.a +dumb: all objects-normal: gfx inp sfx sys -objects-dumb: gfx inp sfx-dumb sys - gfx: $(CC) gfx_sdl.cpp $(CXXFLAGS) sfx: $(CC) sfx_sdl.cpp $(CXXFLAGS) -sfx-dumb: - $(CC) sfx_dumb.cpp $(CXXFLAGS) inp: $(CC) inp_sdl.cpp $(CXXFLAGS) sys: $(CC) sys_sdl.cpp $(CXXFLAGS) archive-normal: - $(AR) rcs libsmelt.a gfx_sdl.o sfx_sdl.o inp_sdl.o sys_sdl.o -archive-dumb: - $(AR) rcs libsmelt-dumb.a gfx_sdl.o sfx_dumb.o inp_sdl.o sys_sdl.o + $(AR) rcs $(TARGET) gfx_sdl.o sfx_sdl.o inp_sdl.o sys_sdl.o + clean: rm -f *.o clean-all: clean - rm *.a
\ No newline at end of file + rm *.a diff --git a/smelt/sdl/sfx_dumb.cpp b/smelt/sdl/sfx_dumb.cpp index 4e7a277..69cae6e 100644 --- a/smelt/sdl/sfx_dumb.cpp +++ b/smelt/sdl/sfx_dumb.cpp @@ -6,13 +6,9 @@ * This dumb implementation has everything stubbed, useful if you don't * use the audio routines here. * - * WARNING: This library is in development and interfaces would be very - * unstable. + * WARNING: This file is not intended to be used on its own! * */ -#include "smelt_internal.hpp" - -static const char* SFX_SDL_SRCFN="smelt/sdl/sfx_dumb.cpp"; SMSFX SMELT_IMPL::smSFXLoad(const char *path) {return 0;} @@ -57,18 +53,11 @@ int SMELT_IMPL::smChannelGetPosd(SMCHN chn) void SMELT_IMPL::smChannelSetPosd(SMCHN chn,int pos) {} -ALuint SMELT_IMPL::getSource() -{return 0;} bool SMELT_IMPL::initOAL() { smLog("%s:" SLINE ": I'm dumb!\n",SFX_SDL_SRCFN); - pOpenALDevice=(void*)1; return true; } void SMELT_IMPL::finiOAL() { - if(pOpenALDevice) - { - pOpenALDevice=NULL; - } } diff --git a/smelt/sdl/sfx_sdl.cpp b/smelt/sdl/sfx_sdl.cpp index c49162a..2b0f87a 100644 --- a/smelt/sdl/sfx_sdl.cpp +++ b/smelt/sdl/sfx_sdl.cpp @@ -11,8 +11,11 @@ #include "smelt_internal.hpp" static const char* SFX_SDL_SRCFN="smelt/sdl/sfx_sdl.cpp"; +#ifndef ENABLE_DUMB +#ifdef ENABLE_OGG_SUPPORT struct oggdata{const BYTE *data;DWORD size,pos;}; static void* readVorbis(const BYTE *data,const DWORD size, ALsizei *decomp_size,ALenum *fmt,ALsizei *freq); +#endif static void* readRiffWv(const BYTE *data,const DWORD size, ALsizei *decomp_size,ALenum *fmt,ALsizei *freq); SMSFX SMELT_IMPL::smSFXLoad(const char *path) { @@ -33,16 +36,20 @@ SMSFX SMELT_IMPL::smSFXLoadFromMemory(const char *ptr,DWORD size) { if(pOpenALDevice&&!mute) { +#ifdef ENABLE_OGG_SUPPORT bool isOgg=size>4&&ptr[0]=='O'&&ptr[1]=='g'&&ptr[2]=='g'&&ptr[3]=='S'; +#endif void *decompdata=NULL,*decomp=NULL; ALsizei decompsize=0,freq=0; ALenum fmt=AL_FORMAT_STEREO16; decompdata=readRiffWv((const BYTE*)ptr,size,&decompsize,&fmt,&freq); +#ifdef ENABLE_OGG_SUPPORT if(!decompdata) { if(!isOgg)return 0; else decompdata=readVorbis((const BYTE*)ptr,size,&decompsize,&fmt,&freq); } +#endif if(!decompdata)return 0; decomp=decompdata; ALuint buff=0;alGenBuffers(1,&buff); @@ -205,6 +212,7 @@ void SMELT_IMPL::smChannelSetPosd(SMCHN chn,int pos) if(pOpenALDevice)alSourcei((ALuint)chn,AL_SAMPLE_OFFSET,(ALint)pos); } +#ifdef ENABLE_OGG_SUPPORT static size_t oggRead(void *ptr,size_t size,size_t nmemb,void *ds) { oggdata *data=(oggdata*)ds; @@ -276,6 +284,7 @@ static void* readVorbis(const BYTE *data,const DWORD size, ALsizei *decomp_size, } return NULL; } +#endif static void* readRiffWv(const BYTE *data,const DWORD size, ALsizei *decomp_size,ALenum *fmt,ALsizei *freq) { if(data[0x0]!='R'||data[0x1]!='I'||data[0x2]!='F'||data[0x3]!='F')return NULL; @@ -354,3 +363,6 @@ void SMELT_IMPL::finiOAL() alcCloseDevice(dev);pOpenALDevice=NULL; } } +#else +#include "sfx_dumb.cpp" +#endif //ifndef ENABLE_DUMB diff --git a/smelt/sdl/smelt_config.hpp b/smelt/sdl/smelt_config.hpp index 0e56e8a..3d8c2ca 100644 --- a/smelt/sdl/smelt_config.hpp +++ b/smelt/sdl/smelt_config.hpp @@ -18,3 +18,13 @@ * Client-side vertex buffer size. */ #define VERTEX_BUFFER_SIZE 4000 + +/* + * Uncomment this to build a "dumb" version with no audio routines. + */ +//#define ENABLE_DUMB + +/* + * Undefine this to disable ogg support. + */ +#define ENABLE_OGG_SUPPORT diff --git a/smelt/sdl/smelt_internal.hpp b/smelt/sdl/smelt_internal.hpp index a14e151..c7a77fd 100644 --- a/smelt/sdl/smelt_internal.hpp +++ b/smelt/sdl/smelt_internal.hpp @@ -21,11 +21,15 @@ #include <dirent.h> #include <unistd.h> #include <SDL2/SDL.h> +#ifndef ENABLE_DUMB #include <AL/al.h> #include <AL/alc.h> #include <AL/alext.h> +#ifdef ENABLE_OGG_SUPPORT #include <ogg/ogg.h> #include <vorbis/vorbisfile.h> +#endif +#endif #ifdef WIN32 #include <windows.h> #include <intrin.h> @@ -225,12 +229,14 @@ public: DWORD* decodeImage(BYTE *data,const char *fn,DWORD size,int &w,int &h); void *pOpenALDevice; + bool mute,lpp; bool initOAL(); void finiOAL(); - bool mute,lpp; +#ifndef ENABLE_DUMB int scnt; ALuint src[SRC_MAX]; ALuint getSource(); +#endif int posz,lkey; float posx,posy; diff --git a/smelt/sdl/sys_sdl.cpp b/smelt/sdl/sys_sdl.cpp index 5641f31..2c0ae93 100644 --- a/smelt/sdl/sys_sdl.cpp +++ b/smelt/sdl/sys_sdl.cpp @@ -132,6 +132,7 @@ bool SMELT_IMPL::smInit() if(!pSM->Active)pSM->focusChange(true); } SDL_ShowCursor(hideMouse?SDL_DISABLE:SDL_ENABLE); + SDL_EnableScreenSaver(); initInput(); if(!initOGL()){smFinale();return false;} if(!initOAL()){smFinale();return false;} |