git-svn-id: https://scorched3d.svn.sourceforge.net/svnroot/scorched3d/trunk/scorched...
[scorched3d/parasti.git] / src / client / GLEXT / GLViewPort.cpp
blobc83c18d825f419c2147ae300138ac60732f50554
1 ////////////////////////////////////////////////////////////////////////////////
2 // Scorched3D (c) 2000-2009
3 //
4 // This file is part of Scorched3D.
5 //
6 // Scorched3D is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
11 // Scorched3D is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with Scorched3D; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 ////////////////////////////////////////////////////////////////////////////////
21 #include <GLEXT/GLViewPort.h>
22 #include <GLEXT/GLState.h>
24 int GLViewPort::width_ = 0;
25 int GLViewPort::height_ = 0;
26 int GLViewPort::actualWidth_ = 0;
27 int GLViewPort::actualHeight_ = 0;
28 float GLViewPort::widthMult_ = 0.0f;
29 float GLViewPort::heightMult_ = 0.0f;
31 GLViewPort::GLViewPort()
35 GLViewPort::~GLViewPort()
39 void GLViewPort::draw()
41 glMatrixMode(GL_PROJECTION);
42 glLoadIdentity();
43 glViewport(0, 0, actualWidth_, actualHeight_);
44 glOrtho(0.0, float(width_),
45 0.0, float(height_),
46 -4000.0, 4000.0);
47 glMatrixMode(GL_MODELVIEW);
48 glLoadIdentity();
51 void GLViewPort::setWindowSize(int width, int height,
52 int awidth, int aheight)
54 width_ = width;
55 height_ = height;
56 if (awidth != 0 && aheight != 0)
58 actualWidth_ = awidth;
59 actualHeight_ = aheight;
62 widthMult_ = (float) width_ / (float) actualWidth_;
63 heightMult_ = (float) height_ / (float) actualHeight_;