diff options
Diffstat (limited to 'doc/html/RenderWindow_8cpp-source.htm')
-rwxr-xr-x | doc/html/RenderWindow_8cpp-source.htm | 170 |
1 files changed, 0 insertions, 170 deletions
diff --git a/doc/html/RenderWindow_8cpp-source.htm b/doc/html/RenderWindow_8cpp-source.htm deleted file mode 100755 index 9e88a5f..0000000 --- a/doc/html/RenderWindow_8cpp-source.htm +++ /dev/null @@ -1,170 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> -<html> - <head> - <title>SFML - Simple and Fast Multimedia Library</title> - <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> - <link href="doxygen.css" rel="stylesheet" type="text/css" /> - <link href="tabs.css" rel="stylesheet" type="text/css" /> - </head> - <body> - <div id="logo"> - <img src="./logo.jpg" width="770" height="200" title="SFML home" alt="SFML logo" /> - </div> -<!-- Generated by Doxygen 1.5.8 --> -<div class="navigation" id="top"> - <div class="tabs"> - <ul> - <li><a href="index.htm"><span>Main Page</span></a></li> - <li><a href="namespaces.htm"><span>Namespaces</span></a></li> - <li><a href="annotated.htm"><span>Classes</span></a></li> - <li class="current"><a href="files.htm"><span>Files</span></a></li> - </ul> - </div> - <div class="tabs"> - <ul> - <li><a href="files.htm"><span>File List</span></a></li> - </ul> - </div> -<h1>RenderWindow.cpp</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 -<a name="l00002"></a>00002 <span class="comment">//</span> -<a name="l00003"></a>00003 <span class="comment">// SFML - Simple and Fast Multimedia Library</span> -<a name="l00004"></a>00004 <span class="comment">// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)</span> -<a name="l00005"></a>00005 <span class="comment">//</span> -<a name="l00006"></a>00006 <span class="comment">// This software is provided 'as-is', without any express or implied warranty.</span> -<a name="l00007"></a>00007 <span class="comment">// In no event will the authors be held liable for any damages arising from the use of this software.</span> -<a name="l00008"></a>00008 <span class="comment">//</span> -<a name="l00009"></a>00009 <span class="comment">// Permission is granted to anyone to use this software for any purpose,</span> -<a name="l00010"></a>00010 <span class="comment">// including commercial applications, and to alter it and redistribute it freely,</span> -<a name="l00011"></a>00011 <span class="comment">// subject to the following restrictions:</span> -<a name="l00012"></a>00012 <span class="comment">//</span> -<a name="l00013"></a>00013 <span class="comment">// 1. The origin of this software must not be misrepresented;</span> -<a name="l00014"></a>00014 <span class="comment">// you must not claim that you wrote the original software.</span> -<a name="l00015"></a>00015 <span class="comment">// If you use this software in a product, an acknowledgment</span> -<a name="l00016"></a>00016 <span class="comment">// in the product documentation would be appreciated but is not required.</span> -<a name="l00017"></a>00017 <span class="comment">//</span> -<a name="l00018"></a>00018 <span class="comment">// 2. Altered source versions must be plainly marked as such,</span> -<a name="l00019"></a>00019 <span class="comment">// and must not be misrepresented as being the original software.</span> -<a name="l00020"></a>00020 <span class="comment">//</span> -<a name="l00021"></a>00021 <span class="comment">// 3. This notice may not be removed or altered from any source distribution.</span> -<a name="l00022"></a>00022 <span class="comment">//</span> -<a name="l00024"></a>00024 <span class="comment"></span> -<a name="l00026"></a>00026 <span class="comment">// Headers</span> -<a name="l00028"></a>00028 <span class="comment"></span><span class="preprocessor">#include <SFML/Graphics/RenderWindow.hpp></span> -<a name="l00029"></a>00029 <span class="preprocessor">#include <SFML/Graphics/Drawable.hpp></span> -<a name="l00030"></a>00030 <span class="preprocessor">#include <SFML/Graphics/Image.hpp></span> -<a name="l00031"></a>00031 <span class="preprocessor">#include <SFML/Graphics/GraphicsContext.hpp></span> -<a name="l00032"></a>00032 <span class="preprocessor">#include <iostream></span> -<a name="l00033"></a>00033 -<a name="l00034"></a>00034 -<a name="l00035"></a>00035 <span class="keyword">namespace </span>sf -<a name="l00036"></a>00036 { -<a name="l00040"></a><a class="code" href="classsf_1_1RenderWindow.htm#839bbf336bdcafb084dafc3076fc9021">00040</a> <a class="code" href="classsf_1_1RenderWindow.htm#839bbf336bdcafb084dafc3076fc9021" title="Default constructor.">RenderWindow::RenderWindow</a>() -<a name="l00041"></a>00041 { -<a name="l00042"></a>00042 <span class="comment">// Nothing to do</span> -<a name="l00043"></a>00043 } -<a name="l00044"></a>00044 -<a name="l00045"></a>00045 -<a name="l00049"></a><a class="code" href="classsf_1_1RenderWindow.htm#da5aeec63eddbfacb6ee093ed0fff082">00049</a> <a class="code" href="classsf_1_1RenderWindow.htm#839bbf336bdcafb084dafc3076fc9021" title="Default constructor.">RenderWindow::RenderWindow</a>(<a class="code" href="classsf_1_1VideoMode.htm" title="VideoMode defines a video mode (width, height, bpp, frequency) and provides static...">VideoMode</a> Mode, <span class="keyword">const</span> std::string& Title, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> WindowStyle, <span class="keyword">const</span> <a class="code" href="structsf_1_1WindowSettings.htm" title="Structure defining the creation settings of windows.">WindowSettings</a>& Params) -<a name="l00050"></a>00050 { -<a name="l00051"></a>00051 <a class="code" href="classsf_1_1Window.htm#a891f1cbd7d77c4dc02ac950b6e76f61" title="Create (or recreate) the window.">Create</a>(Mode, Title, WindowStyle, Params); -<a name="l00052"></a>00052 } -<a name="l00053"></a>00053 -<a name="l00054"></a>00054 -<a name="l00058"></a><a class="code" href="classsf_1_1RenderWindow.htm#b35dccdc0c735f50edba3acb0cfbea03">00058</a> <a class="code" href="classsf_1_1RenderWindow.htm#839bbf336bdcafb084dafc3076fc9021" title="Default constructor.">RenderWindow::RenderWindow</a>(WindowHandle Handle, <span class="keyword">const</span> <a class="code" href="structsf_1_1WindowSettings.htm" title="Structure defining the creation settings of windows.">WindowSettings</a>& Params) -<a name="l00059"></a>00059 { -<a name="l00060"></a>00060 <a class="code" href="classsf_1_1Window.htm#a891f1cbd7d77c4dc02ac950b6e76f61" title="Create (or recreate) the window.">Create</a>(Handle, Params); -<a name="l00061"></a>00061 } -<a name="l00062"></a>00062 -<a name="l00063"></a>00063 -<a name="l00067"></a><a class="code" href="classsf_1_1RenderWindow.htm#b95277816e7237146ebfeb6d35f85020">00067</a> <a class="code" href="classsf_1_1RenderWindow.htm#b95277816e7237146ebfeb6d35f85020" title="Destructor.">RenderWindow::~RenderWindow</a>() -<a name="l00068"></a>00068 { -<a name="l00069"></a>00069 <span class="comment">// Nothing to do</span> -<a name="l00070"></a>00070 } -<a name="l00071"></a>00071 -<a name="l00072"></a>00072 -<a name="l00076"></a>00076 <span class="keywordtype">bool</span> RenderWindow::Activate(<span class="keywordtype">bool</span> Active) -<a name="l00077"></a>00077 { -<a name="l00078"></a>00078 <span class="comment">// For performances and consistency reasons, we only handle activation</span> -<a name="l00079"></a>00079 <span class="keywordflow">if</span> (Active) -<a name="l00080"></a>00080 <span class="keywordflow">return</span> <a class="code" href="classsf_1_1Window.htm#9fc1e745594d5cf6a30225ec9ea36675" title="Activate of deactivate the window as the current target for rendering.">SetActive</a>(); -<a name="l00081"></a>00081 <span class="keywordflow">else</span> -<a name="l00082"></a>00082 <span class="keywordflow">return</span> <span class="keyword">true</span>; -<a name="l00083"></a>00083 } -<a name="l00084"></a>00084 -<a name="l00085"></a>00085 -<a name="l00089"></a><a class="code" href="classsf_1_1RenderWindow.htm#e2b04f655a655b7c4bfac22958266e0c">00089</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classsf_1_1RenderWindow.htm#e2b04f655a655b7c4bfac22958266e0c" title="Get the width of the rendering region of the window.">RenderWindow::GetWidth</a>()<span class="keyword"> const</span> -<a name="l00090"></a>00090 <span class="keyword"></span>{ -<a name="l00091"></a>00091 <span class="keywordflow">return</span> <a class="code" href="classsf_1_1RenderWindow.htm#e2b04f655a655b7c4bfac22958266e0c" title="Get the width of the rendering region of the window.">sf::Window::GetWidth</a>(); -<a name="l00092"></a>00092 } -<a name="l00093"></a>00093 -<a name="l00094"></a>00094 -<a name="l00098"></a><a class="code" href="classsf_1_1RenderWindow.htm#efa842a47f9c2415d1f8e93543ed2447">00098</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classsf_1_1RenderWindow.htm#efa842a47f9c2415d1f8e93543ed2447" title="Get the height of the rendering region of the window.">RenderWindow::GetHeight</a>()<span class="keyword"> const</span> -<a name="l00099"></a>00099 <span class="keyword"></span>{ -<a name="l00100"></a>00100 <span class="keywordflow">return</span> <a class="code" href="classsf_1_1RenderWindow.htm#efa842a47f9c2415d1f8e93543ed2447" title="Get the height of the rendering region of the window.">sf::Window::GetHeight</a>(); -<a name="l00101"></a>00101 } -<a name="l00102"></a>00102 -<a name="l00103"></a>00103 -<a name="l00107"></a><a class="code" href="classsf_1_1RenderWindow.htm#7066f80705fb53c2c4a9fe068fc47a8a">00107</a> <a class="code" href="classsf_1_1Image.htm" title="Image is the low-level class for loading and manipulating images.">Image</a> <a class="code" href="classsf_1_1RenderWindow.htm#7066f80705fb53c2c4a9fe068fc47a8a" title="Save the content of the window to an image.">RenderWindow::Capture</a>()<span class="keyword"> const</span> -<a name="l00108"></a>00108 <span class="keyword"></span>{ -<a name="l00109"></a>00109 <span class="comment">// Get the window dimensions</span> -<a name="l00110"></a>00110 <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> Width = <a class="code" href="classsf_1_1RenderWindow.htm#e2b04f655a655b7c4bfac22958266e0c" title="Get the width of the rendering region of the window.">GetWidth</a>(); -<a name="l00111"></a>00111 <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> Height = <a class="code" href="classsf_1_1RenderWindow.htm#efa842a47f9c2415d1f8e93543ed2447" title="Get the height of the rendering region of the window.">GetHeight</a>(); -<a name="l00112"></a>00112 -<a name="l00113"></a>00113 <span class="comment">// Set our window as the current target for rendering</span> -<a name="l00114"></a>00114 <span class="keywordflow">if</span> (<a class="code" href="classsf_1_1Window.htm#9fc1e745594d5cf6a30225ec9ea36675" title="Activate of deactivate the window as the current target for rendering.">SetActive</a>()) -<a name="l00115"></a>00115 { -<a name="l00116"></a>00116 <span class="comment">// Make sure we have a valid context</span> -<a name="l00117"></a>00117 priv::GraphicsContext Ctx; -<a name="l00118"></a>00118 -<a name="l00119"></a>00119 <span class="comment">// Get pixels from the backbuffer</span> -<a name="l00120"></a>00120 std::vector<Uint8> Pixels(Width * Height * 4); -<a name="l00121"></a>00121 Uint8* PixelsPtr = &Pixels[0]; -<a name="l00122"></a>00122 GLCheck(glReadPixels(0, 0, Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, PixelsPtr)); -<a name="l00123"></a>00123 -<a name="l00124"></a>00124 <span class="comment">// Flip the pixels</span> -<a name="l00125"></a>00125 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> Pitch = Width * 4; -<a name="l00126"></a>00126 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> y = 0; y < Height / 2; ++y) -<a name="l00127"></a>00127 std::swap_ranges(PixelsPtr + y * Pitch, PixelsPtr + (y + 1) * Pitch, PixelsPtr + (Height - y - 1) * Pitch); -<a name="l00128"></a>00128 -<a name="l00129"></a>00129 <span class="comment">// Create an image from the pixel buffer and return it</span> -<a name="l00130"></a>00130 <span class="keywordflow">return</span> <a class="code" href="classsf_1_1Image.htm" title="Image is the low-level class for loading and manipulating images.">Image</a>(Width, Height, PixelsPtr); -<a name="l00131"></a>00131 } -<a name="l00132"></a>00132 <span class="keywordflow">else</span> -<a name="l00133"></a>00133 { -<a name="l00134"></a>00134 <span class="keywordflow">return</span> <a class="code" href="classsf_1_1Image.htm" title="Image is the low-level class for loading and manipulating images.">Image</a>(Width, Height, <a class="code" href="classsf_1_1Color.htm#4fd874712178d9e206f53226002aa4ca" title="White predefined color.">Color::White</a>); -<a name="l00135"></a>00135 } -<a name="l00136"></a>00136 } -<a name="l00137"></a>00137 -<a name="l00138"></a>00138 -<a name="l00142"></a><a class="code" href="classsf_1_1RenderWindow.htm#05c614a2cdc2c2c4e3b473e39b3b9a17">00142</a> <a class="code" href="classsf_1_1Vector2.htm">sf::Vector2f</a> <a class="code" href="classsf_1_1RenderWindow.htm#05c614a2cdc2c2c4e3b473e39b3b9a17" title="Convert a point in window coordinates into view coordinates.">RenderWindow::ConvertCoords</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> WindowX, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> WindowY, <span class="keyword">const</span> <a class="code" href="classsf_1_1View.htm" title="This class defines a view (position, size, etc.">View</a>* TargetView)<span class="keyword"> const</span> -<a name="l00143"></a>00143 <span class="keyword"></span>{ -<a name="l00144"></a>00144 <span class="comment">// Use the current view if none has been passed</span> -<a name="l00145"></a>00145 <span class="keywordflow">if</span> (!TargetView) -<a name="l00146"></a>00146 TargetView = &<a class="code" href="classsf_1_1RenderTarget.htm#d426b7ba51cc6970fb828a2bef020274" title="Get the current view.">GetView</a>(); -<a name="l00147"></a>00147 -<a name="l00148"></a>00148 <span class="keywordtype">float</span> Left = TargetView-><a class="code" href="classsf_1_1View.htm#edfc422283cb9dbd89c2beb70261b7fd" title="Get the center of the view.">GetCenter</a>().<a class="code" href="classsf_1_1Vector2.htm#1e6ad77fa155f3753bfb92699bd28141" title="X coordinate of the vector.">x</a> - TargetView-><a class="code" href="classsf_1_1View.htm#2fa0eb90604dd90ffdaf2405be276d47" title="Get the half-size of the view.">GetHalfSize</a>().<a class="code" href="classsf_1_1Vector2.htm#1e6ad77fa155f3753bfb92699bd28141" title="X coordinate of the vector.">x</a>; -<a name="l00149"></a>00149 <span class="keywordtype">float</span> Top = TargetView-><a class="code" href="classsf_1_1View.htm#edfc422283cb9dbd89c2beb70261b7fd" title="Get the center of the view.">GetCenter</a>().<a class="code" href="classsf_1_1Vector2.htm#420f2481b015f4eb929c75f2af564299" title="Y coordinate of the vector.">y</a> - TargetView-><a class="code" href="classsf_1_1View.htm#2fa0eb90604dd90ffdaf2405be276d47" title="Get the half-size of the view.">GetHalfSize</a>().<a class="code" href="classsf_1_1Vector2.htm#420f2481b015f4eb929c75f2af564299" title="Y coordinate of the vector.">y</a>; -<a name="l00150"></a>00150 <span class="keywordtype">float</span> Right = TargetView-><a class="code" href="classsf_1_1View.htm#edfc422283cb9dbd89c2beb70261b7fd" title="Get the center of the view.">GetCenter</a>().<a class="code" href="classsf_1_1Vector2.htm#1e6ad77fa155f3753bfb92699bd28141" title="X coordinate of the vector.">x</a> + TargetView-><a class="code" href="classsf_1_1View.htm#2fa0eb90604dd90ffdaf2405be276d47" title="Get the half-size of the view.">GetHalfSize</a>().<a class="code" href="classsf_1_1Vector2.htm#1e6ad77fa155f3753bfb92699bd28141" title="X coordinate of the vector.">x</a>; -<a name="l00151"></a>00151 <span class="keywordtype">float</span> Bottom = TargetView-><a class="code" href="classsf_1_1View.htm#edfc422283cb9dbd89c2beb70261b7fd" title="Get the center of the view.">GetCenter</a>().<a class="code" href="classsf_1_1Vector2.htm#420f2481b015f4eb929c75f2af564299" title="Y coordinate of the vector.">y</a> + TargetView-><a class="code" href="classsf_1_1View.htm#2fa0eb90604dd90ffdaf2405be276d47" title="Get the half-size of the view.">GetHalfSize</a>().<a class="code" href="classsf_1_1Vector2.htm#420f2481b015f4eb929c75f2af564299" title="Y coordinate of the vector.">y</a>; -<a name="l00152"></a>00152 -<a name="l00153"></a>00153 <span class="keywordflow">return</span> <a class="code" href="classsf_1_1Vector2.htm">sf::Vector2f</a>(Left + WindowX * (Right - Left) / <a class="code" href="classsf_1_1RenderWindow.htm#e2b04f655a655b7c4bfac22958266e0c" title="Get the width of the rendering region of the window.">GetWidth</a>(), -<a name="l00154"></a>00154 Top + WindowY * (Bottom - Top) / <a class="code" href="classsf_1_1RenderWindow.htm#efa842a47f9c2415d1f8e93543ed2447" title="Get the height of the rendering region of the window.">GetHeight</a>()); -<a name="l00155"></a>00155 } -<a name="l00156"></a>00156 -<a name="l00157"></a>00157 -<a name="l00161"></a>00161 <span class="keywordtype">void</span> RenderWindow::OnCreate() -<a name="l00162"></a>00162 { -<a name="l00163"></a>00163 <span class="comment">// We can now initialize the render target part</span> -<a name="l00164"></a>00164 <a class="code" href="classsf_1_1RenderTarget.htm#3d9265548b6903ab7f645d12177bba24" title="Called by the derived class when it&#39;s ready to be initialized.">RenderTarget::Initialize</a>(); -<a name="l00165"></a>00165 } -<a name="l00166"></a>00166 -<a name="l00167"></a>00167 } <span class="comment">// namespace sf</span> -</pre></div></div> - - <p id="footer"> - :: Copyright © 2007-2008 Laurent Gomila, all rights reserved :: - Documentation generated by <a href="http://www.doxygen.org/" title="doxygen website">doxygen 1.5.2</a> :: - </p> - - </body> -</html> |