现在的位置: 首页 > 综合 > 正文

opengl学习笔记(一)—获取opengl版本等信息

2014年02月07日 ⁄ 综合 ⁄ 共 871字 ⁄ 字号 评论关闭

总结:程序调试过程中,把日志打印出来是个不错的调试方法:

	//! Print the log info to console;
	static void log( std::string strLog)
	{
#ifdef _DEBUG_LOG_PRINT
		cout << strLog << endl;

		//! Write the debug log in file(debug.log);
		fstream fs("./debug.log", ios::app);
		fs << strLog << endl;
		fs.close();
#endif
	}

	//! Print the opengl and glsl's version information;
	static void TEGlVersionInfo(void)
	{
		const GLubyte* byteGlVersion = glGetString(GL_VERSION);
		const GLubyte* byteGlVendor = glGetString(GL_VENDOR);
		const GLubyte* byteGlRenderer = glGetString(GL_RENDERER);
		const GLubyte* byteSLVersion = glGetString(GL_SHADING_LANGUAGE_VERSION);
		std::string strTemp = "OpenGL version: ";
		strTemp += TE::numToString(byteGlVersion);
		TE::log(strTemp);

		strTemp = "GL_VENDOR: ";
		strTemp += TE::numToString(byteGlVendor);
		TE::log(strTemp);

		strTemp = "GL_RENDERER: ";
		strTemp += TE::numToString(byteGlRenderer);
		TE::log(strTemp);

		strTemp = "GLSL version: ";
		strTemp += TE::numToString(byteSLVersion);
		TE::log(strTemp);
	}

运行结果:

抱歉!评论已关闭.