aboutsummaryrefslogtreecommitdiff
path: root/smelt/sdl
diff options
context:
space:
mode:
Diffstat (limited to 'smelt/sdl')
-rw-r--r--smelt/sdl/gfx_sdl.cpp52
-rw-r--r--smelt/sdl/sfx_sdl.cpp14
-rw-r--r--smelt/sdl/smelt_internal.hpp6
-rw-r--r--smelt/sdl/sys_sdl.cpp34
4 files changed, 49 insertions, 57 deletions
diff --git a/smelt/sdl/gfx_sdl.cpp b/smelt/sdl/gfx_sdl.cpp
index 4a4baa1..4ad7404 100644
--- a/smelt/sdl/gfx_sdl.cpp
+++ b/smelt/sdl/gfx_sdl.cpp
@@ -25,7 +25,7 @@ bool SMELT_IMPL::smRenderBegin2D(bool ztest,SMTRG trg)
{
TRenderTargetList *targ=(TRenderTargetList*)trg;
if(vertexArray)
- {smLog("%s: 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);
@@ -52,7 +52,7 @@ bool SMELT_IMPL::smRenderBegin3D(float fov,SMTRG trg)
{
TRenderTargetList *targ=(TRenderTargetList*)trg;
if(vertexArray)
- {smLog("%s: 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);
@@ -225,7 +225,7 @@ SMTRG SMELT_IMPL::smTargetCreate(int w,int h)
ok=buildTarget(pTarget,gltex->name,w,h);
if(!ok)
{
- smLog("%s: 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;
@@ -689,20 +689,19 @@ bool SMELT_IMPL::checkGLExtension(const char *extlist,const char *ext)
}
bool SMELT_IMPL::loadGLEntryPoints()
{
- smLog("%s: 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;
pOpenGLDevice->have_GL_EXT_framebuffer_object=true;
pOpenGLDevice->have_GL_EXT_texture_compression_s3tc=true;
pOpenGLDevice->have_GL_ARB_vertex_buffer_object=true;
- //pOpenGLDevice->have_GL_APPLE_ycbcr_422=true;
#define GL_PROC(ext,fn,call,ret,params) \
if(pOpenGLDevice->have_##ext) \
{ \
if((pOpenGLDevice->fn=(_PFN_##fn) SDL_GL_GetProcAddress(#fn))==NULL) \
{ \
- smLog("Failed to load OpenGL entry point '" #fn "'\n"); \
+ smLog("%s: Failed to load OpenGL entry point '" #fn "'\n",GFX_SDL_SRCFN); \
pOpenGLDevice->have_##ext = false; \
} \
} else {}
@@ -713,15 +712,15 @@ bool SMELT_IMPL::loadGLEntryPoints()
unloadGLEntryPoints();
return false;
}
- smLog("%s: GL_RENDERER: %s\n",GFX_SDL_SRCFN,(const char *)pOpenGLDevice->glGetString(GL_RENDERER));
- smLog("%s: GL_VENDOR: %s\n",GFX_SDL_SRCFN,(const char *)pOpenGLDevice->glGetString(GL_VENDOR));
- smLog("%s: 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: 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;
}
@@ -734,60 +733,55 @@ bool SMELT_IMPL::loadGLEntryPoints()
maj>=2||checkGLExtension(exts,"GL_ARB_texture_non_power_of_two");
if(pOpenGLDevice->have_GL_ARB_texture_rectangle)
{
- smLog("%s: 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: 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: 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: 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: 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: 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: OpenGL: WARNING: no texture compression support or it's disabled.\n",GFX_SDL_SRCFN);
- smLog("%s: OpenGL: Performance may suffer in a low-memory system!\n",GFX_SDL_SRCFN);
+ smLog("%s:"SLINE": OpenGL: WARNING: no texture compression support or it's disabled.\n",GFX_SDL_SRCFN);
+ smLog("%s:"SLINE": OpenGL: Performance may suffer in a low-memory system!\n",GFX_SDL_SRCFN);
}
- /*pOpenGLDevice->have_GL_APPLE_ycbcr_422=checkGLExtension(exts,"GL_APPLE_ycbcr_422");
- if(pOpenGLDevice->have_GL_APPLE_ycbcr_422)
- smLog("%s: OpenGL: Using GL_APPLE_ycbcr_422 to render YUV frames.",GFX_SDL_SRCFN);
- else
- smLog("%s: OpenGL: WARNING: YUV texture/video not supported.",GFX_SDL_SRCFN);*/
if(pOpenGLDevice->have_GL_ARB_vertex_buffer_object)
{
pOpenGLDevice->have_GL_ARB_vertex_buffer_object=
checkGLExtension(exts,"GL_ARB_vertex_buffer_object");
}
if(pOpenGLDevice->have_GL_ARB_vertex_buffer_object)
- smLog("%s: 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: 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: 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: Mode: %dx%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);
@@ -877,8 +871,6 @@ bool SMELT_IMPL::confOGL()
pOpenGLDevice->glDisable(GL_CULL_FACE);
pOpenGLDevice->glDisable(GL_LIGHTING);
pOpenGLDevice->glDepthFunc(GL_GEQUAL);
- //if (zbufenabled)pOpenGLDevice->glEnable(GL_DEPTH_TEST);
- //else pOpenGLDevice->glDisable(GL_DEPTH_TEST);
pOpenGLDevice->glEnable(GL_DEPTH_TEST);
pOpenGLDevice->glEnable(GL_BLEND);
pOpenGLDevice->glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
@@ -887,7 +879,7 @@ bool SMELT_IMPL::confOGL()
pOpenGLDevice->glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE);
pOpenGLDevice->glTexParameteri(pOpenGLDevice->TextureTarget,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
pOpenGLDevice->glTexParameteri(pOpenGLDevice->TextureTarget,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
- //TODO: try GL_REPEAT?
+ //GL_REPEAT doesn't work with non-pot textures...
pOpenGLDevice->glTexParameteri(pOpenGLDevice->TextureTarget,GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE);
pOpenGLDevice->glTexParameteri(pOpenGLDevice->TextureTarget,GL_TEXTURE_WRAP_T,GL_CLAMP_TO_EDGE);
pOpenGLDevice->glTexParameteri(pOpenGLDevice->TextureTarget,GL_TEXTURE_WRAP_R,GL_CLAMP_TO_EDGE);
diff --git a/smelt/sdl/sfx_sdl.cpp b/smelt/sdl/sfx_sdl.cpp
index fde771d..afc8f68 100644
--- a/smelt/sdl/sfx_sdl.cpp
+++ b/smelt/sdl/sfx_sdl.cpp
@@ -280,25 +280,25 @@ bool SMELT_IMPL::initOAL()
{
if(pOpenALDevice)return true;
scnt=0;memset(src,0,sizeof(src));
- smLog("%s: Initializing OpenAL...\n",SFX_SDL_SRCFN);
+ smLog("%s:"SLINE": Initializing OpenAL...\n",SFX_SDL_SRCFN);
ALCdevice *dev=alcOpenDevice(NULL);
if(!dev)
{
- smLog("%s: 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: alcCreateContext() failed.\n",SFX_SDL_SRCFN);
+ smLog("%s:"SLINE": alcCreateContext() failed.\n",SFX_SDL_SRCFN);
return mute=true;
}
alcMakeContextCurrent(ctx);alcProcessContext(ctx);
- smLog("%s: Done OpenAL initialization\n",SFX_SDL_SRCFN);
- smLog("%s: AL_VENDOR: %s\n",SFX_SDL_SRCFN,(char*)alGetString(AL_VENDOR));
- smLog("%s: AL_RENDERER: %s\n",SFX_SDL_SRCFN,(char*)alGetString(AL_RENDERER));
- smLog("%s: 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));
pOpenALDevice=(void*)dev;
return true;
}
diff --git a/smelt/sdl/smelt_internal.hpp b/smelt/sdl/smelt_internal.hpp
index 0f0fc2d..a84050f 100644
--- a/smelt/sdl/smelt_internal.hpp
+++ b/smelt/sdl/smelt_internal.hpp
@@ -35,9 +35,9 @@
#include <GL/gl.h>
#include <GL/glext.h>
-#ifndef WINGDIAPI
-#define WINGDIAPI
-#endif
+#define xstr(s) str(s)
+#define str(s) #s
+#define SLINE xstr(__LINE__)
#define GL_PROC(ext,fn,call,ret,params) typedef call ret (* _PFN_##fn) params;
#include "glimports.hpp"
diff --git a/smelt/sdl/sys_sdl.cpp b/smelt/sdl/sys_sdl.cpp
index 6a4bd1b..f489c9d 100644
--- a/smelt/sdl/sys_sdl.cpp
+++ b/smelt/sdl/sys_sdl.cpp
@@ -39,15 +39,15 @@ void SMELT_IMPL::smRelease()
bool SMELT_IMPL::smInit()
{
- smLog("%s: Initalizing SMELT...\n",SYS_SDL_SRCFN);
- smLog("%s: 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: 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: 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);
@@ -64,50 +64,50 @@ bool SMELT_IMPL::smInit()
memcpy(cpuName+32, CPUInfo, sizeof(CPUInfo));
}
while(*cpuName=' ')++cpuName;
- smLog("%s: CPU: %s\n", SYS_SDL_SRCFN,cpuName);
+ smLog("%s:"SLINE": CPU: %s\n", SYS_SDL_SRCFN,cpuName);
free(loced);
GlobalMemoryStatus(&mem_st);
- smLog("%s: 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: 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: 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: 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: 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: 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: 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: 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);
@@ -123,7 +123,7 @@ bool SMELT_IMPL::smInit()
SDL_GL_SetSwapInterval(vsync?1:0);
if(!hwnd)
{
- smLog("%s: 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;
}
@@ -143,15 +143,15 @@ bool SMELT_IMPL::smInit()
void SMELT_IMPL::smFinale()
{
- smLog("%s: 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: Error: SMELT is not initialized.\n",SYS_SDL_SRCFN);
- if(!pUpdateFunc) return smLog("%s: 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(;;)
{