00001 /* 00002 * $Id: glUtil.h,v 1.4 2003/07/15 11:26:08 jmk Exp $ 00003 */ 00004 00005 /* 00006 ** Joe Michael Kniss (c) 2002 00007 ** 00008 ** This library is free software; you can redistribute it and/or 00009 ** modify it under the terms of the GNU Lesser General Public 00010 ** License as published by the Free Software Foundation; either 00011 ** version 2.1 of the License, or (at your option) any later version. 00012 ** 00013 ** This library is distributed in the hope that it will be useful, 00014 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 ** Lesser General Public License for more details. 00017 ** 00018 ** You should have received a copy of the GNU Lesser General Public 00019 ** License along with this library; if not, write to the Free Software 00020 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 */ 00022 00023 00024 00025 // glUtils.h 00026 00027 // depends on: 00028 // glew.h 00029 00030 00031 #ifndef __GL_UTILS_DOT_H 00032 #define __GL_UTILS_DOT_H 00033 00034 #include <GL/glew.h> 00035 #include <iostream> 00036 00037 /////////////////////////////////////////////////////////////////////////// 00038 /// General GL/WGL error reporting 00039 /////////////////////////////////////////////////////////////////////////// 00040 00041 bool glErr(std::ostream &os, const char *where = 0, const char *when= 0); 00042 void wglGetLastError(std::ostream &os, const char *where = 0); 00043 00044 00045 /////////////////////////////////////////////////////////////////////////// 00046 /// GL Window state 00047 /////////////////////////////////////////////////////////////////////////// 00048 struct WinStatsGL 00049 { 00050 int colorBits[4]; 00051 int accumBits[4]; 00052 int depthBits; 00053 int stencilBits; 00054 unsigned char doubleBuffer; 00055 unsigned char stereoBuffer; 00056 unsigned char auxBuffer; 00057 }; 00058 00059 WinStatsGL getGLWinStats(bool print = false); 00060 00061 00062 /////////////////////////////////////////////////////////////////////////// 00063 /// GL Limits 00064 /////////////////////////////////////////////////////////////////////////// 00065 struct LimitsGL 00066 { 00067 int maxTexUnits; 00068 int maxTexCoords; 00069 }; 00070 00071 // you must call this function before you use the gl-limits structure 00072 const LimitsGL getLimitsGL(); 00073 00074 /////////////////////////////////////////////////////////////////////////// 00075 /// GL Color & Texture Utils 00076 /////////////////////////////////////////////////////////////////////////// 00077 void setColorMask( GLenum channel ); 00078 GLenum validateSingleRGBChannel( GLenum channel ); 00079 bool isSingleChannel( GLenum channel ); /// Return true if 'channel' is single-channel GLenum 00080 int getNumChannels( GLenum format ); /// Get the number of color channels represented by 'format' 00081 int getTexDim( GLenum texType ); /// Get the dimensionality of the texture type 00082 00083 /// Glut has some issues with vc7 00084 #if 0 00085 /////////////////////////////////////////////////////////////////////////// 00086 /// GL Text Utils 00087 /////////////////////////////////////////////////////////////////////////// 00088 void renderBitmapString( float x, float y, int spacing, void *font, char *string); 00089 00090 00091 /////////////////////////////////////////////////////////////////////////// 00092 /// GLUT main window context switcher, should be called the first time 00093 /// when the main window context is current 00094 /////////////////////////////////////////////////////////////////////////// 00095 void MakeGlutWindowCurrent(); 00096 #endif 00097 00098 #endif 00099 00100 //------------------------------------------------------------------------ 00101 //C++ 00102 // 00103 // ________ ____ ___ 00104 // | \ / | / / 00105 // +---+ \/ |/ / 00106 // +--+| |\ /| < 00107 // | || | \ / | |\ \ 00108 // | | \/ | | \ \ 00109 // \_____| |__| \__\ 00110 // Copyright 2002 00111 // Joe Michael Kniss 00112 // "All Your Base are Belong to Us" 00113 //-------------------------------------------------------------------------