aboutsummaryrefslogtreecommitdiff
path: root/smelt
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2015-12-07 23:47:53 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2015-12-07 23:47:53 +0800
commit308cc42fbc27522615baf7843511571434c34062 (patch)
tree612ac7ee671a27de6c823ed4760c95a9d150f86a /smelt
parentcccf71f117f6acd02726d8d72702bdc8cc35d86d (diff)
downloadbullet-lab-remix-master.tar.xz
Update SMELT to the latest revision.HEADmaster
Diffstat (limited to 'smelt')
-rw-r--r--smelt/sdl/sfx_sdl.cpp35
-rw-r--r--smelt/sdl/smelt_config.hpp20
-rw-r--r--smelt/sdl/smelt_internal.hpp5
3 files changed, 53 insertions, 7 deletions
diff --git a/smelt/sdl/sfx_sdl.cpp b/smelt/sdl/sfx_sdl.cpp
index b61a8a0..c49162a 100644
--- a/smelt/sdl/sfx_sdl.cpp
+++ b/smelt/sdl/sfx_sdl.cpp
@@ -13,6 +13,7 @@
static const char* SFX_SDL_SRCFN="smelt/sdl/sfx_sdl.cpp";
struct oggdata{const BYTE *data;DWORD size,pos;};
static void* readVorbis(const BYTE *data,const DWORD size, ALsizei *decomp_size,ALenum *fmt,ALsizei *freq);
+static void* readRiffWv(const BYTE *data,const DWORD size, ALsizei *decomp_size,ALenum *fmt,ALsizei *freq);
SMSFX SMELT_IMPL::smSFXLoad(const char *path)
{
FILE *pFile;DWORD size,rsize; char *buff;
@@ -33,15 +34,20 @@ SMSFX SMELT_IMPL::smSFXLoadFromMemory(const char *ptr,DWORD size)
if(pOpenALDevice&&!mute)
{
bool isOgg=size>4&&ptr[0]=='O'&&ptr[1]=='g'&&ptr[2]=='g'&&ptr[3]=='S';
- if(!isOgg)return 0;
void *decompdata=NULL,*decomp=NULL;
ALsizei decompsize=0,freq=0;
ALenum fmt=AL_FORMAT_STEREO16;
- decompdata=readVorbis((const BYTE*)ptr,size,&decompsize,&fmt,&freq);
+ decompdata=readRiffWv((const BYTE*)ptr,size,&decompsize,&fmt,&freq);
+ if(!decompdata)
+ {
+ if(!isOgg)return 0;
+ else decompdata=readVorbis((const BYTE*)ptr,size,&decompsize,&fmt,&freq);
+ }
+ if(!decompdata)return 0;
decomp=decompdata;
ALuint buff=0;alGenBuffers(1,&buff);
alBufferData(buff,fmt,decomp,decompsize,freq);
- free(decompdata);return (SMSFX)buff;
+ free(decompdata);return(SMSFX)buff;
}
return 0;
}
@@ -270,6 +276,29 @@ static void* readVorbis(const BYTE *data,const DWORD size, ALsizei *decomp_size,
}
return NULL;
}
+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;
+ if(data[0x8]!='W'||data[0x9]!='A'||data[0xA]!='V'||data[0xB]!='E')return NULL;
+ if(data[0xC]!='f'||data[0xD]!='m'||data[0xE]!='t'||data[0xF]!=' ')return NULL;
+ if(data[0x16]==2)
+ {
+ if(data[0x22]==16)*fmt=AL_FORMAT_STEREO16;
+ else if(data[0x22]==8)*fmt=AL_FORMAT_STEREO8;
+ else return NULL;
+ }
+ else if(data[0x16]==1)
+ {
+ if(data[0x22]==16)*fmt=AL_FORMAT_MONO16;
+ else if(data[0x22]==8)*fmt=AL_FORMAT_MONO8;
+ else return NULL;
+ }else return NULL;
+ *decomp_size=(ALsizei)(data[0x28]|(data[0x29]<<8L)|(data[0x2A]<<16L)|(data[0x2B]<<24L));
+ *freq=(ALsizei)(data[0x18]|(data[0x19]<<8L)|(data[0x1A]<<16L)|(data[0x1B]<<24L));
+ ALubyte *ret=(ALubyte*)malloc(*decomp_size);
+ memcpy(ret,data+44,*decomp_size);
+ return ret;
+}
ALuint SMELT_IMPL::getSource()
{
for(int i=0;i<scnt;++i)
diff --git a/smelt/sdl/smelt_config.hpp b/smelt/sdl/smelt_config.hpp
new file mode 100644
index 0000000..0e56e8a
--- /dev/null
+++ b/smelt/sdl/smelt_config.hpp
@@ -0,0 +1,20 @@
+// -*- C++ -*-
+/*
+ * Simple MultimEdia LiTerator(SMELT)
+ * by Chris Xiong 2015
+ * Configuration header for SDL version
+ *
+ * Modify this header according to your own requirements.
+ *
+ */
+
+/*
+ * Maximum audio channels.
+ * (How many audio can be played simultaneously?)
+ */
+#define SRC_MAX 128
+
+/*
+ * Client-side vertex buffer size.
+ */
+#define VERTEX_BUFFER_SIZE 4000
diff --git a/smelt/sdl/smelt_internal.hpp b/smelt/sdl/smelt_internal.hpp
index 2d75e9a..a434079 100644
--- a/smelt/sdl/smelt_internal.hpp
+++ b/smelt/sdl/smelt_internal.hpp
@@ -12,6 +12,7 @@
#define SMELT_INTERNAL_H
#include "../../include/smelt.hpp"
+#include "smelt_config.hpp"
#include <cstdio>
#include <cstring>
#include <cstdlib>
@@ -42,8 +43,6 @@
#include "glimports.hpp"
#undef GL_PROC
-#define SRC_MAX 128
-
class TOpenGLDevice
{
public:
@@ -59,8 +58,6 @@ public:
bool have_GL_ARB_vertex_buffer_object;
};
-#define VERTEX_BUFFER_SIZE 4000
-
struct glTexture;
class TRenderTargetList
{