Sophie

Sophie

distrib > Mandriva > 10.0 > i586 > media > contrib > by-pkgid > 06719cf03808e17ae6f0852ca1052dc2 > files > 1177

libogre1-devel-0.13.0-1mdk.i586.rpm

<html>
<head>
<title>OgreSDLGLSupport.cpp Source File - OGRE Documentation</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
<link type="text/css" rel="stylesheet" href="style.css">
</head>

<body>
<!-- Generated by Doxygen 1.2.16 -->
<center>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="namespacemembers.html">Namespace Members</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; <a class="qindex" href="pages.html">Related Pages</a> &nbsp; </center>
<hr><h1>OgreSDLGLSupport.cpp</h1><a href="OgreSDLGLSupport_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <font class="preprocessor">#include "<a class="code" href="OgreException_8h.html">OgreException.h</a>"</font>
00002 <font class="preprocessor">#include "<a class="code" href="OgreLogManager_8h.html">OgreLogManager.h</a>"</font>
00003 <font class="preprocessor">#include "<a class="code" href="OgreStringConverter_8h.html">OgreStringConverter.h</a>"</font>
00004 
00005 <font class="preprocessor">#include "<a class="code" href="OgreSDLGLSupport_8h.html">OgreSDLGLSupport.h</a>"</font>
00006 
00007 <font class="preprocessor">#include "<a class="code" href="OgreSDLWindow_8h.html">OgreSDLWindow.h</a>"</font>
00008 
00009 <font class="keyword">using</font> <font class="keyword">namespace </font>Ogre;
00010 
<a name="l00011"></a><a class="code" href="classOgre_1_1SDLGLSupport.html#Ogre_1_1SDLGLSupporta0">00011</a> SDLGLSupport::SDLGLSupport()
00012 {
00013 
00014     SDL_Init(SDL_INIT_VIDEO);
00015 }
00016 
<a name="l00017"></a><a class="code" href="classOgre_1_1SDLGLSupport.html#Ogre_1_1SDLGLSupporta1">00017</a> SDLGLSupport::~SDLGLSupport()
00018 {
00019 }
00020 
<a name="l00021"></a><a class="code" href="classOgre_1_1SDLGLSupport.html#Ogre_1_1SDLGLSupporta2">00021</a> <font class="keywordtype">void</font> SDLGLSupport::addConfig(<font class="keywordtype">void</font>)
00022 {
00023     <a class="code" href="classOgre_1_1SDLGLSupport.html#Ogre_1_1SDLGLSupporto0">mVideoModes</a> = SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_OPENGL);
00024     
00025     <font class="keywordflow">if</font> (<a class="code" href="classOgre_1_1SDLGLSupport.html#Ogre_1_1SDLGLSupporto0">mVideoModes</a> == (SDL_Rect **)0)
00026     {
00027         <a class="code" href="OgreException_8h.html#a0">Except</a>(999, <font class="stringliteral">"Unable to load video modes"</font>,
00028                 <font class="stringliteral">"SDLRenderSystem::initConfigOptions"</font>);
00029     }
00030 
00031     <a class="code" href="structOgre_1_1__ConfigOption.html">ConfigOption</a> optFullScreen;
00032     <a class="code" href="structOgre_1_1__ConfigOption.html">ConfigOption</a> optVideoMode;
00033 
00034     <font class="comment">// FS setting possiblities</font>
00035     optFullScreen.<a class="code" href="structOgre_1_1__ConfigOption.html#Ogre_1_1__ConfigOptionm0">name</a> = <font class="stringliteral">"Full Screen"</font>;
00036     optFullScreen.<a class="code" href="structOgre_1_1__ConfigOption.html#Ogre_1_1__ConfigOptionm2">possibleValues</a>.push_back(<font class="stringliteral">"Yes"</font>);
00037     optFullScreen.<a class="code" href="structOgre_1_1__ConfigOption.html#Ogre_1_1__ConfigOptionm2">possibleValues</a>.push_back(<font class="stringliteral">"No"</font>);
00038     optFullScreen.<a class="code" href="structOgre_1_1__ConfigOption.html#Ogre_1_1__ConfigOptionm1">currentValue</a> = <font class="stringliteral">"Yes"</font>;
00039     optFullScreen.<a class="code" href="structOgre_1_1__ConfigOption.html#Ogre_1_1__ConfigOptionm3">immutable</a> = <font class="keyword">false</font>;
00040 
00041     <font class="comment">// Video mode possiblities</font>
00042     optVideoMode.<a class="code" href="structOgre_1_1__ConfigOption.html#Ogre_1_1__ConfigOptionm0">name</a> = <font class="stringliteral">"Video Mode"</font>;
00043     optVideoMode.<a class="code" href="structOgre_1_1__ConfigOption.html#Ogre_1_1__ConfigOptionm3">immutable</a> = <font class="keyword">false</font>;
00044     <font class="keywordflow">for</font> (size_t i = 0; <a class="code" href="classOgre_1_1SDLGLSupport.html#Ogre_1_1SDLGLSupporto0">mVideoModes</a>[i]; i++)
00045     {
00046         <font class="keywordtype">char</font> szBuf[16];
00047         snprintf(szBuf, 16, <font class="stringliteral">"%d x %d"</font>, <a class="code" href="classOgre_1_1SDLGLSupport.html#Ogre_1_1SDLGLSupporto0">mVideoModes</a>[i]-&gt;w, <a class="code" href="classOgre_1_1SDLGLSupport.html#Ogre_1_1SDLGLSupporto0">mVideoModes</a>[i]-&gt;h);
00048         optVideoMode.<a class="code" href="structOgre_1_1__ConfigOption.html#Ogre_1_1__ConfigOptionm2">possibleValues</a>.push_back(szBuf);
00049         <font class="comment">// Make the first one default</font>
00050         <font class="keywordflow">if</font> (i == 0)
00051         {
00052             optVideoMode.<a class="code" href="structOgre_1_1__ConfigOption.html#Ogre_1_1__ConfigOptionm1">currentValue</a> = szBuf;
00053         }
00054     }
00055     
00056     <a class="code" href="classOgre_1_1GLSupport.html#Ogre_1_1Win32GLSupportn0">mOptions</a>[optFullScreen.<a class="code" href="structOgre_1_1__ConfigOption.html#Ogre_1_1__ConfigOptionm0">name</a>] = optFullScreen;
00057     <a class="code" href="classOgre_1_1GLSupport.html#Ogre_1_1Win32GLSupportn0">mOptions</a>[optVideoMode.<a class="code" href="structOgre_1_1__ConfigOption.html#Ogre_1_1__ConfigOptionm0">name</a>] = optVideoMode;
00058 }
00059 
<a name="l00060"></a><a class="code" href="classOgre_1_1SDLGLSupport.html#Ogre_1_1SDLGLSupporta3">00060</a> <a class="code" href="classOgre_1_1String.html">String</a> SDLGLSupport::validateConfig(<font class="keywordtype">void</font>)
00061 {
00062     <font class="keywordflow">return</font> <a class="code" href="classOgre_1_1String.html">String</a>(<font class="stringliteral">""</font>);
00063 }
00064 
<a name="l00065"></a><a class="code" href="classOgre_1_1SDLGLSupport.html#Ogre_1_1SDLGLSupporta4">00065</a> <a class="code" href="classOgre_1_1RenderWindow.html">RenderWindow</a>* SDLGLSupport::createWindow(<font class="keywordtype">bool</font> autoCreateWindow, <a class="code" href="classOgre_1_1GLRenderSystem.html">GLRenderSystem</a>* renderSystem)
00066 {
00067     <font class="keywordflow">if</font> (autoCreateWindow)
00068     {
00069         ConfigOptionMap::iterator opt = <a class="code" href="classOgre_1_1GLSupport.html#Ogre_1_1Win32GLSupportn0">mOptions</a>.find(<font class="stringliteral">"Full Screen"</font>);
00070         <font class="keywordflow">if</font> (opt == <a class="code" href="classOgre_1_1GLSupport.html#Ogre_1_1Win32GLSupportn0">mOptions</a>.end())
00071             <a class="code" href="OgreException_8h.html#a0">Except</a>(999, <font class="stringliteral">"Can't find full screen options!"</font>, <font class="stringliteral">"SDLGLSupport::createWindow"</font>);
00072         <font class="keywordtype">bool</font> fullscreen = (opt-&gt;second.currentValue == <font class="stringliteral">"Yes"</font>);
00073 
00074         opt = <a class="code" href="classOgre_1_1GLSupport.html#Ogre_1_1Win32GLSupportn0">mOptions</a>.find(<font class="stringliteral">"Video Mode"</font>);
00075         <font class="keywordflow">if</font> (opt == <a class="code" href="classOgre_1_1GLSupport.html#Ogre_1_1Win32GLSupportn0">mOptions</a>.end())
00076             <a class="code" href="OgreException_8h.html#a0">Except</a>(999, <font class="stringliteral">"Can't find video mode options!"</font>, <font class="stringliteral">"SDLGLSupport::createWindow"</font>);
00077         <a class="code" href="classOgre_1_1String.html">String</a> val = opt-&gt;second.currentValue;
00078         String::size_type pos = val.find(<font class="charliteral">'x'</font>);
00079         <font class="keywordflow">if</font> (pos == String::npos)
00080             <a class="code" href="OgreException_8h.html#a0">Except</a>(999, <font class="stringliteral">"Invalid Video Mode provided"</font>, <font class="stringliteral">"SDLGLSupport::createWindow"</font>);
00081 
00082         <font class="keywordtype">unsigned</font> <font class="keywordtype">int</font> w = StringConverter::parseUnsignedInt(val.substr(0, pos));
00083         <font class="keywordtype">unsigned</font> <font class="keywordtype">int</font> h = StringConverter::parseUnsignedInt(val.substr(pos + 1));
00084 
00085         <font class="keywordflow">return</font> renderSystem-&gt;<a class="code" href="classOgre_1_1GLRenderSystem.html#Ogre_1_1GLRenderSystema12">createRenderWindow</a>(<font class="stringliteral">"OGRE Render Window"</font>, w, h, 32, fullscreen);
00086     }
00087     <font class="keywordflow">else</font>
00088     {
00089         <font class="comment">// XXX What is the else?</font>
00090         <font class="keywordflow">return</font> NULL;
00091     }
00092 }
00093 
<a name="l00094"></a><a class="code" href="classOgre_1_1SDLGLSupport.html#Ogre_1_1SDLGLSupporta5">00094</a> <a class="code" href="classOgre_1_1RenderWindow.html">RenderWindow</a>* SDLGLSupport::newWindow(<font class="keyword">const</font> <a class="code" href="classOgre_1_1String.html">String</a>&amp; name, <font class="keywordtype">unsigned</font> <font class="keywordtype">int</font> width, <font class="keywordtype">unsigned</font> <font class="keywordtype">int</font> height, <font class="keywordtype">unsigned</font> <font class="keywordtype">int</font> colourDepth,
00095         <font class="keywordtype">bool</font> fullScreen, <font class="keywordtype">int</font> left, <font class="keywordtype">int</font> top, <font class="keywordtype">bool</font> depthBuffer, <a class="code" href="classOgre_1_1RenderWindow.html">RenderWindow</a>* parentWindowHandle,
00096         <font class="keywordtype">bool</font> vsync)
00097 {
00098     <a class="code" href="classOgre_1_1SDLWindow.html">SDLWindow</a>* window = <font class="keyword">new</font> <a class="code" href="classOgre_1_1SDLWindow.html">SDLWindow</a>();
00099     window-&gt;<a class="code" href="classOgre_1_1SDLWindow.html#Ogre_1_1SDLWindowa2">create</a>(name, width, height, colourDepth, fullScreen, left, top, depthBuffer,
00100         parentWindowHandle);
00101     <font class="keywordflow">return</font> window;
00102 }
00103 
<a name="l00104"></a><a class="code" href="classOgre_1_1SDLGLSupport.html#Ogre_1_1SDLGLSupporta6">00104</a> <font class="keywordtype">void</font> SDLGLSupport::start()
00105 {
00106     LogManager::getSingleton().logMessage(
00107         <font class="stringliteral">"******************************\n"</font>
00108         <font class="stringliteral">"*** Starting SDL Subsystem ***\n"</font>
00109         <font class="stringliteral">"******************************"</font>);
00110 
00111     SDL_Init(SDL_INIT_VIDEO);
00112 }
00113 
<a name="l00114"></a><a class="code" href="classOgre_1_1SDLGLSupport.html#Ogre_1_1SDLGLSupporta7">00114</a> <font class="keywordtype">void</font> SDLGLSupport::stop()
00115 {
00116     LogManager::getSingleton().logMessage(
00117         <font class="stringliteral">"******************************\n"</font>
00118         <font class="stringliteral">"*** Stopping SDL Subsystem ***\n"</font>
00119         <font class="stringliteral">"******************************"</font>);
00120 
00121     SDL_Quit();
00122 }
00123 
<a name="l00124"></a><a class="code" href="classOgre_1_1SDLGLSupport.html#Ogre_1_1SDLGLSupporta8">00124</a> <font class="keywordtype">void</font>* SDLGLSupport::getProcAddress(<font class="keyword">const</font> <a class="code" href="classOgre_1_1String.html">String</a>&amp; procname)
00125 {
00126     <font class="keywordflow">return</font> SDL_GL_GetProcAddress(procname.c_str());
00127 }
</pre></div><p>
Copyright &copy; 2002-2003 by The OGRE Team<br />
Last modified Wed Jan 21 00:10:27 2004
</p>
</body>
</html>