加载opengl信息的函数:
1 void LogGraphicsInfo() 2 { 3 #if defined(HAS_GL) || defined(HAS_GLES) 4 const GLubyte *s; 5 6 s = glGetString(GL_VENDOR); 7 if (s) 8 CLog::Log(LOGNOTICE, "GL_VENDOR = %s", s); 9 else 10 CLog::Log(LOGNOTICE, "GL_VENDOR = NULL"); 11 12 s = glGetString(GL_RENDERER); 13 if (s) 14 CLog::Log(LOGNOTICE, "GL_RENDERER = %s", s); 15 else 16 CLog::Log(LOGNOTICE, "GL_RENDERER = NULL"); 17 18 s = glGetString(GL_VERSION); 19 if (s) 20 CLog::Log(LOGNOTICE, "GL_VERSION = %s", s); 21 else 22 CLog::Log(LOGNOTICE, "GL_VERSION = NULL"); 23 24 s = glGetString(GL_SHADING_LANGUAGE_VERSION); 25 if (s) 26 CLog::Log(LOGNOTICE, "GL_SHADING_LANGUAGE_VERSION = %s", s); 27 else 28 CLog::Log(LOGNOTICE, "GL_SHADING_LANGUAGE_VERSION = NULL"); 29 30 //GL_NVX_gpu_memory_info extension 31 #define GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX 0x9047 32 #define GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX 0x9048 33 #define GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX 0x9049 34 #define GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX 0x904A 35 #define GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX 0x904B 36 37 if (g_Windowing.IsExtSupported("GL_NVX_gpu_memory_info")) 38 { 39 GLint mem = 0; 40 41 glGetIntegerv(GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX, &mem); 42 CLog::Log(LOGNOTICE, "GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX = %i", mem); 43 44 //this seems to be the amount of ram on the videocard 45 glGetIntegerv(GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX, &mem); 46 CLog::Log(LOGNOTICE, "GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX = %i", mem); 47 } 48 49 s = glGetString(GL_EXTENSIONS); 50 if (s) 51 CLog::Log(LOGNOTICE, "GL_EXTENSIONS = %s", s); 52 else 53 CLog::Log(LOGNOTICE, "GL_EXTENSIONS = NULL"); 54 55 #else /* !HAS_GL */ 56 CLog::Log(LOGNOTICE, 57 "Please define LogGraphicsInfo for your chosen graphics libary"); 58 #endif /* !HAS_GL */ 59 }
输出举例:
14:12:19 T:738726416 NOTICE: GL_VENDOR = Imagination Technologies 14:12:19 T:738726416 NOTICE: GL_RENDERER = PowerVR SGX 531 14:12:19 T:738726416 NOTICE: GL_VERSION = OpenGL ES 2.0 build 1.7@550786 14:12:19 T:738726416 NOTICE: GL_SHADING_LANGUAGE_VERSION = OpenGL ES GLSL ES 1.00 build 1.7@550786 14:12:19 T:738726416 DEBUG: GLES: Extension Support Test - GL_NVX_gpu_memory_info NO 14:12:19 T:738726416 NOTICE: GL_EXTENSIONS = GL_OES_rgb8_rgba8 GL_OES_depth24 GL_OES_vertex_half_float GL_OES_texture_float GL_OES_texture_half_float GL_OES_element_index_uint GL_OES_mapbuffer GL_OES_fragment_precision_high GL_OES_compressed_ETC1_RGB8_texture GL_OES_EGL_image GL_OES_required_internalformat GL_OES_depth_texture GL_OES_get_program_binary GL_OES_packed_depth_stencil GL_OES_standard_derivatives GL_OES_vertex_array_object GL_OES_egl_sync GL_EXT_multi_draw_arrays GL_EXT_texture_format_BGRA8888 GL_EXT_discard_framebuffer GL_EXT_shader_texture_lod GL_IMG_shader_binary GL_IMG_texture_compression_pvrtc GL_IMG_texture_stream2 GL_IMG_texture_npot GL_IMG_texture_format_BGRA8888 GL_IMG_read_format GL_IMG_program_binary GL_IMG_multisampled_render_to_texture