aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2015-08-15 11:31:21 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2015-08-15 11:31:21 +0800
commitbfe4f5ac512493bd9a359a06875288fbfaea6ff8 (patch)
treef3792da663b88b0db48376bf493d9dbe1ceba248
parent65408f92d1728d06094cb81eac3c81e1dae34a65 (diff)
downloadbullet-lab-remix-bfe4f5ac512493bd9a359a06875288fbfaea6ff8.tar.xz
Bump SMELT to apilevel 2, adding several functions.
-rw-r--r--extensions/smanim.cpp1
-rw-r--r--extensions/smbmfont.cpp1
-rw-r--r--extensions/smdatapack.cpp1
-rw-r--r--extensions/smentity.cpp1
-rw-r--r--extensions/smgrid.cpp1
-rw-r--r--extensions/smttfont.cpp1
-rw-r--r--include/smanim.hpp1
-rw-r--r--include/smbmfont.hpp1
-rw-r--r--include/smcolor.hpp1
-rw-r--r--include/smdatapack.hpp1
-rw-r--r--include/smelt.hpp6
-rw-r--r--include/smentity.hpp1
-rw-r--r--include/smgrid.hpp1
-rw-r--r--include/smindicator.hpp52
-rw-r--r--include/smmath.hpp11
-rw-r--r--include/smprogresser.hpp1
-rw-r--r--include/smrandom.hpp1
-rw-r--r--include/smttfont.hpp1
-rw-r--r--smelt/sdl/gfx_sdl.cpp6
-rw-r--r--smelt/sdl/sfx_sdl.cpp12
-rw-r--r--smelt/sdl/smelt_internal.hpp5
-rw-r--r--smelt/sdl/sys_sdl.cpp1
22 files changed, 78 insertions, 30 deletions
diff --git a/extensions/smanim.cpp b/extensions/smanim.cpp
index f96a575..5d8cac5 100644
--- a/extensions/smanim.cpp
+++ b/extensions/smanim.cpp
@@ -2,7 +2,6 @@
/*
* Simple MultimEdia LiTerator(SMELT)
* by Chris Xiong 2015
- * api level 1
* Animation implementation
*
* WARNING: This library is in development and interfaces would be very
diff --git a/extensions/smbmfont.cpp b/extensions/smbmfont.cpp
index 598c7eb..fb550a0 100644
--- a/extensions/smbmfont.cpp
+++ b/extensions/smbmfont.cpp
@@ -2,7 +2,6 @@
/*
* Simple MultimEdia LiTerator(SMELT)
* by Chris Xiong 2015
- * api level 1
* Bitmap font support implementation
*
* WARNING: This library is in development and interfaces would be very
diff --git a/extensions/smdatapack.cpp b/extensions/smdatapack.cpp
index b707d39..78082bb 100644
--- a/extensions/smdatapack.cpp
+++ b/extensions/smdatapack.cpp
@@ -2,7 +2,6 @@
/*
* Simple MultimEdia LiTerator(SMELT)
* by Chris Xiong 2015
- * api level 1
* DaTaPack format support implementation
*
* WARNING: This library is in development and interfaces would be very
diff --git a/extensions/smentity.cpp b/extensions/smentity.cpp
index 43c81ac..ea28e74 100644
--- a/extensions/smentity.cpp
+++ b/extensions/smentity.cpp
@@ -2,7 +2,6 @@
/*
* Simple MultimEdia LiTerator(SMELT)
* by Chris Xiong 2015
- * api level 1
* Entity implementation
*
* WARNING: This library is in development and interfaces would be very
diff --git a/extensions/smgrid.cpp b/extensions/smgrid.cpp
index 292a717..d78864f 100644
--- a/extensions/smgrid.cpp
+++ b/extensions/smgrid.cpp
@@ -2,7 +2,6 @@
/*
* Simple MultimEdia LiTerator(SMELT)
* by Chris Xiong 2015
- * api level 1
* Distortion grid implementation
*
* WARNING: This library is in development and interfaces would be very
diff --git a/extensions/smttfont.cpp b/extensions/smttfont.cpp
index 9a37183..935b8a8 100644
--- a/extensions/smttfont.cpp
+++ b/extensions/smttfont.cpp
@@ -2,7 +2,6 @@
/*
* Simple MultimEdia LiTerator(SMELT)
* by Chris Xiong 2015
- * api level 1
* Truetype font support implementation
*
* WARNING: This library is in development and interfaces would be very
diff --git a/include/smanim.hpp b/include/smanim.hpp
index b206d5e..8cc4eef 100644
--- a/include/smanim.hpp
+++ b/include/smanim.hpp
@@ -2,7 +2,6 @@
/*
* Simple MultimEdia LiTerator(SMELT)
* by Chris Xiong 2015
- * api level 1
* Animation header
*
* WARNING: This library is in development and interfaces would be very
diff --git a/include/smbmfont.hpp b/include/smbmfont.hpp
index 8dffc1f..6a0f1c1 100644
--- a/include/smbmfont.hpp
+++ b/include/smbmfont.hpp
@@ -2,7 +2,6 @@
/*
* Simple MultimEdia LiTerator(SMELT)
* by Chris Xiong 2015
- * api level 1
* Bitmap font support header
*
* WARNING: This library is in development and interfaces would be very
diff --git a/include/smcolor.hpp b/include/smcolor.hpp
index 9d901de..94ff4f3 100644
--- a/include/smcolor.hpp
+++ b/include/smcolor.hpp
@@ -2,7 +2,6 @@
/*
* Simple MultimEdia LiTerator(SMELT)
* by Chris Xiong 2015
- * api level 1
* Color system header & implementation
*
* WARNING: This library is in development and interfaces would be very
diff --git a/include/smdatapack.hpp b/include/smdatapack.hpp
index ace7c81..8431b58 100644
--- a/include/smdatapack.hpp
+++ b/include/smdatapack.hpp
@@ -2,7 +2,6 @@
/*
* Simple MultimEdia LiTerator(SMELT)
* by Chris Xiong 2015
- * api level 1
* DaTaPack format support header
*
* WARNING: This library is in development and interfaces would be very
diff --git a/include/smelt.hpp b/include/smelt.hpp
index 105da2a..b5c324e 100644
--- a/include/smelt.hpp
+++ b/include/smelt.hpp
@@ -2,7 +2,7 @@
/*
* Simple MultimEdia LiTerator(SMELT)
* by Chris Xiong 2015
- * api level 1
+ * api level 2
* Public header
*
* WARNING: This library is in development and interfaces would be very
@@ -31,7 +31,7 @@
#include <stddef.h>
#include <stdint.h>
-#define SMELT_APILEVEL 1
+#define SMELT_APILEVEL 2
typedef uint32_t DWORD;
typedef uint16_t WORD;
@@ -141,6 +141,7 @@ public:
virtual SMCHN smSFXPlay(SMSFX fx,int vol=100,int pan=0,float pitch=1.,bool loop=0)=0;
virtual float smSFXGetLengthf(SMSFX fx)=0;
virtual DWORD smSFXGetLengthd(SMSFX fx)=0;
+ virtual void smSFXSetLoopPoint(SMSFX fx,DWORD l,DWORD r)=0;
virtual void smSFXFree(SMSFX fx)=0;
virtual void smChannelVol(SMCHN chn,int vol)=0;
@@ -170,6 +171,7 @@ public:
virtual bool smRenderEnd()=0;
virtual void sm3DCamera6f2v(float *pos,float *rot)=0;
virtual void sm2DCamera5f3v(float *pos,float *dpos,float *rot)=0;
+ virtual void smMultViewMatrix(float *mat)=0;
virtual void smClrscr(DWORD color)=0;
virtual void smRenderLinefd(float x1,float y1,float z1,float x2,float y2,float z2,DWORD color)=0;
virtual void smRenderLinefvd(float *p1,float *p2,DWORD color)=0;
diff --git a/include/smentity.hpp b/include/smentity.hpp
index 7ecb8ee..54fb3fb 100644
--- a/include/smentity.hpp
+++ b/include/smentity.hpp
@@ -2,7 +2,6 @@
/*
* Simple MultimEdia LiTerator(SMELT)
* by Chris Xiong 2015
- * api level 1
* Entity header
*
* WARNING: This library is in development and interfaces would be very
diff --git a/include/smgrid.hpp b/include/smgrid.hpp
index acd808c..ce1aabb 100644
--- a/include/smgrid.hpp
+++ b/include/smgrid.hpp
@@ -2,7 +2,6 @@
/*
* Simple MultimEdia LiTerator(SMELT)
* by Chris Xiong 2015
- * api level 1
* Distortion grid header
*
* WARNING: This library is in development and interfaces would be very
diff --git a/include/smindicator.hpp b/include/smindicator.hpp
index 5237a3b..0595dc8 100644
--- a/include/smindicator.hpp
+++ b/include/smindicator.hpp
@@ -2,7 +2,6 @@
/*
* Simple MultimEdia LiTerator(SMELT)
* by Chris Xiong 2015
- * api level 1
* Indicator header & implementation
*
* WARNING: This library is in development and interfaces would be very
@@ -14,16 +13,17 @@
#include "smelt.hpp"
#include "smmath.hpp"
#include "smcolor.hpp"
+#include "smentity.hpp"
#include "smgrid.hpp"
class indicatorCircular
{
private:
smGrid *circle;
- double value,radius,thickness;
+ float value,radius,thickness;
DWORD color;
BYTE alpha;
public:
- void init(double r,double thkns,BYTE a,SMTEX tex,smTexRect tr)
+ void init(float r,float thkns,BYTE a,SMTEX tex,smTexRect tr)
{
circle=new smGrid(1025,3);
circle->setTexture(tex);
@@ -31,8 +31,8 @@ public:
radius=r;thickness=thkns;alpha=a;color=0;
for(int i=0;i<=1024;++i)
{
- double tang,tx,ty;
- tang=(double)i/1024.*PI*2-PI/2;
+ float tang,tx,ty;
+ tang=(float)i/1024.*PI*2-PI/2;
tx=-cos(tang)*radius;ty=sin(tang)*radius;
circle->setPos(i,2,tx,ty,0.5,GRID_REFTOPLEFT);
tx=-cos(tang)*(radius-thickness);ty=sin(tang)*(radius-thickness);
@@ -43,7 +43,7 @@ public:
}
void overrideColor(DWORD col){color=col;}
void setAlpha(BYTE a){alpha=a;}
- void setValue(double v)
+ void setValue(float v)
{
value=v;
for(int i=0;i<=1024;++i)
@@ -55,7 +55,7 @@ public:
if(tc->v<0.85)tc->v=0.85;
tcolor=color?SETA(color,alpha):SETA(tc->getHWColor(),alpha);
delete tc;
- if((double)i/1024.<=value)
+ if((float)i/1024.<=value)
{
circle->setColor(i,2,tcolor);
circle->setColor(i,1,SETA(0x00FFFFFF,alpha));
@@ -72,4 +72,42 @@ public:
void render(float x,float y){circle->render(x,y);}
void deinit(){delete circle;circle=NULL;}
};
+class indicatorLinear
+{
+private:
+ smEntity2D *upper,*lower;
+ float value,maxlength,thickness;
+ DWORD color;smTexRect trect;
+ BYTE alpha;
+public:
+ void init(float ml,float thkns,BYTE a,SMTEX tex,smTexRect tr)
+ {
+ upper=new smEntity2D(tex,tr.x,tr.y,tr.w,tr.h/2);
+ lower=new smEntity2D(tex,tr.x,tr.y+tr.h/2,tr.w,tr.h/2);
+ maxlength=ml;thickness=thkns;alpha=a;color=0;trect=tr;
+ }
+ void overrideColor(DWORD col){color=col;}
+ void setAlpha(BYTE a){alpha=a;}
+ void setValue(float v)
+ {
+ value=v;
+ int tr=(int)((1.0f-value)*255);
+ int tg=(int)(value*255);
+ DWORD tcolor=ARGB(alpha,tr,tg,0);
+ smColorHSVA *tc=new smColorHSVA(tcolor);
+ if(tc->v<0.85)tc->v=0.85;
+ tcolor=color?SETA(color,alpha):SETA(tc->getHWColor(),alpha);
+ delete tc;
+ upper->setColor(tcolor,0);upper->setColor(tcolor,1);
+ upper->setColor(0,2);upper->setColor(0,3);
+ lower->setColor(0,0);lower->setColor(0,1);
+ lower->setColor(tcolor,2);lower->setColor(tcolor,3);
+ }
+ void render(float x,float y)
+ {
+ upper->render(x,y,0,value*maxlength/trect.w,thickness/trect.h/2);
+ lower->render(x,y+thickness/2,0,value*maxlength/trect.w,thickness/trect.h/2);
+ }
+ void deinit(){delete upper;delete lower;upper=lower=NULL;}
+};
#endif
diff --git a/include/smmath.hpp b/include/smmath.hpp
index 805df50..5172772 100644
--- a/include/smmath.hpp
+++ b/include/smmath.hpp
@@ -2,7 +2,6 @@
/*
* Simple MultimEdia LiTerator(SMELT)
* by Chris Xiong 2015
- * api level 1
* Math header & implementation
*
* WARNING: This library is in development and interfaces would be very
@@ -105,6 +104,16 @@ public:
tmp[3][3]=1;
*this=*this*tmp;
}
+ void lookat(double *eye,double *at,double *up)
+ {
+ smvec3d f=smvec3d(at[0],at[1],at[2])-smvec3d(eye[0],eye[1],eye[2]);f.normalize();
+ smvec3d UP=smvec3d(up[0],up[1],up[2]);UP.normalize();
+ smvec3d s=f*UP;smvec3d u=s.getNormalized()*f;
+ *this[0][0]= s.x;*this[1][0]= s.y;*this[2][0]= s.z;*this[3][0]=0;
+ *this[0][1]= u.x;*this[1][1]= u.y;*this[2][1]= u.z;*this[3][1]=0;
+ *this[0][2]=-f.x;*this[1][2]=-f.y;*this[2][2]=-f.z;*this[3][2]=0;
+ *this[0][3]= 0;*this[1][3]= 0;*this[2][3]= 0;*this[3][3]=1;
+ }
friend smMatrix operator *(smMatrix a,smMatrix b)
{
smMatrix ret;
diff --git a/include/smprogresser.hpp b/include/smprogresser.hpp
index ca81e62..50edd2d 100644
--- a/include/smprogresser.hpp
+++ b/include/smprogresser.hpp
@@ -2,7 +2,6 @@
/*
* Simple MultimEdia LiTerator(SMELT)
* by Chris Xiong 2015
- * api level 1
* Progresser header & implementation
*
* WARNING: This library is in development and interfaces would be very
diff --git a/include/smrandom.hpp b/include/smrandom.hpp
index 9c47941..ed560e0 100644
--- a/include/smrandom.hpp
+++ b/include/smrandom.hpp
@@ -2,7 +2,6 @@
/*
* Simple MultimEdia LiTerator(SMELT)
* by Chris Xiong 2015
- * api level 1
* Random engine header & implementation
*
* WARNING: This library is in development and interfaces would be very
diff --git a/include/smttfont.hpp b/include/smttfont.hpp
index 2fd96d5..777d8ed 100644
--- a/include/smttfont.hpp
+++ b/include/smttfont.hpp
@@ -2,7 +2,6 @@
/*
* Simple MultimEdia LiTerator(SMELT)
* by Chris Xiong 2015
- * api level 1
* Truetype font support header
*
* WARNING: This library is in development and interfaces would be very
diff --git a/smelt/sdl/gfx_sdl.cpp b/smelt/sdl/gfx_sdl.cpp
index 4ad7404..3fd3b46 100644
--- a/smelt/sdl/gfx_sdl.cpp
+++ b/smelt/sdl/gfx_sdl.cpp
@@ -2,7 +2,6 @@
/*
* Simple MultimEdia LiTerator(SMELT)
* by Chris Xiong 2015
- * api level 1
* GFX implementation based on SDL2/OpenGL and hge-unix
*
* WARNING: This library is in development and interfaces would be very
@@ -116,6 +115,11 @@ void SMELT_IMPL::sm3DCamera6f2v(float *pos,float *rot)
pOpenGLDevice->glRotatef((GLfloat)-rot[2],0,0,1);
pOpenGLDevice->glTranslatef((GLfloat)-pos[0],(GLfloat)-pos[1],(GLfloat)-pos[2]);
}
+void SMELT_IMPL::smMultViewMatrix(float *mat)
+{
+ pOpenGLDevice->glMatrixMode(GL_MODELVIEW);
+ pOpenGLDevice->glMultMatrixf(mat);
+}
void SMELT_IMPL::sm2DCamera5f3v(float *pos,float *dpos,float *rot)
{
batchOGL();
diff --git a/smelt/sdl/sfx_sdl.cpp b/smelt/sdl/sfx_sdl.cpp
index afc8f68..10a207c 100644
--- a/smelt/sdl/sfx_sdl.cpp
+++ b/smelt/sdl/sfx_sdl.cpp
@@ -2,7 +2,6 @@
/*
* Simple MultimEdia LiTerator(SMELT)
* by Chris Xiong 2015
- * api level 1
* GFX implementation based on OpenAL
*
* WARNING: This library is in development and interfaces would be very
@@ -90,6 +89,14 @@ DWORD SMELT_IMPL::smSFXGetLengthd(SMSFX fx)
}
return -1;
}
+void SMELT_IMPL::smSFXSetLoopPoint(SMSFX fx,DWORD l,DWORD r)
+{
+ if(pOpenALDevice)
+ {
+ ALint pt[2];pt[0]=l;pt[1]=r;
+ alBufferiv((ALuint)fx,AL_LOOP_POINTS_SOFT,pt);
+ }
+}
void SMELT_IMPL::smSFXFree(SMSFX fx)
{
if(pOpenALDevice)
@@ -299,6 +306,9 @@ bool SMELT_IMPL::initOAL()
smLog("%s:"SLINE": AL_VENDOR: %s\n",SFX_SDL_SRCFN,(char*)alGetString(AL_VENDOR));
smLog("%s:"SLINE": AL_RENDERER: %s\n",SFX_SDL_SRCFN,(char*)alGetString(AL_RENDERER));
smLog("%s:"SLINE": AL_VERSION: %s\n",SFX_SDL_SRCFN,(char*)alGetString(AL_VERSION));
+ const char* ext=(const char*)alGetString(AL_EXTENSIONS);
+ lpp=strstr(ext,"AL_SOFT_loop_points")!=NULL;
+ if(!lpp)smLog("%s:"SLINE": Warning: loop points not supported. Please recompile with OpenAL Soft.\n",SFX_SDL_SRCFN);
pOpenALDevice=(void*)dev;
return true;
}
diff --git a/smelt/sdl/smelt_internal.hpp b/smelt/sdl/smelt_internal.hpp
index a84050f..8b36ebf 100644
--- a/smelt/sdl/smelt_internal.hpp
+++ b/smelt/sdl/smelt_internal.hpp
@@ -2,7 +2,6 @@
/*
* Simple MultimEdia LiTerator(SMELT)
* by Chris Xiong 2015
- * api level 1
* Internal header for SDL version
*
* WARNING: This library is in development and interfaces would be very
@@ -113,6 +112,7 @@ public:
virtual SMCHN smSFXPlay(SMSFX fx,int vol=100,int pan=0,float pitch=1.,bool loop=0);
virtual float smSFXGetLengthf(SMSFX fx);
virtual DWORD smSFXGetLengthd(SMSFX fx);
+ virtual void smSFXSetLoopPoint(SMSFX fx,DWORD l,DWORD r);
virtual void smSFXFree(SMSFX fx);
virtual void smChannelVol(SMCHN chn,int vol);
@@ -142,6 +142,7 @@ public:
virtual bool smRenderEnd();
virtual void sm3DCamera6f2v(float *pos,float *rot);
virtual void sm2DCamera5f3v(float *pos,float *dpos,float *rot);
+ virtual void smMultViewMatrix(float *mat);
virtual void smClrscr(DWORD color);
virtual void smRenderLinefd(float x1,float y1,float z1,float x2,float y2,float z2,DWORD color);
virtual void smRenderLinefvd(float *p1,float *p2,DWORD color);
@@ -217,7 +218,7 @@ public:
void *pOpenALDevice;
bool initOAL();
void finiOAL();
- bool mute;
+ bool mute,lpp;
int scnt;
ALuint src[SRC_MAX];
ALuint getSource();
diff --git a/smelt/sdl/sys_sdl.cpp b/smelt/sdl/sys_sdl.cpp
index f489c9d..1892069 100644
--- a/smelt/sdl/sys_sdl.cpp
+++ b/smelt/sdl/sys_sdl.cpp
@@ -2,7 +2,6 @@
/*
* Simple MultimEdia LiTerator(SMELT)
* by Chris Xiong 2015
- * api level 1
* SMELT system implementation
*
* WARNING: This library is in development and interfaces would be very