博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CHECK opengl version
阅读量:4041 次
发布时间:2019-05-24

本文共 3082 字,大约阅读时间需要 10 分钟。

TEMPLATE = appCONFIG += console c++11CONFIG -= app_bundleCONFIG -= qtSOURCES += \        main.cppLIBS += -lGLEW -lGLU -lglut -lGL
#include 
// the opengl library wrapped by extended features#include
// library cross-platform toolkit windows and managing input operations#include
#include
#include
#include
#include
using namespace std;/*** analyse the version*/string makeMeString(GLint versionRaw) { stringstream ss; string str = "\0"; ss << versionRaw; // transfers versionRaw value into "ss" str = ss.str(); // sets the "str" string as the "ss" value return str;}/*** Format the string as expected*/void formatMe(string *text) { string dot = "."; text->insert(1, dot); // transforms 30000 into 3.0000 text->insert(4, dot); // transforms 3.0000 into 3.00.00}/*** Message*/void consoleMessage() { char *versionGL = "\0"; GLint versionFreeGlutInt = 0; versionGL = (char *)(glGetString(GL_VERSION)); versionFreeGlutInt = (glutGet(GLUT_VERSION)); string versionFreeGlutString = makeMeString(versionFreeGlutInt); formatMe(&versionFreeGlutString); cout << endl; cout << "OpenGL version: " << versionGL << endl << endl; cout << "FreeGLUT version: " << versionFreeGlutString << endl << endl; cout << "GLEW version: " << GLEW_VERSION << "." << GLEW_VERSION_MAJOR << "." << GLEW_VERSION_MINOR << "." << GLEW_VERSION_MICRO << endl;}/*** Manager error*/void managerError() { if (glewInit()) { // checks if glewInit() is activated cerr << "Unable to initialize GLEW." << endl; while (1); // let's use this infinite loop to check the error message before closing the window exit(EXIT_FAILURE); } // FreeConsole();}/*** Manage display (to be implemented)*/void managerDisplay(void){ glClear(GL_COLOR_BUFFER_BIT); // clear the screen glutSwapBuffers();}/*** Initialize FREEGLUT*/void initFreeGlut(int ac, char *av[]) { // A. init glutInit(&ac, av); // 1. inits glut with arguments from the shell glutInitDisplayString(""); // 2a. sets display parameters with a string (obsolete) glutInitDisplayMode(GLUT_SINGLE); // 2b. sets display parameters with defines glutInitWindowSize(600, 600); // 3. window size glutInitContextVersion(3, 3); // 4. sets the version 3.3 as current version (so some functions of 1.x and 2.x could not work properly) glutInitContextProfile(GLUT_CORE_PROFILE); // 5. sets the version 3.3 for the profile core glutInitWindowPosition(500, 500); // 6. distance from the top-left screen // B. create window glutCreateWindow("BadproG - Hello world :D"); // 7. message displayed on top bar window}/*** Manage keyboard*/void managerKeyboard(unsigned char key, int x, int y) { if (key == 27) { // 27 = ESC key exit(0); }}/*** Main, what else?*/int main(int argc, char** argv) { initFreeGlut(argc, argv); // inits freeglut managerError(); // manages errors consoleMessage(); // displays message on the console // C. register the display callback function glutDisplayFunc(managerDisplay); // 8. callback function glutKeyboardFunc(managerKeyboard); // D. main loop glutMainLoop(); // 9. infinite loop return 0;}

这里写图片描述

你可能感兴趣的文章
spring cloud服务的注册与发现(Eureka)
查看>>
Java IO流
查看>>
多线程
查看>>
互联网产品设计:产品即服务
查看>>
UrlreWirte的使用
查看>>
使用js定位到页面某个位子
查看>>
java获取客户端真实ip
查看>>
SWFUPLOAD的使用(java版)
查看>>
Memcached的使用(基于java)
查看>>
java ee中的乱码问题及解决方案
查看>>
从技术到管理:思维转变是关键
查看>>
spring2.5.6下配置定时器
查看>>
为什么很多程序员都选择跳槽?
查看>>
mongdb介绍
查看>>
mongdb安装使用
查看>>
mongdb在java中的应用
查看>>
mongodb与spring集成
查看>>
mongoVue介绍
查看>>
AppServ在Windows平台下的配置与安装使用教程
查看>>
Eclipse+maven开发环境搭建
查看>>