rViewport Class Reference

#include <rViewport.h>

Collaboration diagram for rViewport:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 rViewport (REAL l, REAL b, REAL w, REAL h)
 rViewport (rViewport &top, rViewport &sub)
 ~rViewport ()
void Select ()
void Perspective (REAL fov, REAL zNear=1, REAL zFar=10000000, REAL xShift=0)
REAL UpDownFOV (REAL fov)
rViewport CorrectAspectBottom () const
 returns a viewport with normal aspect ratio that coincides with this viewport in the bottom line
rViewport EqualAspectBottom () const
 returns a viewport that has the same scale horizontally and vertically
tCoord GetDimensions () const
 returns the height and width of the viewport

Static Public Member Functions

static void CorrectViewport (int i, int mp)
static void CorrectViewports (int mp)
static void SetDirectionOfCorrection (int vp, int dir)
static void Update (int mp)

Static Public Attributes

static rViewport s_viewportFullscreen
static rViewport s_viewportLeft
static rViewport s_viewportRight
static rViewport s_viewportTop
static rViewport s_viewportBottom
static rViewport s_viewportTopLeft
static rViewport s_viewportBottomLeft
static rViewport s_viewportTopRight
static rViewport s_viewportBottomRight
static rViewport s_viewportDemonstation

Private Attributes

REAL left
REAL bottom
REAL width
REAL height


Detailed Description

Definition at line 38 of file rViewport.h.


Constructor & Destructor Documentation

rViewport::rViewport ( REAL  l,
REAL  b,
REAL  w,
REAL  h 
) [inline]

Definition at line 41 of file rViewport.h.

00041 :left(l),bottom(b),width(w),height(h){}

rViewport::rViewport ( rViewport top,
rViewport sub 
) [inline]

Definition at line 43 of file rViewport.h.

00044             :left  (top.left+top.width*sub.left),
00045             bottom(top.bottom+top.height*sub.bottom),
00046             width(top.width*sub.width),
00047     height(top.height*sub.height){}

rViewport::~rViewport (  )  [inline]

Definition at line 49 of file rViewport.h.

References tCHECK_DEST.

00049 {tCHECK_DEST;}


Member Function Documentation

void rViewport::Select (  ) 

Definition at line 43 of file rViewport.cpp.

References bottom, height, left, sr_glOut, sr_screenHeight, sr_screenWidth, and width.

Referenced by rViewportConfiguration::DemonstrateViewport(), display_cockpit_lucifer(), uMenu::Message(), rViewportConfiguration::Select(), and welcome().

00043                       {
00044     if (sr_glOut)
00045         glViewport (GLsizei(sr_screenWidth*left),
00046                     GLsizei(sr_screenHeight*bottom),
00047                     GLsizei(sr_screenWidth*width),
00048                     GLsizei(sr_screenHeight*height));
00049 }

Here is the caller graph for this function:

void rViewport::Perspective ( REAL  fov,
REAL  zNear = 1,
REAL  zFar = 10000000,
REAL  xShift = 0 
)

Definition at line 64 of file rViewport.cpp.

References rScreenSettings::aspect, currentScreensetting, glMatrixMode, height, M_PI, REAL, sr_glOut, sr_screenHeight, sr_screenWidth, tan(), UpDownFOV(), and width.

00064                                                                     {
00065 #ifndef DEDICATED
00066     if (!sr_glOut)
00067         return;
00068 
00069     // Jonathan's improved version
00070     REAL aspectratio = (height * sr_screenHeight) / (width * sr_screenWidth * currentScreensetting.aspect);
00071     REAL ensureverticalfov = fmax((3.0 / 5.0) * aspectratio, 1.0);
00072     REAL xmul = ensureverticalfov * tan((M_PI / 360.0) * fov);
00073     REAL ymul = ensureverticalfov * aspectratio * xmul;
00074     glMatrixMode(GL_PROJECTION);
00075     xshift *= nnear;
00076     glFrustum(-nnear * xmul + xshift, nnear * xmul + xshift, -nnear * ymul, nnear * ymul, nnear, ffar);
00077     glTranslatef(xshift, 0.f, 0.f);
00078 
00079 #if 0 // Z-Man's old and clumsy version
00080     REAL ratio=currentScreensetting.aspect*(width*sr_screenWidth)/(height*sr_screenHeight);
00081     // REAL udfov=360*atan(tan(M_PI*fov/360)/ratio)/M_PI;
00082     REAL udfov=UpDownFOV(fov);
00083     glMatrixMode(GL_PROJECTION);
00084     gluPerspective(
00085         udfov,
00086         ratio,
00087         nnear,
00088         ffar
00089     );
00090 #endif
00091 
00092 #endif
00093 }

Here is the call graph for this function:

REAL rViewport::UpDownFOV ( REAL  fov  ) 

Definition at line 53 of file rViewport.cpp.

References rScreenSettings::aspect, atan(), currentScreensetting, height, M_PI, REAL, sr_screenHeight, sr_screenWidth, tan(), and width.

Referenced by Perspective().

00053                                  {
00054     REAL ratio=currentScreensetting.aspect*(width*sr_screenWidth)/(height*sr_screenHeight);
00055 
00056     // clamp ratio to 5/3
00057     REAL maxratio = 5.0/3.0;
00058     if (ratio > maxratio)
00059         ratio = maxratio;
00060 
00061     return 360*atan(tan(M_PI*fov/360)/ratio)/M_PI;
00062 }

Here is the call graph for this function:

Here is the caller graph for this function:

rViewport rViewport::CorrectAspectBottom ( void   )  const

returns a viewport with normal aspect ratio that coincides with this viewport in the bottom line

Returns:

Definition at line 303 of file rViewport.cpp.

References height, and width.

00304 {
00305     rViewport ret( *this );
00306     ret.height = width * 4.0 / 3.0;
00307 
00308     return ret;
00309 }

rViewport rViewport::EqualAspectBottom ( void   )  const

returns a viewport that has the same scale horizontally and vertically

Definition at line 311 of file rViewport.cpp.

References height, sr_screenHeight, sr_screenWidth, and width.

Referenced by display_cockpit_lucifer().

00312 {
00313     rViewport ret( *this );
00314     ret.height = width * sr_screenWidth / sr_screenHeight;
00315 
00316     return ret;
00317 }

Here is the caller graph for this function:

tCoord rViewport::GetDimensions (  )  const [inline]

returns the height and width of the viewport

Definition at line 66 of file rViewport.h.

References height, and width.

Referenced by display_cockpit_lucifer().

00066 {return tCoord(width, height);}

Here is the caller graph for this function:

void rViewport::CorrectViewport ( int  i,
int  mp 
) [static]

Definition at line 253 of file rViewport.cpp.

References conf_num, rViewportConfiguration::next_conf_num, rViewportConfiguration::num_viewports, s_newViewportBelongsToPlayer, and vpb_dir.

Referenced by CorrectViewports(), and ArmageTronPlayer_to_viewport_menuitem::RenderBackground().

00253                                                      {
00254     if (vpb_dir[i]!=1 && vpb_dir[i]!=-1)
00255         vpb_dir[i]=1;
00256     s_newViewportBelongsToPlayer[i]+=MAX_PLAYERS-vpb_dir[i];
00257     s_newViewportBelongsToPlayer[i]%=MAX_PLAYERS;
00258     bool again;
00259     do{
00260         s_newViewportBelongsToPlayer[i]+=MAX_PLAYERS+vpb_dir[i];
00261         s_newViewportBelongsToPlayer[i]%=MAX_PLAYERS;
00262         again=false;
00263         int starta=rViewportConfiguration::s_viewportConfigurations[rViewportConfiguration::next_conf_num]->num_viewports-1;
00264         int startb=rViewportConfiguration::s_viewportConfigurations[     conf_num]->num_viewports-1;
00265         if (starta>startb)
00266             startb=starta;
00267         for(int j=starta;j>=0;j--)
00268             if (i!=j && s_newViewportBelongsToPlayer[i]
00269                     ==s_newViewportBelongsToPlayer[j])
00270                 again=true;
00271     } while(again);
00272 }

Here is the caller graph for this function:

void rViewport::CorrectViewports ( int  mp  )  [static]

Definition at line 274 of file rViewport.cpp.

References conf_num, and CorrectViewport().

Referenced by Update().

00274                                                {
00275     for (int i=rViewportConfiguration::s_viewportConfigurations[conf_num]->num_viewports-1;i>=0;i--)
00276         CorrectViewport(i, MAX_PLAYERS);
00277 }

Here is the call graph for this function:

Here is the caller graph for this function:

void rViewport::SetDirectionOfCorrection ( int  vp,
int  dir 
) [static]

Definition at line 289 of file rViewport.cpp.

References vpb_dir.

Referenced by ArmageTronPlayer_to_viewport_menuitem::LeftRight().

00289                                                        {
00290     vpb_dir[vp] = dir;
00291 }

Here is the caller graph for this function:

void rViewport::Update ( int  mp  )  [static]

Definition at line 280 of file rViewport.cpp.

References CorrectViewports(), MAX_VIEWPORTS, s_newViewportBelongsToPlayer, sr_viewportBelongsToPlayer, and rViewportConfiguration::UpdateConf().

Referenced by ConnectToServerCore(), ingame_menu_cleanup(), MainMenu(), and gGame::StateUpdate().

00280                                      {
00281     rViewportConfiguration::UpdateConf();
00282     CorrectViewports(MAX_PLAYERS);
00283 
00284     int i;
00285     for(i=MAX_VIEWPORTS-1;i>=0;i--)
00286         sr_viewportBelongsToPlayer[i]=s_newViewportBelongsToPlayer[i];
00287 }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

REAL rViewport::left [private]

Definition at line 39 of file rViewport.h.

Referenced by Select().

REAL rViewport::bottom [private]

Definition at line 39 of file rViewport.h.

Referenced by Select().

REAL rViewport::width [private]

Definition at line 39 of file rViewport.h.

Referenced by CorrectAspectBottom(), EqualAspectBottom(), GetDimensions(), Perspective(), Select(), and UpDownFOV().

REAL rViewport::height [private]

Definition at line 39 of file rViewport.h.

Referenced by CorrectAspectBottom(), EqualAspectBottom(), GetDimensions(), Perspective(), Select(), and UpDownFOV().

static rViewportConfiguration single_vp & rViewport::s_viewportFullscreen [static]

Definition at line 68 of file rViewport.h.

Referenced by rViewportConfiguration::DemonstrateViewport(), uMenu::Message(), and welcome().

static rViewportConfiguration two_b & rViewport::s_viewportLeft [static]

Definition at line 68 of file rViewport.h.

rViewport rViewport::s_viewportRight [static]

Definition at line 68 of file rViewport.h.

static rViewportConfiguration three_a & rViewport::s_viewportTop [static]

Definition at line 68 of file rViewport.h.

rViewport rViewport::s_viewportBottom [static]

Definition at line 68 of file rViewport.h.

static rViewportConfiguration four_vp & rViewport::s_viewportTopLeft [static]

Definition at line 68 of file rViewport.h.

rViewport rViewport::s_viewportBottomLeft [static]

Definition at line 68 of file rViewport.h.

rViewport rViewport::s_viewportTopRight [static]

Definition at line 68 of file rViewport.h.

rViewport rViewport::s_viewportBottomRight [static]

Definition at line 68 of file rViewport.h.

rViewport rViewport::s_viewportDemonstation [static]

Definition at line 68 of file rViewport.h.

Referenced by rViewportConfiguration::DemonstrateViewport().


The documentation for this class was generated from the following files:
Generated on Sat Mar 15 23:54:38 2008 for Armagetron Advanced by  doxygen 1.5.4