diff options
author | Chris Xiong <chirs241097@gmail.com> | 2016-01-07 23:54:06 +0800 |
---|---|---|
committer | Chris Xiong <chirs241097@gmail.com> | 2016-01-07 23:54:06 +0800 |
commit | 1d64816653b5d1835dd60762c2bc64f000d88fa5 (patch) | |
tree | 62817d39f4713d0f41ff275a21e25a31017c2a1e /smelt | |
parent | 49e67bc8566e8c5017b931837792a648cb0048c2 (diff) | |
download | SMELT-1d64816653b5d1835dd60762c2bc64f000d88fa5.tar.xz |
Add a new way to hook into smelt.
Diffstat (limited to 'smelt')
-rw-r--r-- | smelt/sdl/glimports.hpp | 28 | ||||
-rw-r--r-- | smelt/sdl/makefile | 30 | ||||
-rw-r--r-- | smelt/sdl/sfx_dumb.cpp | 74 | ||||
-rw-r--r-- | smelt/sdl/smelt_internal.hpp | 2 | ||||
-rw-r--r-- | smelt/sdl/sys_sdl.cpp | 8 |
5 files changed, 118 insertions, 24 deletions
diff --git a/smelt/sdl/glimports.hpp b/smelt/sdl/glimports.hpp index 3c0a54f..c16d69a 100644 --- a/smelt/sdl/glimports.hpp +++ b/smelt/sdl/glimports.hpp @@ -6,36 +6,36 @@ GL_PROC(base_opengl,glGetError,,GLenum,(void)) GL_PROC(base_opengl,glDepthMask,,void,(GLboolean flag)) GL_PROC(base_opengl,glDepthRange,,void,(GLclampd zNear, GLclampd zFar)) GL_PROC(base_opengl,glBlendFunc,,void,(GLenum sfactor, GLenum dfactor)) -GL_PROC(base_opengl,glAlphaFunc,,void,(GLenum func, GLclampf ref)) +GL_PROC(base_opengl,glAlphaFunc,,void,(GLenum func, GLclampf ref))//** GL_PROC(base_opengl,glDepthFunc,,void,(GLenum func)) -GL_PROC(base_opengl,glMatrixMode,,void,(GLenum mode)) -GL_PROC(base_opengl,glMultMatrixf,,void,(GLfloat *m)) -GL_PROC(base_opengl,glLoadIdentity,,void,(void)) -GL_PROC(base_opengl,glScalef,,void,(GLfloat x, GLfloat y, GLfloat z)) +GL_PROC(base_opengl,glMatrixMode,,void,(GLenum mode))//** +GL_PROC(base_opengl,glMultMatrixf,,void,(GLfloat *m))//** +GL_PROC(base_opengl,glLoadIdentity,,void,(void))//** +GL_PROC(base_opengl,glScalef,,void,(GLfloat x, GLfloat y, GLfloat z))//** GL_PROC(base_opengl,glViewport,,void,(GLint x, GLint y, GLsizei width, GLsizei height)) -GL_PROC(base_opengl,glTranslatef,,void,(GLfloat x, GLfloat y, GLfloat z)) -GL_PROC(base_opengl,glRotatef,,void,(GLfloat angle, GLfloat x, GLfloat y, GLfloat z)) -GL_PROC(base_opengl,glOrtho,,void,(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar)) +GL_PROC(base_opengl,glTranslatef,,void,(GLfloat x, GLfloat y, GLfloat z))//** +GL_PROC(base_opengl,glRotatef,,void,(GLfloat angle, GLfloat x, GLfloat y, GLfloat z))//** +GL_PROC(base_opengl,glOrtho,,void,(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar))//** GL_PROC(base_opengl,glScissor,,void,(GLint x, GLint y, GLsizei width, GLsizei height)) GL_PROC(base_opengl,glClearColor,,void,(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)) GL_PROC(base_opengl,glClearDepth,,void,(GLclampd depth)) GL_PROC(base_opengl,glClear,,void,(GLbitfield mask)) GL_PROC(base_opengl,glPixelStorei,,void,(GLenum pname, GLint param)) GL_PROC(base_opengl,glBindTexture,,void,(GLenum target, GLuint texture)) -GL_PROC(base_opengl,glTexEnvi,,void,(GLenum target, GLenum pname, GLint param)) +GL_PROC(base_opengl,glTexEnvi,,void,(GLenum target, GLenum pname, GLint param))//** GL_PROC(base_opengl,glTexParameterf,,void,(GLenum target, GLenum pname, GLfloat param)) GL_PROC(base_opengl,glTexParameteri,,void,(GLenum target, GLenum pname, GLint param)) GL_PROC(base_opengl,glTexImage2D,,void,(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels)) GL_PROC(base_opengl,glTexSubImage2D,,void,(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels)) GL_PROC(base_opengl,glGenTextures,,void,(GLsizei n, GLuint *textures)) GL_PROC(base_opengl,glDeleteTextures,,void,(GLsizei n, const GLuint *textures)) -GL_PROC(base_opengl,glVertexPointer,,void,(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)) -GL_PROC(base_opengl,glColorPointer,,void,(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)) -GL_PROC(base_opengl,glTexCoordPointer,,void,(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)) +GL_PROC(base_opengl,glVertexPointer,,void,(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer))//** +GL_PROC(base_opengl,glColorPointer,,void,(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer))//** +GL_PROC(base_opengl,glTexCoordPointer,,void,(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer))//** GL_PROC(base_opengl,glDrawArrays,,void,(GLenum mode, GLint first, GLsizei count)) GL_PROC(base_opengl,glDrawElements,,void,(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices)) -GL_PROC(base_opengl,glEnableClientState,,void,(GLenum array)) -GL_PROC(base_opengl,glFinish,,void,(void)) +GL_PROC(base_opengl,glEnableClientState,,void,(GLenum array))//** +GL_PROC(base_opengl,glFinish,,void,(void))//** GL_PROC(base_opengl,glReadPixels,,void,(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels)) GL_PROC(GL_EXT_framebuffer_object,glBindRenderbufferEXT,,void,(GLenum target, GLuint name)) diff --git a/smelt/sdl/makefile b/smelt/sdl/makefile index aa9acb8..09d9237 100644 --- a/smelt/sdl/makefile +++ b/smelt/sdl/makefile @@ -1,13 +1,29 @@ CC= g++ -CXXFLAGS= -c -std=c++11 -Wall -I/usr/include/SDL/ -I../include -D_LINUX +CXXFLAGS= -c -g -std=c++11 -Wall -I/usr/include/SDL/ -I../include -D_LINUX -all: objects archive clean +all: objects-normal archive-normal -objects: - $(CC) *.cpp $(CXXFLAGS) -archive: - $(AR) rcs libsmelt.a *.o +dumb: objects-dumb archive-dumb + +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 clean: - if ( test gfx_sdl.o ); then rm *.o; fi + rm -f *.o clean-all: clean rm *.a
\ No newline at end of file diff --git a/smelt/sdl/sfx_dumb.cpp b/smelt/sdl/sfx_dumb.cpp new file mode 100644 index 0000000..4e7a277 --- /dev/null +++ b/smelt/sdl/sfx_dumb.cpp @@ -0,0 +1,74 @@ +// -*- C++ -*- +/* + * Simple MultimEdia LiTerator(SMELT) + * by Chris Xiong 2015 + * SFX dumb implementation + * 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. + * + */ +#include "smelt_internal.hpp" + +static const char* SFX_SDL_SRCFN="smelt/sdl/sfx_dumb.cpp"; + +SMSFX SMELT_IMPL::smSFXLoad(const char *path) +{return 0;} +SMSFX SMELT_IMPL::smSFXLoadFromMemory(const char *ptr,DWORD size) +{return 0;} +SMCHN SMELT_IMPL::smSFXPlay(SMSFX fx,int vol,int pan,float pitch,bool loop) +{return 0;} +float SMELT_IMPL::smSFXGetLengthf(SMSFX fx) +{return 0.0;} +DWORD SMELT_IMPL::smSFXGetLengthd(SMSFX fx) +{return -1;} +void SMELT_IMPL::smSFXSetLoopPoint(SMSFX fx,DWORD l,DWORD r) +{} +void SMELT_IMPL::smSFXFree(SMSFX fx) +{} +void SMELT_IMPL::smChannelVol(SMCHN chn,int vol) +{} +void SMELT_IMPL::smChannelPan(SMCHN chn,int pan) +{} +void SMELT_IMPL::smChannelPitch(SMCHN chn,float pitch) +{} +void SMELT_IMPL::smChannelPause(SMCHN chn) +{} +void SMELT_IMPL::smChannelResume(SMCHN chn) +{} +void SMELT_IMPL::smChannelStop(SMCHN chn) +{} +void SMELT_IMPL::smChannelPauseAll() +{} +void SMELT_IMPL::smChannelResumeAll() +{} +void SMELT_IMPL::smChannelStopAll() +{} +bool SMELT_IMPL::smChannelIsPlaying(SMCHN chn) +{return false;} +float SMELT_IMPL::smChannelGetPosf(SMCHN chn) +{return -1.;} +void SMELT_IMPL::smChannelSetPosf(SMCHN chn,float pos) +{} +int SMELT_IMPL::smChannelGetPosd(SMCHN chn) +{return -1;} +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/smelt_internal.hpp b/smelt/sdl/smelt_internal.hpp index a434079..c3cfa89 100644 --- a/smelt/sdl/smelt_internal.hpp +++ b/smelt/sdl/smelt_internal.hpp @@ -89,6 +89,7 @@ public: virtual void smFinale(); virtual void smMainLoop(); virtual void smUpdateFunc(smHook func); + virtual void smUpdateFunc(smHandler* h); virtual void smUnFocFunc(smHook func); virtual void smFocFunc(smHook func); virtual void smQuitFunc(smHook func); @@ -174,6 +175,7 @@ public: bool (*pUnFocFunc)(); bool (*pFocFunc)(); bool (*pQuitFunc)(); + smHandler *updateHandler; const char *Icon; char winTitle[256]; int scrw,scrh; diff --git a/smelt/sdl/sys_sdl.cpp b/smelt/sdl/sys_sdl.cpp index 27a9e7b..675d88f 100644 --- a/smelt/sdl/sys_sdl.cpp +++ b/smelt/sdl/sys_sdl.cpp @@ -150,7 +150,7 @@ void SMELT_IMPL::smFinale() void SMELT_IMPL::smMainLoop() { if(!hwnd)return smLog("%s:" SLINE ": Error: SMELT is not initialized.\n",SYS_SDL_SRCFN); - if(!pUpdateFunc) return smLog("%s:" SLINE ": UpdateFunc is not defined.\n",SYS_SDL_SRCFN); + if(!pUpdateFunc&&!updateHandler) return smLog("%s:" SLINE ": UpdateFunc is not defined.\n",SYS_SDL_SRCFN); Active=true; for(;;) { @@ -168,7 +168,8 @@ void SMELT_IMPL::smMainLoop() if(timeDelta>0.2)timeDelta=fixDelta?fixDelta/1000.:.01; ++fcnt;updateFPSDelay+=timeDelta;t0=sdlticks;timeS+=timeDelta; if(updateFPSDelay>1){fps=fcnt/updateFPSDelay;updateFPSDelay=.0;fcnt=0;} - if(pUpdateFunc())break; + if(pUpdateFunc){if(pUpdateFunc())break;} + if(updateHandler){if(updateHandler->handlerFunc())break;} for(int i=1;i<=255;++i)keylst[i]=((keyz[i]&4)!=0); clearQueue(); } @@ -179,6 +180,7 @@ void SMELT_IMPL::smMainLoop() clearQueue();Active=false; } void SMELT_IMPL::smUpdateFunc(smHook func){pUpdateFunc=func;} +void SMELT_IMPL::smUpdateFunc(smHandler* h){updateHandler=h;} void SMELT_IMPL::smUnFocFunc(smHook func){pUnFocFunc=func;} void SMELT_IMPL::smFocFunc(smHook func){pFocFunc=func;} void SMELT_IMPL::smQuitFunc(smHook func){pQuitFunc=func;} @@ -248,7 +250,7 @@ float SMELT_IMPL::smGetTime(){return timeS;} SMELT_IMPL::SMELT_IMPL() { hwnd=NULL;Active=false;memset(curError,0,sizeof(curError)); - pUpdateFunc=pUnFocFunc=pFocFunc=pQuitFunc=NULL; + pUpdateFunc=pUnFocFunc=pFocFunc=pQuitFunc=NULL;updateHandler=NULL; Icon=NULL;strcpy(winTitle,"untitled");scrw=dispw=800;scrh=disph=600; windowed=vsync=false;memset(logFile,0,sizeof(logFile)); limfps=0;hideMouse=true;noSuspend=false; |