Go to the documentation of this file.00001 #include <GL/gl.h>
00002 #include <iostream>
00003 #include <sstream>
00004 #include <iomanip>
00005 #include <algorithm>
00006 #include <stdio.h>
00007 #include <string.h>
00008 #include "rtc/rtcGLInfo.h"
00009
00010 using std::string;
00011 using std::stringstream;
00012 using std::vector;
00013 using std::cout;
00014 using std::endl;
00015
00016
00017 namespace rtc {
00018
00020
00021
00023 bool GLInfo::getInfo()
00024 {
00025 char* str = 0;
00026 char* tok = 0;
00027
00028
00029 str = (char*)glGetString(GL_VENDOR);
00030 if(str) this->vendor = str;
00031 else return false;
00032
00033
00034 str = (char*)glGetString(GL_RENDERER);
00035 if(str) this->renderer = str;
00036 else return false;
00037
00038
00039 str = (char*)glGetString(GL_VERSION);
00040 if(str) this->version = str;
00041 else return false;
00042
00043
00044 str = (char*)glGetString(GL_EXTENSIONS);
00045
00046
00047 if(str)
00048 {
00049 tok = strtok((char*)str, " ");
00050 while(tok)
00051 {
00052 this->extensions.push_back(tok);
00053 tok = strtok(0, " ");
00054 }
00055 }
00056 else
00057 {
00058 return false;
00059 }
00060
00061
00062 std::sort(this->extensions.begin(), this->extensions.end());
00063
00064
00065 glGetIntegerv(GL_RED_BITS, &this->redBits);
00066 glGetIntegerv(GL_GREEN_BITS, &this->greenBits);
00067 glGetIntegerv(GL_BLUE_BITS, &this->blueBits);
00068 glGetIntegerv(GL_ALPHA_BITS, &this->alphaBits);
00069
00070
00071 glGetIntegerv(GL_DEPTH_BITS, &this->depthBits);
00072
00073
00074 glGetIntegerv(GL_STENCIL_BITS, &this->stencilBits);
00075
00076
00077 glGetIntegerv(GL_MAX_LIGHTS, &this->maxLights);
00078
00079
00080 glGetIntegerv(GL_MAX_TEXTURE_SIZE, &this->maxTextureSize);
00081
00082
00083 glGetIntegerv(GL_MAX_CLIP_PLANES, &this->maxClipPlanes);
00084
00085
00086 glGetIntegerv(GL_MAX_MODELVIEW_STACK_DEPTH, &this->maxModelViewStacks);
00087 glGetIntegerv(GL_MAX_PROJECTION_STACK_DEPTH, &this->maxProjectionStacks);
00088 glGetIntegerv(GL_MAX_ATTRIB_STACK_DEPTH, &this->maxAttribStacks);
00089
00090
00091 glGetIntegerv(GL_MAX_TEXTURE_STACK_DEPTH, &this->maxTextureStacks);
00092
00093 return true;
00094 }
00095
00096
00097
00099
00101 bool GLInfo::isExtensionSupported(const char* ext)
00102 {
00103
00104 std::vector< string >::const_iterator iter = this->extensions.begin();
00105 std::vector< string >::const_iterator endIter = this->extensions.end();
00106
00107 while(iter != endIter)
00108 {
00109 if(ext == *iter)
00110 return true;
00111 else
00112 ++iter;
00113 }
00114 return false;
00115 }
00116
00117
00118
00120
00122 void GLInfo::printSelf()
00123 {
00124 stringstream ss;
00125
00126 ss << endl;
00127 ss << "OpenGL Driver Info" << endl;
00128 ss << "==================" << endl;
00129 ss << "Vendor: " << this->vendor << endl;
00130 ss << "Version: " << this->version << endl;
00131 ss << "Renderer: " << this->renderer << endl;
00132
00133 ss << endl;
00134 ss << "Color Bits(R,G,B,A): (" << this->redBits << ", " << this->greenBits
00135 << ", " << this->blueBits << ", " << this->alphaBits << ")\n";
00136 ss << "Depth Bits: " << this->depthBits << endl;
00137 ss << "Stencil Bits: " << this->stencilBits << endl;
00138
00139 ss << endl;
00140 ss << "Max Texture Size: " << this->maxTextureSize << "x" << this->maxTextureSize << endl;
00141 ss << "Max Lights: " << this->maxLights << endl;
00142 ss << "Max Clip Planes: " << this->maxClipPlanes << endl;
00143 ss << "Max Modelview Matrix Stacks: " << this->maxModelViewStacks << endl;
00144 ss << "Max Projection Matrix Stacks: " << this->maxProjectionStacks << endl;
00145 ss << "Max Attribute Stacks: " << this->maxAttribStacks << endl;
00146 ss << "Max Texture Stacks: " << this->maxTextureStacks << endl;
00147
00148 ss << endl;
00149 ss << "Total Number of Extensions: " << this->extensions.size() << endl;
00150 ss << "==============================" << endl;
00151 for(unsigned int i = 0; i < this->extensions.size(); ++i)
00152 ss << this->extensions.at(i) << endl;
00153
00154 ss << "======================================================================" << endl;
00155
00156 cout << ss.str() << endl;
00157 }
00158
00159
00160 }
00161