//----------------------------------------------------------------------- bool RenderWindow::InitSDL(void) { /* Information about the current video settings. */ const SDL_VideoInfo* info = NULL; /* Color depth in bits of our window. */ int bpp = 0; /* Flags we will pass into SDL_SetVideoMode. */ int flags = 0; /* First, initialize SDL's video subsystem. */ if( SDL_Init( SDL_INIT_VIDEO ) < 0 ) { /* Failed, exit. */ fprintf( stderr, "Video initialization failed: %s\n",SDL_GetError()); Quit(); return false; } /* Let's get some video information. */ info = SDL_GetVideoInfo( ); if( !info ) { /* This should probably never happen. */ fprintf( stderr, "Video query failed: %s\n",SDL_GetError()); Quit(); return false; } bpp = info->vfmt->BitsPerPixel; SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 ); SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 ); SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 ); SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 24 ); SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, 0); flags = SDL_OPENGL; /*Set the video mode */ if( SDL_SetVideoMode(m_WindowWidth, m_WindowHeight, bpp, flags ) == 0 ) { fprintf( stderr, "Video mode set failed: %s\n",SDL_GetError()); Quit(); return false; } //initial glew if(InitGlew()==false) { Quit(); return false; } //initial rendering state if(InitRenderState() == false) { Quit(); return false; } //show the OpenGL library version info , this is window-system specified GetGLInfo(); return true; }
//Get the system information and print everything on screen (and in the log file) void GameDebugger::GetSystemSpecs(ALLEGRO_DISPLAY* mydisplay) { GetSystemInfo(&SystemInfo); struct tm* mytime = GetDateAndTime(); fprintf(OutputFile, "-- START OF LOG FILE --\nTIMESTAMP: %02i/%02i/%02i - %02i:%02i:%02i\n\n",1+mytime->tm_mday, 1+mytime->tm_mon, 1900+mytime->tm_year, mytime->tm_hour, mytime->tm_min, mytime->tm_sec); GetPhysicallyInstalledSystemMemory(&pMemory); myMemory.dwLength = sizeof(myMemory); GlobalMemoryStatus(&myMemory); fprintf(OutputFile, "-- SYSTEM SPECS --\n\n"); fprintf(OutputFile, "CPU: %s\n", cpuInstInfo.cpusignature); fprintf(OutputFile, "Cores: %i\n", SystemInfo.dwNumberOfProcessors); #ifdef _DEBUG printf("-- SYSTEM SPECS --\n\n"); printf("CPU: %s\n", cpuInstInfo.cpusignature); printf("Cores: %i\n", SystemInfo.dwNumberOfProcessors); #endif if(cpuInstInfo.PFLAGS.PYSICAL_ADDRESS_E) { fprintf(OutputFile, "Physical Address Extension (PAE) Available (x86_64)\n"); #ifdef _DEBUG printf("Physical Address Extension (PAE) Available (x86_64)\n"); #endif } fprintf(OutputFile, "Other processor extensions: "); printf("Other processor extensions: "); if(cpuInstInfo.PFLAGS.LONGMODE) { fprintf(OutputFile, "lm "); #ifdef _DEBUG printf("lm "); #endif } if(cpuInstInfo.PFLAGS.MMX_INSTRUCTIONS) { fprintf(OutputFile, "mmx "); #ifdef _DEBUG printf("mmx "); #endif } if(cpuInstInfo.PFLAGS.EXT_MMX) { fprintf(OutputFile, "mmxext "); #ifdef _DEBUG printf("mmxext "); #endif } if(cpuInstInfo.PFLAGS.B3DNOW) { fprintf(OutputFile, "3dnow "); #ifdef _DEBUG printf("3dnow "); #endif } if(cpuInstInfo.PFLAGS.EXT_3DNOW) { fprintf(OutputFile, "3dnowext "); #ifdef _DEBUG printf("3dnowext "); #endif } if(cpuInstInfo.PFLAGS.MULTIPROCESSOR_CAPABLE) { fprintf(OutputFile, "mp "); #ifdef _DEBUG printf("mp "); #endif } fprintf(OutputFile, "\n\n -- RAM INFORMATION -- \n\n"); fprintf(OutputFile, "Physical RAM: %I64u Mb\n",pMemory/1024); fprintf(OutputFile, "Available RAM: %i Mb\n",myMemory.dwAvailPhys / 1024 / 1024); fprintf(OutputFile, "Total PageFile: %i Mb\n",myMemory.dwTotalPageFile / 1024 / 1024); fprintf(OutputFile, "Available PageFile: %i Mb\n",myMemory.dwAvailPageFile / 1024 / 1024); fprintf(OutputFile, "Total Virtual Memory: %i Mb\n",myMemory.dwTotalVirtual / 1024 / 1024); fprintf(OutputFile, "Available Virtual Memory: %i Mb\n",myMemory.dwAvailVirtual / 1024 / 1024); #ifdef _DEBUG printf("\n\n -- RAM INFORMATION -- \n\n"); printf("Physical RAM: %I64u Mb\n",pMemory/1024); printf("Available RAM: %i Mb\n",myMemory.dwAvailPhys / 1024 / 1024); printf("Total PageFile: %i Mb\n",myMemory.dwTotalPageFile / 1024 / 1024); printf("Available PageFile: %i Mb\n",myMemory.dwAvailPageFile / 1024 / 1024); printf("Total Virtual Memory: %i Mb\n",myMemory.dwTotalVirtual / 1024 / 1024); printf("Available Virtual Memory: %i Mb\n",myMemory.dwAvailVirtual / 1024 / 1024); #endif if(IsD3D(mydisplay)) { #ifdef _DEBUG printf("Using Direct 3D\n"); #endif fprintf(OutputFile, "Using Direct 3D\n"); GetD3DInfo(mydisplay); }else{ #ifdef _DEBUG printf("Using OpenGL 3D\n"); #endif fprintf(OutputFile, "Using OpenGL\n"); GetGLInfo(mydisplay); } return; }