src/cardinfo.cpp

Go to the documentation of this file.
00001 #include "cardinfo.h"
00002 
00003 // This function returns true if the extension is there.
00004 bool CARDINFO::isExtensionSupported(string extstring)
00005 {
00006         char * temp = (char *) glGetString(GL_EXTENSIONS);
00007         if (temp == 0)
00008         {
00009                 cout << "Error getting extensions.  Continuing anyway, errors may follow!" << endl;
00010                 return true;
00011         }
00012 
00013         string s = temp;
00014         string::size_type temppos = s.find(extstring);
00015 
00016         bool hasext = (temppos <= s.length());
00017 
00018         if (!hasext)
00019         {
00020                 cout << "Extension not supported: " << extstring << endl;
00021         }
00022 
00023         //cout << s << endl;
00024 
00025         return hasext;
00026 }
00027 
00028 void CARDINFO::ResetDB()
00029 {
00030         db.resize(NUM_CARDINFOTYPES);
00031         dbvalid = false;
00032 }
00033 
00034 int CARDINFO::GetCapability(CARDINFOTYPE::TYPE capability)
00035 {
00036         if (!dbvalid)
00037                 return -1;
00038         
00039         if (capability >= 0 && capability < NUM_CARDINFOTYPES)
00040         {
00041                 return db[capability].data;
00042         }
00043         
00044         return -1;
00045 }
00046 
00047 void CARDINFO::BuildCardInfo()
00048 {
00049         if (isExtensionSupported( "GL_ARB_multitexture" ))
00050         {
00051                 db[CARDINFOTYPE::MULTITEXTURE].data = 1;
00052                 GLint tu;
00053                 glGetIntegerv( GL_MAX_TEXTURE_UNITS_ARB,&tu );
00054                 db[CARDINFOTYPE::TEXTUREUNITS].data = tu;
00055         }
00056         else
00057         {
00058                 db[CARDINFOTYPE::MULTITEXTURE].data = 0;
00059                 db[CARDINFOTYPE::TEXTUREUNITS].data = 1;
00060         }
00061         
00062         if (isExtensionSupported( "GL_EXT_texture_filter_anisotropic" ))
00063         {
00064                 db[CARDINFOTYPE::ANISOTROPY].data = 1;
00065                 GLint aniso;
00066                 glGetIntegerv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT,&aniso );
00067                 db[CARDINFOTYPE::MAXANISOTROPY].data = aniso;
00068         }
00069         else
00070         {
00071                 db[CARDINFOTYPE::ANISOTROPY].data = 0;
00072                 db[CARDINFOTYPE::MAXANISOTROPY].data = -1;
00073         }
00074         
00075         dbvalid = true;
00076 }
00077 
00078 void CARDINFO::PrintCardInfo(ostream & out)
00079 {
00080         if (dbvalid)
00081         {
00082                 out << "Multitexture: ";
00083                 if (db[CARDINFOTYPE::MULTITEXTURE].data == 1)
00084                         out << "Yes" << endl;
00085                 else
00086                         out << "No" << endl;
00087                 out << "Texture units: " << db[CARDINFOTYPE::TEXTUREUNITS].data << endl;
00088                 out << "Anisotropic texture filtering: ";
00089                 if (db[CARDINFOTYPE::ANISOTROPY].data == 1)
00090                 {
00091                         out << "Yes" << endl;
00092                         out << "Maximum Anisotropy: " << db[CARDINFOTYPE::MAXANISOTROPY].data << endl;
00093                 }
00094                 else
00095                         out << "No" << endl;
00096         }
00097         else
00098                 cout << "Card info not yet built" << endl;
00099 }

Generated on Thu Oct 19 04:05:48 2006 by  doxygen 1.4.6