bool SDLPlatform::_initialize() { m_touchpad = false; if( SDL_Init(SDL_INIT_EVERYTHING) < 0 ) { LOGGER_CRITICAL(m_serviceProvider)("SDL initialization failed"); return false; } const Char* sdlPlatform = SDL_GetPlatform(); const int sdlRam = SDL_GetSystemRAM(); m_platformName = Helper::stringizeString(m_serviceProvider, sdlPlatform); LOGGER_WARNING(m_serviceProvider)("Device info:" ); LOGGER_WARNING(m_serviceProvider)("Platform: %s" , sdlPlatform ); LOGGER_WARNING(m_serviceProvider)("RAM: %d MB" , sdlRam ); m_sdlInput = new SDLInput(); m_sdlInput->setServiceProvider(m_serviceProvider); if( !m_sdlInput->initialize() ) { return false; } return true; }
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); }
internal void OutputSystemInfo() { SDL_Log("System Info\n"); int ram = SDL_GetSystemRAM(); SDL_Log("Ram: %dMB\n", ram); int cpu_count = SDL_GetCPUCount(); SDL_Log("CPU Count: %d\n", cpu_count); const char *platform = SDL_GetPlatform(); SDL_Log("Platform: %s\n", platform); int display_num = SDL_GetNumVideoDisplays(); SDL_Log("Display Count: %d\n", display_num); for (int i = 0; i < display_num; i++) { SDL_Rect rect; SDL_GetDisplayBounds(i, &rect); const char *name = SDL_GetDisplayName(i); SDL_Log("Display: %s\n", name); SDL_Log("-X: %d, ", rect.x); SDL_Log("Y: %d, ", rect.y); SDL_Log("Width: %d, ", rect.w); SDL_Log("Height: %d\n", rect.h); for (int j = 0; j < SDL_GetNumDisplayModes(i); j++) { SDL_DisplayMode mode; SDL_GetDisplayMode(i, j, &mode); SDL_Log("--Mode: \n"); SDL_Log("---Width: %d\n", mode.w); SDL_Log("---Height: %d\n", mode.h); SDL_Log("---Refresh Rate: %d\n", mode.refresh_rate); } } }
int System::GetRAMSize() { return SDL_GetSystemRAM(); }
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"); }
static mrb_value mrb_sdl2_cpuinfo_get_ram(mrb_state *mrb, mrb_value self) { int result = SDL_GetSystemRAM(); return mrb_fixnum_value(result); }