src/tron/cockpit/cRectangle.cpp

Go to the documentation of this file.
00001 /*
00002 
00003 *************************************************************************
00004 
00005 ArmageTron -- Just another Tron Lightcycle Game in 3D.
00006 Copyright (C) 2000  Manuel Moos (manuel@moosnet.de)
00007 
00008 **************************************************************************
00009 
00010 This program is free software; you can redistribute it and/or
00011 modify it under the terms of the GNU General Public License
00012 as published by the Free Software Foundation; either version 2
00013 of the License, or (at your option) any later version.
00014 
00015 This program is distributed in the hope that it will be useful,
00016 but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 GNU General Public License for more details.
00019 
00020 You should have received a copy of the GNU General Public License
00021 along with this program; if not, write to the Free Software
00022 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00023 
00024 ***************************************************************************
00025 
00026 */
00027 
00028 #include "cockpit/cRectangle.h"
00029 
00030 #ifndef DEDICATED
00031 
00032 #include "rRender.h"
00033 #include "rScreen.h"
00034 
00035 namespace cWidget {
00036 
00037 bool Rectangle::Process(tXmlParser::node cur) {
00038     if (
00039         WithSingleData  ::Process(cur) ||
00040         WithBackground  ::Process(cur) ||
00041         WithForeground  ::Process(cur) ||
00042         WithCoordinates ::Process(cur))
00043         return true;
00044     else {
00045         DisplayError(cur);
00046         return false;
00047     }
00048 }
00049 
00050 void Rectangle::Render() {
00051     float val=m_data.GetVal().GetFloat();
00052     float min=m_data.GetMin().GetFloat();
00053     float max=m_data.GetMax().GetFloat();
00054     float where = (val-min)/(max-min);
00055 
00056     const tCoord edge1(tCoord(m_position.x-m_size.x, m_position.y+m_size.y));
00057     const tCoord edge2(tCoord(m_position.x+m_size.x, m_position.y-m_size.y));
00058 
00059     m_foreground.SetGradientEdges(edge1, edge2);
00060     m_background.SetGradientEdges(edge1, edge2);
00061 
00062     glEnable(GL_ALPHA_TEST);
00063     glAlphaFunc(GL_GREATER,0);
00064 
00065     m_foreground.SetValue(where);
00066     m_background.SetValue(where);
00067 
00068     m_background.BeginDraw();
00069     m_background.DrawRect(edge1, edge2);
00070 }
00071 
00072 }
00073 
00074 #endif

Generated on Sat Mar 15 22:56:05 2008 for Armagetron Advanced by  doxygen 1.5.4