MCPcopy Create free account
hub / github.com/GarageGames/Torque2D / setScreenMode

Method setScreenMode

engine/source/platformAndroid/AndroidOGLVideo.cpp:164–228  ·  view source on GitHub ↗

------------------------------------------------------------------------------ This is the real workhorse function of the DisplayDevice...

Source from the content-addressed store, hash-verified

162// This is the real workhorse function of the DisplayDevice...
163//
164bool OpenGLDevice::setScreenMode(U32 width, U32 height, U32 bpp, bool fullScreen, bool forceIt, bool repaint)
165{
166 Con::printf(" set screen mode %i x %i x %i, %s, %s, %s", width, height, bpp,
167 fullScreen ? "fullscreen" : "windowed",
168 forceIt ? "force it" : "dont force it",
169 repaint ? "repaint" : "dont repaint"
170 );
171
172 // validation, early outs --------------------------------------------------
173 // sanity check. some scripts are liable to pass in bad values.
174 if (!bpp)
175 bpp = platState.desktopBitsPixel;
176
177 Resolution newRes = Resolution(width, height, bpp);
178
179 // if no values changing and we're not forcing a change, kick out. prevents thrashing.
180 if (!forceIt && smIsFullScreen == fullScreen && smCurrentRes == newRes)
181 return (true);
182
183 // we have a new context, this is now safe to do:
184 // delete any contexts or windows that exist, and kill the texture manager.
185 bool needResurrect = cleanupContextAndWindow();
186
187 Con::printf(">> Attempting to change display settings to %s %dx%dx%d...",
188 fullScreen ? "fullscreen" : "windowed", newRes.w, newRes.h, newRes.bpp);
189
190 // set torque variables ----------------------------------------------------
191 // save window size for dgl
192 Platform::setWindowSize(newRes.w, newRes.h);
193
194 // update smIsFullScreen and pref
195 smIsFullScreen = fullScreen;
196
197 Con::setBoolVariable("$pref::Video::fullScreen", smIsFullScreen);
198
199 // save resolution
200 smCurrentRes = newRes;
201
202 // save resolution to prefs
203 char buf[32];
204
205 if (fullScreen)
206 {
207 dSprintf(buf, sizeof(buf), "%d %d %d", newRes.w, newRes.h, newRes.bpp);
208 Con::setVariable("$pref::Video::resolution", buf);
209 }
210 else
211 {
212 dSprintf(buf, sizeof(buf), "%d %d", newRes.w, newRes.h);
213 Con::setVariable("$pref::Video::windowedRes", buf);
214 }
215
216 // begin rendering again ----------------------------------------------------
217 if (needResurrect)
218 {
219 // Reload the textures gl names
220 Con::printf("Resurrecting the texture manager...");
221 Game->textureResurrect();

Callers

nothing calls this directly

Calls 7

printfFunction · 0.85
ResolutionClass · 0.85
setBoolVariableFunction · 0.85
setVariableFunction · 0.85
evaluateFunction · 0.85
textureResurrectMethod · 0.80
dSprintfFunction · 0.70

Tested by

no test coverage detected