Example #1
0
    void QuerySystemInformation()
    {
        num_cpus = SDL_GetCPUCount();
        ram = SDL_GetSystemRAM();
        l1_cache = SDL_GetCPUCacheLineSize();

        const char *_vendor = reinterpret_cast<const char*>(glGetString(GL_VENDOR));
        const char *_renderer = reinterpret_cast<const char*>(glGetString(GL_RENDERER));
        const char *_version = reinterpret_cast<const char*>(glGetString(GL_VERSION));

        strcpy(platform, SDL_GetPlatform());
        strcpy(vendor, _vendor);
        strcpy(renderer, _renderer);
        strcpy(version, _version);
    }
Example #2
0
static void _sys_info_reset(void)
{
    memset(sys_info_buffer,0,sizeof(sys_info_buffer));

    _sys_info_printf("SDL information:\n"
                     "----------------\n"
                     "\n"
                     "SDL_GetPlatform(): %s\n\n"
                     "SDL_GetCPUCount(): %d (Number of logical CPU cores)\n"
#if SDL_VERSION_ATLEAST(2,0,1)
                     "SDL_GetSystemRAM(): %d MB\n"
#endif
                     "SDL_GetCPUCacheLineSize(): %d kB (Cache L1)\n\n",
                     SDL_GetPlatform(), SDL_GetCPUCount(),
#if SDL_VERSION_ATLEAST(2,0,1)
                     SDL_GetSystemRAM(),
#endif
                     SDL_GetCPUCacheLineSize() );

    int total_secs, pct;
    SDL_PowerState st = SDL_GetPowerInfo(&total_secs,&pct);
    char * st_string;
    switch(st)
    {
        default:
        case SDL_POWERSTATE_UNKNOWN:
            st_string = "SDL_POWERSTATE_UNKNOWN (cannot determine power status)";
            break;
        case SDL_POWERSTATE_ON_BATTERY:
            st_string = "SDL_POWERSTATE_ON_BATTERY (not plugged in, running on battery)";
            break;
        case SDL_POWERSTATE_NO_BATTERY:
            st_string = "SDL_POWERSTATE_NO_BATTERY (plugged in, no battery available)";
            break;
        case SDL_POWERSTATE_CHARGING:
            st_string = "SDL_POWERSTATE_CHARGING (plugged in, charging battery)";
            break;
        case SDL_POWERSTATE_CHARGED:
            st_string = "SDL_POWERSTATE_CHARGED (plugged in, battery charged)";
            break;
    }

    unsigned int hours = ((unsigned int)total_secs)/3600;
    unsigned int min = (((unsigned int)total_secs)-(hours*3600))/60;
    unsigned int secs = (((unsigned int)total_secs)-(hours*3600)-(min*60));

    _sys_info_printf("SDL_GetPowerInfo():\n  %s\n  Time left: %d:%02d:%02d\n  Percentage: %3d%%\n\n",
                     st_string,hours,min,secs,pct);
#ifdef ENABLE_OPENGL
    _sys_info_printf("OpenGL information:\n"
                     "-------------------\n"
                     "\n"
                     "GL_RENDERER   = %s\n"
                     "GL_VERSION    = %s\n"
                     "GL_VENDOR     = %s\n"
                     "GL_EXTENSIONS = ",
                     (char*)glGetString(GL_RENDERER),(char*)glGetString(GL_VERSION),
                     (char*)glGetString(GL_VENDOR));
    _sys_info_print((char*)glGetString(GL_EXTENSIONS));
#endif
    _sys_info_printf("\n\nEND LOG\n");
}
Example #3
0
	int System::GetCacheSize()
	{
		return SDL_GetCPUCacheLineSize();
	}
Example #4
0
static mrb_value
mrb_sdl2_cpuinfo_cache_line_size(mrb_state *mrb, mrb_value self)
{
  int result = SDL_GetCPUCacheLineSize();
  return mrb_fixnum_value(result);
}