diff options
Diffstat (limited to 'smelt')
-rw-r--r-- | smelt/sdl/CxImage/makefile | 12 | ||||
-rw-r--r-- | smelt/sdl/gfx_sdl.cpp | 40 | ||||
-rw-r--r-- | smelt/sdl/inp_sdl.cpp | 2 | ||||
-rw-r--r-- | smelt/sdl/makefile | 13 | ||||
-rw-r--r-- | smelt/sdl/sfx_sdl.cpp | 16 | ||||
-rw-r--r-- | smelt/sdl/sys_sdl.cpp | 34 |
6 files changed, 71 insertions, 46 deletions
diff --git a/smelt/sdl/CxImage/makefile b/smelt/sdl/CxImage/makefile new file mode 100644 index 0000000..6dcb28b --- /dev/null +++ b/smelt/sdl/CxImage/makefile @@ -0,0 +1,12 @@ +CC= g++ +CXXFLAGS= -c -Os -D_LINUX +AR= ar + +all: objects archive clean + +objects: + $(CC) *.cpp $(CXXFLAGS) +archive: + $(AR) rcs libCxImage.a *.o +clean: + rm *.o && mv libCxImage.a ../ diff --git a/smelt/sdl/gfx_sdl.cpp b/smelt/sdl/gfx_sdl.cpp index 8c028ca..47b6999 100644 --- a/smelt/sdl/gfx_sdl.cpp +++ b/smelt/sdl/gfx_sdl.cpp @@ -24,7 +24,7 @@ bool SMELT_IMPL::smRenderBegin2D(bool ztest,SMTRG trg) { TRenderTargetList *targ=(TRenderTargetList*)trg; if(vertexArray) - {smLog("%s:"SLINE": Last frame not closed.\n",GFX_SDL_SRCFN);return false;} + {smLog("%s:" SLINE ": Last frame not closed.\n",GFX_SDL_SRCFN);return false;} if(pOpenGLDevice->have_GL_EXT_framebuffer_object) pOpenGLDevice->glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,(targ)?targ->frame:0); pOpenGLDevice->glDepthFunc(GL_GEQUAL); @@ -51,7 +51,7 @@ bool SMELT_IMPL::smRenderBegin3D(float fov,SMTRG trg) { TRenderTargetList *targ=(TRenderTargetList*)trg; if(vertexArray) - {smLog("%s:"SLINE": Last frame not closed.\n",GFX_SDL_SRCFN);return false;} + {smLog("%s:" SLINE ": Last frame not closed.\n",GFX_SDL_SRCFN);return false;} if(pOpenGLDevice->have_GL_EXT_framebuffer_object) pOpenGLDevice->glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,(targ)?targ->frame:0); pOpenGLDevice->glDepthFunc(GL_LESS); @@ -230,7 +230,7 @@ SMTRG SMELT_IMPL::smTargetCreate(int w,int h) ok=buildTarget(pTarget,gltex->name,w,h); if(!ok) { - smLog("%s:"SLINE": Failed to create render target.\n",GFX_SDL_SRCFN); + smLog("%s:" SLINE ": Failed to create render target.\n",GFX_SDL_SRCFN); smTextureFree(pTarget->tex); delete pTarget; return 0; @@ -642,7 +642,7 @@ void SMELT_IMPL::batchOGL(bool endScene) { printf("idxbuf:%d\n",indexBuf[i]); printf("QUAD'S TRIANGLE:\n"); -#define printVertex(a) printf("(%.2f,%.2f,%.2f),0x%lX,(%.2f,%.2f)\n",a.x,a.y,a.z,a.col,a.tx,a.ty); +#define printVertex(a) printf("(%.2f,%.2f,%.2f),0x%X,(%.2f,%.2f)\n",a.x,a.y,a.z,a.col,a.tx,a.ty); printf("#%d: ",indexBuf[i+0]);printVertex(vertexBuf[indexBuf[i+0]]); printf("#%d: ",indexBuf[i+1]);printVertex(vertexBuf[indexBuf[i+1]]); printf("#%d: ",indexBuf[i+2]);printVertex(vertexBuf[indexBuf[i+2]]); @@ -694,7 +694,7 @@ bool SMELT_IMPL::checkGLExtension(const char *extlist,const char *ext) } bool SMELT_IMPL::loadGLEntryPoints() { - smLog("%s:"SLINE": OpenGL: loading entry points and examining extensions...\n",GFX_SDL_SRCFN); + smLog("%s:" SLINE ": OpenGL: loading entry points and examining extensions...\n",GFX_SDL_SRCFN); pOpenGLDevice->have_base_opengl=true; pOpenGLDevice->have_GL_ARB_texture_rectangle=true; pOpenGLDevice->have_GL_ARB_texture_non_power_of_two=true; @@ -717,15 +717,15 @@ bool SMELT_IMPL::loadGLEntryPoints() unloadGLEntryPoints(); return false; } - smLog("%s:"SLINE": GL_RENDERER: %s\n",GFX_SDL_SRCFN,(const char *)pOpenGLDevice->glGetString(GL_RENDERER)); - smLog("%s:"SLINE": GL_VENDOR: %s\n",GFX_SDL_SRCFN,(const char *)pOpenGLDevice->glGetString(GL_VENDOR)); - smLog("%s:"SLINE": GL_VERSION: %s\n",GFX_SDL_SRCFN,(const char *)pOpenGLDevice->glGetString(GL_VERSION)); + smLog("%s:" SLINE ": GL_RENDERER: %s\n",GFX_SDL_SRCFN,(const char *)pOpenGLDevice->glGetString(GL_RENDERER)); + smLog("%s:" SLINE ": GL_VENDOR: %s\n",GFX_SDL_SRCFN,(const char *)pOpenGLDevice->glGetString(GL_VENDOR)); + smLog("%s:" SLINE ": GL_VERSION: %s\n",GFX_SDL_SRCFN,(const char *)pOpenGLDevice->glGetString(GL_VERSION)); const char *verstr=(const char*)pOpenGLDevice->glGetString(GL_VERSION); int maj=0,min=0; sscanf(verstr,"%d.%d",&maj,&min); if((maj<1)||((maj==1)&&(min<2))) { - smLog("%s:"SLINE": OpenGL implementation must be at least version 1.2.\n",GFX_SDL_SRCFN); + smLog("%s:" SLINE ": OpenGL implementation must be at least version 1.2.\n",GFX_SDL_SRCFN); unloadGLEntryPoints(); return false; } @@ -738,35 +738,35 @@ bool SMELT_IMPL::loadGLEntryPoints() maj>=2||checkGLExtension(exts,"GL_ARB_texture_non_power_of_two"); if(pOpenGLDevice->have_GL_ARB_texture_rectangle) { - smLog("%s:"SLINE": OpenGL: Using GL_ARB_texture_rectangle.\n",GFX_SDL_SRCFN); + smLog("%s:" SLINE ": OpenGL: Using GL_ARB_texture_rectangle.\n",GFX_SDL_SRCFN); pOpenGLDevice->TextureTarget=GL_TEXTURE_RECTANGLE_ARB; } else if(pOpenGLDevice->have_GL_ARB_texture_non_power_of_two) { - smLog("%s:"SLINE": OpenGL: Using GL_ARB_texture_non_power_of_two.\n",GFX_SDL_SRCFN); + smLog("%s:" SLINE ": OpenGL: Using GL_ARB_texture_non_power_of_two.\n",GFX_SDL_SRCFN); pOpenGLDevice->TextureTarget=GL_TEXTURE_2D; } else { - smLog("%s:"SLINE": OpenGL: Using power-of-two textures. This costs more memory!\n",GFX_SDL_SRCFN); + smLog("%s:" SLINE ": OpenGL: Using power-of-two textures. This costs more memory!\n",GFX_SDL_SRCFN); pOpenGLDevice->TextureTarget=GL_TEXTURE_2D; } if(pOpenGLDevice->have_GL_EXT_framebuffer_object) pOpenGLDevice->have_GL_EXT_framebuffer_object= checkGLExtension(exts, "GL_EXT_framebuffer_object"); if(pOpenGLDevice->have_GL_EXT_framebuffer_object) - smLog("%s:"SLINE": OpenGL: Using GL_EXT_framebuffer_object.\n",GFX_SDL_SRCFN); + smLog("%s:" SLINE ": OpenGL: Using GL_EXT_framebuffer_object.\n",GFX_SDL_SRCFN); else - smLog("%s:"SLINE": OpenGL: WARNING! No render-to-texture support. Things may render badly.\n",GFX_SDL_SRCFN); + smLog("%s:" SLINE ": OpenGL: WARNING! No render-to-texture support. Things may render badly.\n",GFX_SDL_SRCFN); if(pOpenGLDevice->have_GL_EXT_texture_compression_s3tc) pOpenGLDevice->have_GL_EXT_texture_compression_s3tc= checkGLExtension(exts,"GL_ARB_texture_compression")&& checkGLExtension(exts,"GL_EXT_texture_compression_s3tc"); if(pOpenGLDevice->have_GL_EXT_texture_compression_s3tc) - smLog("%s:"SLINE": OpenGL: Using GL_EXT_texture_compression_s3tc.\n",GFX_SDL_SRCFN); + smLog("%s:" SLINE ": OpenGL: Using GL_EXT_texture_compression_s3tc.\n",GFX_SDL_SRCFN); else if (true) { - smLog("%s:"SLINE": OpenGL: Texture compression disabled!\n",GFX_SDL_SRCFN); + smLog("%s:" SLINE ": OpenGL: Texture compression disabled!\n",GFX_SDL_SRCFN); } if(pOpenGLDevice->have_GL_ARB_vertex_buffer_object) { @@ -774,18 +774,18 @@ bool SMELT_IMPL::loadGLEntryPoints() checkGLExtension(exts,"GL_ARB_vertex_buffer_object"); } if(pOpenGLDevice->have_GL_ARB_vertex_buffer_object) - smLog("%s:"SLINE": OpenGL: Using GL_ARB_vertex_buffer_object.\n",GFX_SDL_SRCFN); + smLog("%s:" SLINE ": OpenGL: Using GL_ARB_vertex_buffer_object.\n",GFX_SDL_SRCFN); else - smLog("%s:"SLINE": OpenGL: WARNING! No VBO support; performance may suffer.\n",GFX_SDL_SRCFN); + smLog("%s:" SLINE ": OpenGL: WARNING! No VBO support; performance may suffer.\n",GFX_SDL_SRCFN); return true; } bool SMELT_IMPL::initOGL() { primTex=0; - if(pOpenGLDevice){smLog("%s:"SLINE": Multiple initialization!\n",GFX_SDL_SRCFN);return false;} + if(pOpenGLDevice){smLog("%s:" SLINE ": Multiple initialization!\n",GFX_SDL_SRCFN);return false;} pOpenGLDevice=new TOpenGLDevice; if(!loadGLEntryPoints())return false; - smLog("%s:"SLINE": Mode: %d x %d\n",GFX_SDL_SRCFN,scrw,scrh); + smLog("%s:" SLINE ": Mode: %d x %d\n",GFX_SDL_SRCFN,scrw,scrh); vertexArray=NULL;textures=NULL;IndexBufferObject=0; if(!confOGL())return false; pOpenGLDevice->glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); diff --git a/smelt/sdl/inp_sdl.cpp b/smelt/sdl/inp_sdl.cpp index a18baa9..c1e05de 100644 --- a/smelt/sdl/inp_sdl.cpp +++ b/smelt/sdl/inp_sdl.cpp @@ -9,7 +9,7 @@ * */ #include "smelt_internal.hpp" -static const char* INP_SDL_SRCFN="smelt/sdl/inp_sdl.cpp"; +//static const char* INP_SDL_SRCFN="smelt/sdl/inp_sdl.cpp"; bool SMELT_IMPL::smGetInpEvent(smInpEvent *e) { TInputEventList *eptr; diff --git a/smelt/sdl/makefile b/smelt/sdl/makefile new file mode 100644 index 0000000..aa9acb8 --- /dev/null +++ b/smelt/sdl/makefile @@ -0,0 +1,13 @@ +CC= g++ +CXXFLAGS= -c -std=c++11 -Wall -I/usr/include/SDL/ -I../include -D_LINUX + +all: objects archive clean + +objects: + $(CC) *.cpp $(CXXFLAGS) +archive: + $(AR) rcs libsmelt.a *.o +clean: + if ( test gfx_sdl.o ); then rm *.o; fi +clean-all: clean + rm *.a
\ No newline at end of file diff --git a/smelt/sdl/sfx_sdl.cpp b/smelt/sdl/sfx_sdl.cpp index 10a207c..b61a8a0 100644 --- a/smelt/sdl/sfx_sdl.cpp +++ b/smelt/sdl/sfx_sdl.cpp @@ -287,28 +287,28 @@ bool SMELT_IMPL::initOAL() { if(pOpenALDevice)return true; scnt=0;memset(src,0,sizeof(src)); - smLog("%s:"SLINE": Initializing OpenAL...\n",SFX_SDL_SRCFN); + smLog("%s:" SLINE ": Initializing OpenAL...\n",SFX_SDL_SRCFN); ALCdevice *dev=alcOpenDevice(NULL); if(!dev) { - smLog("%s:"SLINE": alcOpenDevice() failed.\n",SFX_SDL_SRCFN); + smLog("%s:" SLINE ": alcOpenDevice() failed.\n",SFX_SDL_SRCFN); return mute=true; } ALint caps[]={ALC_FREQUENCY,44100,0}; ALCcontext *ctx=alcCreateContext(dev,caps); if(!ctx) { - smLog("%s:"SLINE": alcCreateContext() failed.\n",SFX_SDL_SRCFN); + smLog("%s:" SLINE ": alcCreateContext() failed.\n",SFX_SDL_SRCFN); return mute=true; } alcMakeContextCurrent(ctx);alcProcessContext(ctx); - smLog("%s:"SLINE": Done OpenAL initialization\n",SFX_SDL_SRCFN); - 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)); + smLog("%s:" SLINE ": Done OpenAL initialization\n",SFX_SDL_SRCFN); + 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); + 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/sys_sdl.cpp b/smelt/sdl/sys_sdl.cpp index 190f3bb..27a9e7b 100644 --- a/smelt/sdl/sys_sdl.cpp +++ b/smelt/sdl/sys_sdl.cpp @@ -38,15 +38,15 @@ void SMELT_IMPL::smRelease() bool SMELT_IMPL::smInit() { - smLog("%s:"SLINE": Initalizing SMELT...\n",SYS_SDL_SRCFN); - smLog("%s:"SLINE": SMELT api version %d\n",SYS_SDL_SRCFN,SMELT_APILEVEL); + smLog("%s:" SLINE ": Initalizing SMELT...\n",SYS_SDL_SRCFN); + smLog("%s:" SLINE ": SMELT api version %d\n",SYS_SDL_SRCFN,SMELT_APILEVEL); time_t t=time(NULL); - smLog("%s:"SLINE": Date %s",SYS_SDL_SRCFN,asctime(localtime(&t))); + smLog("%s:" SLINE ": Date %s",SYS_SDL_SRCFN,asctime(localtime(&t))); #ifdef WIN32 OSVERSIONINFO os_ver; MEMORYSTATUS mem_st; os_ver.dwOSVersionInfoSize=sizeof(os_ver); GetVersionEx(&os_ver); - smLog("%s:"SLINE": OS: Windows %ld.%ld.%ld\n", SYS_SDL_SRCFN,os_ver.dwMajorVersion,os_ver.dwMinorVersion,os_ver.dwBuildNumber); + smLog("%s:" SLINE ": OS: Windows %ld.%ld.%ld\n", SYS_SDL_SRCFN,os_ver.dwMajorVersion,os_ver.dwMinorVersion,os_ver.dwBuildNumber); int CPUInfo[4]={-1}; __cpuid(CPUInfo,0x80000000); @@ -63,50 +63,50 @@ bool SMELT_IMPL::smInit() memcpy(cpuName+32, CPUInfo, sizeof(CPUInfo)); } while(*cpuName=' ')++cpuName; - smLog("%s:"SLINE": CPU: %s\n", SYS_SDL_SRCFN,cpuName); + smLog("%s:" SLINE ": CPU: %s\n", SYS_SDL_SRCFN,cpuName); free(loced); GlobalMemoryStatus(&mem_st); - smLog("%s:"SLINE": Memory: %ldK total, %ldK free\n", SYS_SDL_SRCFN,mem_st.dwTotalPhys/1024L,mem_st.dwAvailPhys/1024L); + smLog("%s:" SLINE ": Memory: %ldK total, %ldK free\n", SYS_SDL_SRCFN,mem_st.dwTotalPhys/1024L,mem_st.dwAvailPhys/1024L); #else system("uname -svm > os.out"); char osv[100];FILE* a=fopen("os.out","r");fgets(osv,100,a);fclose(a); osv[strlen(osv)-1]='\0'; - smLog("%s:"SLINE": OS: %s\n",SYS_SDL_SRCFN,osv); + smLog("%s:" SLINE ": OS: %s\n",SYS_SDL_SRCFN,osv); system("rm os.out"); system("cat /proc/cpuinfo | grep name -m 1 > cpu.out"); a=fopen("cpu.out","r");fgets(osv,100,a);fclose(a); osv[strlen(osv)-1]='\0';char *ptr=osv;while(*ptr!=':')++ptr;ptr+=2; - smLog("%s:"SLINE": CPU: %s\n",SYS_SDL_SRCFN,osv); + smLog("%s:" SLINE ": CPU: %s\n",SYS_SDL_SRCFN,osv); system("rm cpu.out"); a=fopen("/proc/meminfo","r"); unsigned totalm,freem; fscanf(a,"MemTotal: %u kB\n",&totalm); fscanf(a,"MemFree: %u kB\n",&freem); - smLog("%s:"SLINE": RAM: %ukB installed, %ukB free\n",SYS_SDL_SRCFN,totalm,freem); + smLog("%s:" SLINE ": RAM: %ukB installed, %ukB free\n",SYS_SDL_SRCFN,totalm,freem); fclose(a); #endif if(SDL_Init(SDL_INIT_VIDEO)==-1) { - smLog("%s:"SLINE": SDL_Init() failed with error %s\n",SYS_SDL_SRCFN,SDL_GetError()); + smLog("%s:" SLINE ": SDL_Init() failed with error %s\n",SYS_SDL_SRCFN,SDL_GetError()); return false; } if(SDL_GL_LoadLibrary(NULL)==-1) { - smLog("%s:"SLINE": SDL_GL_LoadLibrary() failed with error %s\n",SYS_SDL_SRCFN,SDL_GetError()); + smLog("%s:" SLINE ": SDL_GL_LoadLibrary() failed with error %s\n",SYS_SDL_SRCFN,SDL_GetError()); return false; } SDL_DisplayMode vidinfo; if(SDL_GetDesktopDisplayMode(0,&vidinfo)) { - smLog("%s:"SLINE": SDL_GetDesktopDisplayMode() failed with error %s\n",SYS_SDL_SRCFN,SDL_GetError()); + smLog("%s:" SLINE ": SDL_GetDesktopDisplayMode() failed with error %s\n",SYS_SDL_SRCFN,SDL_GetError()); SDL_Quit(); return false; } dispw=vidinfo.w;disph=vidinfo.h; - smLog("%s:"SLINE": Screen: %d x %d\n",SYS_SDL_SRCFN,dispw,disph); + smLog("%s:" SLINE ": Screen: %d x %d\n",SYS_SDL_SRCFN,dispw,disph); Uint32 flags=SDL_WINDOW_OPENGL; if(!windowed)flags|=SDL_WINDOW_FULLSCREEN; SDL_Window *screen=SDL_CreateWindow(winTitle,SDL_WINDOWPOS_UNDEFINED,SDL_WINDOWPOS_UNDEFINED,scrw,scrh,flags); @@ -122,7 +122,7 @@ bool SMELT_IMPL::smInit() SDL_GL_SetSwapInterval(vsync?1:0); if(!hwnd) { - smLog("%s:"SLINE": SDL_CreateWindow() failed with error %s\n",SYS_SDL_SRCFN,SDL_GetError()); + smLog("%s:" SLINE ": SDL_CreateWindow() failed with error %s\n",SYS_SDL_SRCFN,SDL_GetError()); SDL_Quit(); return false; } @@ -142,15 +142,15 @@ bool SMELT_IMPL::smInit() void SMELT_IMPL::smFinale() { - smLog("%s:"SLINE": Cleaning up...\n",SYS_SDL_SRCFN); + smLog("%s:" SLINE ": Cleaning up...\n",SYS_SDL_SRCFN); clearQueue();finiOAL();finiOGL(); SDL_Quit();hwnd=0; } 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(!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); Active=true; for(;;) { |