aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8/source/Irrlicht/CVideoModeList.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/CVideoModeList.cpp')
-rw-r--r--libraries/irrlicht-1.8/source/Irrlicht/CVideoModeList.cpp264
1 files changed, 132 insertions, 132 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/CVideoModeList.cpp b/libraries/irrlicht-1.8/source/Irrlicht/CVideoModeList.cpp
index 9ae7fb2..268aaf3 100644
--- a/libraries/irrlicht-1.8/source/Irrlicht/CVideoModeList.cpp
+++ b/libraries/irrlicht-1.8/source/Irrlicht/CVideoModeList.cpp
@@ -1,132 +1,132 @@
1// Copyright (C) 2002-2012 Nikolaus Gebhardt 1// Copyright (C) 2002-2012 Nikolaus Gebhardt
2// This file is part of the "Irrlicht Engine". 2// This file is part of the "Irrlicht Engine".
3// For conditions of distribution and use, see copyright notice in irrlicht.h 3// For conditions of distribution and use, see copyright notice in irrlicht.h
4 4
5#include "CVideoModeList.h" 5#include "CVideoModeList.h"
6#include "irrMath.h" 6#include "irrMath.h"
7 7
8namespace irr 8namespace irr
9{ 9{
10namespace video 10namespace video
11{ 11{
12 12
13//! constructor 13//! constructor
14CVideoModeList::CVideoModeList() 14CVideoModeList::CVideoModeList()
15{ 15{
16 #ifdef _DEBUG 16 #ifdef _DEBUG
17 setDebugName("CVideoModeList"); 17 setDebugName("CVideoModeList");
18 #endif 18 #endif
19 19
20 Desktop.depth = 0; 20 Desktop.depth = 0;
21 Desktop.size = core::dimension2d<u32>(0,0); 21 Desktop.size = core::dimension2d<u32>(0,0);
22} 22}
23 23
24 24
25void CVideoModeList::setDesktop(s32 desktopDepth, const core::dimension2d<u32>& desktopSize) 25void CVideoModeList::setDesktop(s32 desktopDepth, const core::dimension2d<u32>& desktopSize)
26{ 26{
27 Desktop.depth = desktopDepth; 27 Desktop.depth = desktopDepth;
28 Desktop.size = desktopSize; 28 Desktop.size = desktopSize;
29} 29}
30 30
31 31
32//! Gets amount of video modes in the list. 32//! Gets amount of video modes in the list.
33s32 CVideoModeList::getVideoModeCount() const 33s32 CVideoModeList::getVideoModeCount() const
34{ 34{
35 return (s32)VideoModes.size(); 35 return (s32)VideoModes.size();
36} 36}
37 37
38 38
39//! Returns the screen size of a video mode in pixels. 39//! Returns the screen size of a video mode in pixels.
40core::dimension2d<u32> CVideoModeList::getVideoModeResolution(s32 modeNumber) const 40core::dimension2d<u32> CVideoModeList::getVideoModeResolution(s32 modeNumber) const
41{ 41{
42 if (modeNumber < 0 || modeNumber > (s32)VideoModes.size()) 42 if (modeNumber < 0 || modeNumber > (s32)VideoModes.size())
43 return core::dimension2d<u32>(0,0); 43 return core::dimension2d<u32>(0,0);
44 44
45 return VideoModes[modeNumber].size; 45 return VideoModes[modeNumber].size;
46} 46}
47 47
48 48
49core::dimension2d<u32> CVideoModeList::getVideoModeResolution( 49core::dimension2d<u32> CVideoModeList::getVideoModeResolution(
50 const core::dimension2d<u32>& minSize, 50 const core::dimension2d<u32>& minSize,
51 const core::dimension2d<u32>& maxSize) const 51 const core::dimension2d<u32>& maxSize) const
52{ 52{
53 u32 best=VideoModes.size(); 53 u32 best=VideoModes.size();
54 // if only one or no mode 54 // if only one or no mode
55 if (best<2) 55 if (best<2)
56 return getVideoModeResolution(0); 56 return getVideoModeResolution(0);
57 57
58 u32 i; 58 u32 i;
59 for (i=0; i<VideoModes.size(); ++i) 59 for (i=0; i<VideoModes.size(); ++i)
60 { 60 {
61 if (VideoModes[i].size.Width>=minSize.Width && 61 if (VideoModes[i].size.Width>=minSize.Width &&
62 VideoModes[i].size.Height>=minSize.Height && 62 VideoModes[i].size.Height>=minSize.Height &&
63 VideoModes[i].size.Width<=maxSize.Width && 63 VideoModes[i].size.Width<=maxSize.Width &&
64 VideoModes[i].size.Height<=maxSize.Height) 64 VideoModes[i].size.Height<=maxSize.Height)
65 best=i; 65 best=i;
66 } 66 }
67 // we take the last one found, the largest one fitting 67 // we take the last one found, the largest one fitting
68 if (best<VideoModes.size()) 68 if (best<VideoModes.size())
69 return VideoModes[best].size; 69 return VideoModes[best].size;
70 const u32 minArea = minSize.getArea(); 70 const u32 minArea = minSize.getArea();
71 const u32 maxArea = maxSize.getArea(); 71 const u32 maxArea = maxSize.getArea();
72 u32 minDist = 0xffffffff; 72 u32 minDist = 0xffffffff;
73 best=0; 73 best=0;
74 for (i=0; i<VideoModes.size(); ++i) 74 for (i=0; i<VideoModes.size(); ++i)
75 { 75 {
76 const u32 area = VideoModes[i].size.getArea(); 76 const u32 area = VideoModes[i].size.getArea();
77 const u32 dist = core::min_(abs(int(minArea-area)), abs(int(maxArea-area))); 77 const u32 dist = core::min_(abs(int(minArea-area)), abs(int(maxArea-area)));
78 if (dist<minDist) 78 if (dist<minDist)
79 { 79 {
80 minDist=dist; 80 minDist=dist;
81 best=i; 81 best=i;
82 } 82 }
83 } 83 }
84 return VideoModes[best].size; 84 return VideoModes[best].size;
85} 85}
86 86
87 87
88//! Returns the pixel depth of a video mode in bits. 88//! Returns the pixel depth of a video mode in bits.
89s32 CVideoModeList::getVideoModeDepth(s32 modeNumber) const 89s32 CVideoModeList::getVideoModeDepth(s32 modeNumber) const
90{ 90{
91 if (modeNumber < 0 || modeNumber > (s32)VideoModes.size()) 91 if (modeNumber < 0 || modeNumber > (s32)VideoModes.size())
92 return 0; 92 return 0;
93 93
94 return VideoModes[modeNumber].depth; 94 return VideoModes[modeNumber].depth;
95} 95}
96 96
97 97
98//! Returns current desktop screen resolution. 98//! Returns current desktop screen resolution.
99const core::dimension2d<u32>& CVideoModeList::getDesktopResolution() const 99const core::dimension2d<u32>& CVideoModeList::getDesktopResolution() const
100{ 100{
101 return Desktop.size; 101 return Desktop.size;
102} 102}
103 103
104 104
105//! Returns the pixel depth of a video mode in bits. 105//! Returns the pixel depth of a video mode in bits.
106s32 CVideoModeList::getDesktopDepth() const 106s32 CVideoModeList::getDesktopDepth() const
107{ 107{
108 return Desktop.depth; 108 return Desktop.depth;
109} 109}
110 110
111 111
112//! adds a new mode to the list 112//! adds a new mode to the list
113void CVideoModeList::addMode(const core::dimension2d<u32>& size, s32 depth) 113void CVideoModeList::addMode(const core::dimension2d<u32>& size, s32 depth)
114{ 114{
115 SVideoMode m; 115 SVideoMode m;
116 m.depth = depth; 116 m.depth = depth;
117 m.size = size; 117 m.size = size;
118 118
119 for (u32 i=0; i<VideoModes.size(); ++i) 119 for (u32 i=0; i<VideoModes.size(); ++i)
120 { 120 {
121 if (VideoModes[i] == m) 121 if (VideoModes[i] == m)
122 return; 122 return;
123 } 123 }
124 124
125 VideoModes.push_back(m); 125 VideoModes.push_back(m);
126 VideoModes.sort(); // TODO: could be replaced by inserting into right place 126 VideoModes.sort(); // TODO: could be replaced by inserting into right place
127} 127}
128 128
129 129
130} // end namespace video 130} // end namespace video
131} // end namespace irr 131} // end namespace irr
132 132