aboutsummaryrefslogtreecommitdiff
path: root/smelt/glfw
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2020-02-15 01:52:25 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2020-02-15 01:52:25 +0800
commit41250bda2a3e3383b8825a31610102826c32c486 (patch)
treed195e679257a3c1352043670d7888096d55582f1 /smelt/glfw
parent7398bdc3eb0f58cdfa9b588e1c6c8e5ef3797ac6 (diff)
downloadSMELT-41250bda2a3e3383b8825a31610102826c32c486.tar.xz
Added 3 methods for getting certain types of system information.
Also improved format of related information reported in logs.
Diffstat (limited to 'smelt/glfw')
-rw-r--r--smelt/glfw/gfx_glfw.cpp3
-rw-r--r--smelt/glfw/smelt_internal.hpp6
-rw-r--r--smelt/glfw/sys_glfw.cpp37
3 files changed, 35 insertions, 11 deletions
diff --git a/smelt/glfw/gfx_glfw.cpp b/smelt/glfw/gfx_glfw.cpp
index cb74a67..acb83d0 100644
--- a/smelt/glfw/gfx_glfw.cpp
+++ b/smelt/glfw/gfx_glfw.cpp
@@ -885,6 +885,9 @@ bool SMELT_IMPL::loadGLEntryPoints()
smLog("%s:" SLINE ": GL_RENDERER: %s\n",GFX_GLFW_SRCFN,(const char *)glGetString(GL_RENDERER));
smLog("%s:" SLINE ": GL_VENDOR: %s\n",GFX_GLFW_SRCFN,(const char *)glGetString(GL_VENDOR));
smLog("%s:" SLINE ": GL_VERSION: %s\n",GFX_GLFW_SRCFN,(const char *)glGetString(GL_VERSION));
+ dispdrv=std::string("Renderer: ")+std::string((const char*)glGetString(GL_RENDERER));
+ dispdrv+=std::string("\nVendor: ")+std::string((const char*)glGetString(GL_VENDOR));
+ dispdrv+=std::string("\nOpenGL Version: ")+std::string((const char*)glGetString(GL_VERSION));
const char *verstr=(const char*)glGetString(GL_VERSION);
int maj=0,min=0;
sscanf(verstr,"%d.%d",&maj,&min);
diff --git a/smelt/glfw/smelt_internal.hpp b/smelt/glfw/smelt_internal.hpp
index d7ec3c9..72d09cb 100644
--- a/smelt/glfw/smelt_internal.hpp
+++ b/smelt/glfw/smelt_internal.hpp
@@ -18,6 +18,7 @@
#include <cstdlib>
#include <ctime>
#include <cstdarg>
+#include <string>
#ifdef WIN32
#include <windows.h>
#include <intrin.h>
@@ -110,6 +111,10 @@ public:
virtual float smGetDelta();
virtual float smGetTime();
+ virtual const char* smGetCPUModel();
+ virtual const char* smGetOSInfo();
+ virtual const char* smGetDispDriver();
+
virtual SMSFX smSFXLoad(const char *path);
virtual SMSFX smSFXLoadFromMemory(const char *ptr,DWORD size);
virtual SMCHN smSFXPlay(SMSFX fx,int vol=100,int pan=0,float pitch=1.,bool loop=0);
@@ -191,6 +196,7 @@ public:
char logFile[256];
int limfps;
bool hideMouse,noSuspend;
+ std::string osver,cpumodel,dispdrv;
TOpenGLDevice *pOpenGLDevice;
smVertex *vertexArray;
diff --git a/smelt/glfw/sys_glfw.cpp b/smelt/glfw/sys_glfw.cpp
index 89049dc..86be958 100644
--- a/smelt/glfw/sys_glfw.cpp
+++ b/smelt/glfw/sys_glfw.cpp
@@ -53,11 +53,14 @@ bool SMELT_IMPL::smInit()
smLog("%s:" SLINE ": SMELT api version %d\n",SYS_GLFW_SRCFN,SMELT_APILEVEL);
time_t t=time(NULL);
smLog("%s:" SLINE ": Date %s",SYS_GLFW_SRCFN,asctime(localtime(&t)));
+ char pout[128];
#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_GLFW_SRCFN,os_ver.dwMajorVersion,os_ver.dwMinorVersion,os_ver.dwBuildNumber);
+ snprintf(pout,128,"Windows %ld.%ld.%ld",os_ver.dwMajorVersion,os_ver.dwMinorVersion,os_ver.dwBuildNumber);
+ osver=std::string(pout);
+ smLog("%s:" SLINE ": OS: %s\n", SYS_GLFW_SRCFN,osver.c_str());
int CPUInfo[4]={-1};
__cpuid(CPUInfo,0x80000000);
@@ -74,23 +77,31 @@ bool SMELT_IMPL::smInit()
memcpy(cpuName+32, CPUInfo, sizeof(CPUInfo));
}
while(*cpuName==' ')++cpuName;
+ cpumodel=std::string(cpuName);
smLog("%s:" SLINE ": CPU: %s\n", SYS_GLFW_SRCFN,cpuName);
free(loced);
GlobalMemoryStatus(&mem_st);
smLog("%s:" SLINE ": Memory: %ldK total, %ldK free\n", SYS_GLFW_SRCFN,mem_st.dwTotalPhys/1024L,mem_st.dwAvailPhys/1024L);
#else
- system("uname -svm > /tmp/os.out");
- char osv[100];FILE* a=fopen("/tmp/os.out","r");fgets(osv,100,a);fclose(a);
- osv[strlen(osv)-1]='\0';
- smLog("%s:" SLINE ": OS: %s\n",SYS_GLFW_SRCFN,osv);
- system("rm /tmp/os.out");
+ FILE* a=popen("uname -srm","r");
+ fgets(pout,128,a);pclose(a);
+ osver=std::string(pout);
+ osver.pop_back();
+ if(!access("/etc/os-release",R_OK))
+ {
+ a=popen("grep -oP 'PRETTY_NAME=\"\\K.*(?=\")' /etc/os-release","r");
+ fgets(pout,128,a);pclose(a);
+ std::string osrel(pout);osrel.pop_back();
+ osver=osrel+std::string("; ")+osver;
+ }
+ smLog("%s:" SLINE ": OS: %s\n",SYS_GLFW_SRCFN,osver.c_str());
- system("cat /proc/cpuinfo | grep name -m 1 > /tmp/cpu.out");
- a=fopen("/tmp/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_GLFW_SRCFN,osv);
- system("rm /tmp/cpu.out");
+ a=popen("grep -oP -m1 'model name\t: \\K.*' /proc/cpuinfo","r");
+ fgets(pout,128,a);fclose(a);
+ cpumodel=std::string(pout);
+ while(cpumodel.length()&&isspace(cpumodel.back()))cpumodel.pop_back();
+ smLog("%s:" SLINE ": CPU: %s\n",SYS_GLFW_SRCFN,cpumodel.c_str());
a=fopen("/proc/meminfo","r");
unsigned totalm,freem;
@@ -247,6 +258,10 @@ float SMELT_IMPL::smGetFPS(){return fps;}
float SMELT_IMPL::smGetDelta(){return timeDelta;}
float SMELT_IMPL::smGetTime(){return timeS;}
+const char *SMELT_IMPL::smGetCPUModel(){return cpumodel.c_str();}
+const char *SMELT_IMPL::smGetOSInfo(){return osver.c_str();}
+const char *SMELT_IMPL::smGetDispDriver(){return dispdrv.c_str();}
+
SMELT_IMPL::SMELT_IMPL()
{
hwnd=NULL;Active=false;memset(curError,0,sizeof(curError));