include/vamos/geometry/Gl_Texture_Image.h

Go to the documentation of this file.
00001 //  Gl_Texture_Image.h - an interface to OpenGL texture objects.
00002 //
00003 //      Vamos Automotive Simulator
00004 //  Copyright (C) 2003 Sam Varner
00005 //
00006 //  This program is free software; you can redistribute it and/or modify
00007 //  it under the terms of the GNU General Public License as published by
00008 //  the Free Software Foundation; either version 2 of the License, or
00009 //  (at your option) any later version.
00010 //
00011 //  This program is distributed in the hope that it will be useful,
00012 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //  GNU General Public License for more details.
00015 //
00016 //  You should have received a copy of the GNU General Public License
00017 //  along with this program; if not, write to the Free Software
00018 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 
00020 #ifndef _GL_TEXTURE_IMAGE_H_
00021 #define _GL_TEXTURE_IMAGE_H_
00022 
00023 #include <vamos/geometry/Texture_Image.h>
00024 #include "textures.h"
00025 #include "globals.h"
00026 
00027 #include <iostream>
00028 
00029 #ifdef WIN32
00030 # define WINDOWS_LEAN_AND_MEAN 1
00031 # define NOMINMAX 1               // Do not define MS' min()/max() macros.
00032 # include <windows.h>
00033 #endif
00034 
00035 #include <GL/gl.h>
00036 #include <GL/glu.h>
00037 
00038 namespace Vamos_Geometry
00039 {
00040   class Gl_Texture_Image : public Texture_Image
00041   {
00042         TEXTURE_HANDLE m_texture_name;
00043           
00044   protected:
00045                   
00046 
00047   public:
00048         Gl_Texture_Image (std::string file_name, 
00049                                           bool smooth = false, bool mip_map = false,
00050                                           double width = 1.0, double height = 1.0);
00051         Gl_Texture_Image (const Gl_Texture_Image& image);
00052         //~Gl_Texture_Image ();
00053 
00054         const Gl_Texture_Image& operator = (const Gl_Texture_Image& image);
00055         
00056         void activate ();
00057         // Don't delete the texture in the destructor.  We don't
00058         // necessarily want to delete the texture when the object goes out
00059         // of scope.
00060         void remove () { m_texture_name.Unload(); }
00061 
00062         // Set texture the texture wrap parameter to GL_CLAMP_TO_EDGE.
00063         // GL_REPEAT is the default.
00064         void clamp_to_edge ();
00065 
00066         // Draw the image to the stencil buffer.
00067         void draw_stencil ();
00068   };
00069   
00070   class Facade : public Gl_Texture_Image
00071   {
00072     bool m_draw_back;
00073     double m_x_offset;
00074     double m_y_offset;
00075     double m_z_offset;
00076 
00077   public:
00078     Facade (std::string image_name, bool draw_back = false);
00079     // If `draw_back' is true, draw a solid-color rectangle for the
00080     // back of the image.
00081 
00082     void set_radius (double radius);
00083     void set_x_offset (double offset) { m_x_offset = offset; }
00084     void set_y_offset (double offset) { m_y_offset = offset; }
00085     void set_z_offset (double offset) { m_z_offset = offset; }
00086     void draw ();
00087   };
00088 }
00089 
00090 #endif // not _GL_TEXTURE_IMAGE_H_

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