Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

opengl.h

Go to the documentation of this file.
00001 
00006 #ifndef OPENGL_H
00007 #define OPENGL_H
00008 
00009 #include <string>
00010 #include <map>
00011 
00012 #include "gl.h"
00013 
00014 #include "image.h"
00015 #include "io.h"
00016 
00017 /* OpenGL state flags.  */
00018 #define OGL_TEXTURE_2D     0x01
00019 #define OGL_BLEND          0x02
00020 #define OGL_LIGHTING       0x04
00021 #define OGL_COLOR_MATERIAL 0x08
00022 #define OGL_LIGHT0         0x10
00023 #define OGL_LIGHT1         0x20
00024 #define OGL_CULL_FACE      0x40
00025 #define OGL_DEPTH_TEST     0x80
00026 
00029 void OGL_State (uint s);
00030 
00033 void OGL_CheckError (void);
00034 
00036 void OGL_RegisterWindow (const IO_Window *win);
00037 
00039 void OGL_SelectWindow (const IO_Window *win);
00040 
00042 void OGL_UnregisterWindow (const IO_Window *win);
00043 
00044 /* Texture creation flags.  */
00046 #define OGL_2D    0x01
00047 
00048 #define OGL_CLAMP 0x02
00049 
00050 #define OGL_ALPHA 0x04
00051 
00053 class Texture
00054 {
00055 public:
00057   Texture (void)
00058     {
00059       rc = NULL;
00060     }
00061 
00063   Texture (const std::string &file, const uint flags = 0);
00064 
00066   Texture (Image &img, const uint flags = 0);
00067 
00069   Texture (const Texture &t) : names (t.names)
00070     {
00071       rc = t.rc;
00072       if (rc != NULL)
00073         {
00074           (*rc)++;
00075           img = t.img;
00076           flags = t.flags;
00077         }
00078     }
00079 
00081   Texture &operator = (const Texture &t)
00082     {
00083       if (rc != NULL)
00084         {
00085           (*rc)--;
00086           if (*rc == 0)
00087             {
00088               delete rc;
00089               Unload ();
00090             }
00091         }
00092 
00093       rc = t.rc;
00094       if (rc != NULL)
00095         {
00096           (*rc)++;
00097           img = t.img;
00098           flags = t.flags;
00099           names = t.names;
00100         }
00101 
00102       return (*this);
00103     }
00104 
00106   void Select (void) const;
00107 
00109   ~Texture (void)
00110     {
00111       if (rc != NULL)
00112         {
00113           (*rc)--;
00114           if (*rc == 0)
00115             {
00116               delete rc;
00117               Unload ();
00118             }
00119         }
00120     }
00121 
00123   bool operator == (const Texture &t)
00124     {
00125       return (rc == t.rc);
00126     }
00127 
00129   void AddWindow (const IO_Window *win);
00130 
00132   void RemoveWindow (const IO_Window *win);
00133 
00134 private:
00135   /* Unloads the texture from all windows.  */
00136   void Unload (void);
00137 
00138   /* Reference count.  */
00139   int *rc;
00140 
00141   /* The texture image.  */
00142   Image img;
00143 
00144   /* The creation flags.  */
00145   uint flags;
00146 
00147   /* List of associations between windows and texture names.  */
00148   std::map <IO_Window *, uint> *names;
00149 };
00150 
00151 #endif

Generated on Fri Jan 12 14:15:02 2007 for Construct by  doxygen 1.4.3-20050530