PEBL 2.2
Psychology Experiment Building Language - Cross-platform psychological experiment development system
PlatformWindow Class Reference

#include <PlatformWindow.h>

Inheritance diagram for PlatformWindow:
PWindow PlatformWidget PWindow PlatformWidget PWidget PWidget PWidget PWidget PWidget PWidget PEBLObjectBase PEBLObjectBase PEBLObjectBase PEBLObjectBase PEBLObjectBase PEBLObjectBase

Public Member Functions

 PlatformWindow (PlatformEnvironment *penv)
 Standard Constructor.
 
 ~PlatformWindow ()
 Standard Destructor.
 
bool Initialize (PEBLVideoMode mode, PEBLVideoDepth vdepth, bool windowed, bool resizeable, unsigned int width, unsigned int height)
 This method initiates everything needed to display the main window.
 
int GetVideoFlags ()
 
bool Resize (int w, int h)
 
bool Draw ()
 
long int DrawFor (unsigned int cycles)
 
SDL_Window * GetSDLWindow ()
 
int SaveScreenShot (int x, int y, int w, int h, const Variant fname)
 
 PlatformWindow (PlatformEnvironment *env)
 
virtual ~PlatformWindow ()
 
virtual bool Draw ()
 
virtual std::string ObjectName () const
 
virtual int SaveScreenShot (int x, int y, int w, int h, const Variant fname)
 
virtual bool Initialize (PEBLVideoMode mode, PEBLVideoDepth depth, bool windowed, bool resizeable, unsigned int width, unsigned int height)
 
virtual bool Resize (int w, int h)
 
virtual long int DrawFor (unsigned int cycles)
 
virtual bool SetProperty (std::string name, Variant v)
 
virtual ObjectValidationError ValidateProperty (std::string name, Variant v) const
 
virtual ObjectValidationError ValidateProperty (std::string name) const
 
virtual pInt GetWidth () const
 
virtual pInt GetHeight () const
 
virtual void SetPosition (pInt x, pInt y)
 This sets the widget's position on its parent widget.
 
virtual void SetBackgroundColor (const PColor &color)
 
- Public Member Functions inherited from PWindow
 PWindow (PEnvironment *penv)
 
virtual ~PWindow ()
 
virtual Variant GetProperty (std::string) const
 
- Public Member Functions inherited from PWidget
 PWidget ()
 
 PWidget (const PWidget &pw)
 
 PWidget (pInt x, pInt y, pInt width, pInt height, bool visible)
 
virtual ~PWidget ()
 
virtual void SetParent (PWidget *widget)
 This unconditionally sets the parent widget.
 
virtual PWidgetGetParent ()
 
virtual bool IsParent (PWidget *parent)
 
virtual void SetZoomX (pDouble x)
 This sets the widget's position on its parent widget.
 
virtual void SetZoomY (pDouble x)
 This sets the widget's position on its parent widget.
 
virtual void SetRotation (pDouble x)
 This sets the widget's position on its parent widget.
 
virtual void SetWidth (pInt w)
 
virtual void SetHeight (pInt h)
 
virtual pInt GetX () const
 
virtual pInt GetY () const
 
virtual PColor GetBackgroundColor ()
 
virtual bool AddSubWidget (PWidget *widget)
 
virtual bool RemoveSubWidget (PWidget *widget)
 
virtual bool RemoveLastSubWidget ()
 This is probably pretty useless.
 
virtual void Show ()
 
virtual void Hide ()
 
virtual bool IsVisible () const
 
- Public Member Functions inherited from PEBLObjectBase
 PEBLObjectBase ()
 Standard Constructor.
 
 PEBLObjectBase (ComplexDataType cdt)
 Standard Constructor.
 
 PEBLObjectBase (const PEBLObjectBase &pob)
 
virtual ~PEBLObjectBase ()
 Standard Destructor.
 
virtual bool InitializeProperty (std::string name, Variant v)
 
Variant GetProperty (std::string) const
 
ComplexDataType GetType ()
 
virtual std::ostream & PrintProperties (std::ostream &out)
 
virtual Variant GetPropertyList ()
 
- Public Member Functions inherited from PlatformWidget
 PlatformWidget ()
 
virtual ~PlatformWidget ()
 
virtual SDL_Texture * GetSDL_Texture ()
 Used to extract an SDL surface from the widget. Used by children drawing themselves on their parent.
 
void SetParent (PlatformWidget *parent)
 
SDL_Surface * GetSurface ()
 
virtual bool SetRenderer (SDL_Renderer *renderer)
 
SDL_Renderer * GetRenderer ()
 
virtual bool AddToParentWidget (PlatformWidget *parent)
 
virtual bool AddSubWidget (PlatformWidget *widget)
 
virtual bool RemoveSubWidget (PlatformWidget *widget)
 
virtual bool RemoveSubWidgets ()
 
virtual bool RotoZoom (double angle, double zoomx, double zoomy, int smooth)
 This uses the SDL_gfx package to 'rotozoom'.
 
bool SetPoint (int x, int y, PColor col)
 
PColor GetPixel (int x, int y)
 
 PlatformWidget ()
 
 PlatformWidget (pInt x, pInt y, pInt width, pInt height, bool visible)
 
virtual ~PlatformWidget ()
 
virtual bool RotoZoom (pDouble angle, pDouble zoomx, pDouble zoomy, pInt smooth)
 
virtual bool SetPoint (pInt x, pInt y, PColor col)
 
virtual PColor GetPixel (pInt x, pInt y)
 

Protected Member Functions

virtual std::ostream & SendToStream (std::ostream &out) const
 An inheritable printing class used by PEBLObjectBase::operator<<.
 
virtual std::string ObjectName () const
 
virtual std::ostream & SendToStream (std::ostream &out) const
 An inheritable printing class used by PEBLObjectBase::operator<<.
 
- Protected Member Functions inherited from PlatformWidget
virtual void PrintSubWidgets (std::ostream &out) const
 
virtual bool LockSurface ()
 This needs to be used on some platforms/video cards.
 
virtual bool UnlockSurface ()
 This needs to be used on some platforms/video cards.
 

Additional Inherited Members

- Protected Attributes inherited from PWindow
PEnvironmentmEnv
 
- Protected Attributes inherited from PWidget
pInt mX
 
pInt mY
 
pInt mDrawX
 
pInt mDrawY
 
pInt mWidth
 
pInt mHeight
 
pDouble mZoomX
 
pDouble mZoomY
 
pDouble mRotation
 
PColor mBackgroundColor
 The background color of the widget. if alpha = 0, will not be painted.
 
std::list< PWidget * > mSubWidgets
 
bool mIsVisible
 
PWidgetmParent
 
- Protected Attributes inherited from PEBLObjectBase
ComplexDataType mCDT
 
std::map< std::string, VariantmProperties
 
- Protected Attributes inherited from PlatformWidget
pInt mTextureWidth
 
pInt mTextureHeight
 
bool mNeedsTexture
 
SDL_Texture * mTexture
 
SDL_Surface * mSurface
 
SDL_Renderer * mRenderer
 

Detailed Description

This class instantiates a PWindow using platform-specific code.

Headless platform window - no actual display Used for validation mode where no window is needed

Definition at line 48 of file sdl/PlatformWindow.h.

Constructor & Destructor Documentation

◆ PlatformWindow() [1/2]

PlatformWindow::PlatformWindow ( PlatformEnvironment penv)

Standard Constructor.

Definition at line 56 of file sdl/PlatformWindow.cpp.

56 :
57 mFlags(0),
58 mWindow(NULL),
59 PWindow(penv)
60
61{
63 // InitializeProperty("COLOR",Variant("grey"));//dummy property setting
64 // PWidget::SetBackgroundColor(PColor(200,200,200,255));
65 PColor tmpColor = PColor(0,0,0,255);
67
68 //These don't get used for windows:
69 mSurface = NULL;
70 mTexture = NULL;
72}
#define NULL
Definition BinReloc.cpp:317
@ CDT_WINDOW
Definition PEBLObject.h:58
ComplexDataType mCDT
Definition PEBLObject.h:109
virtual void SetBackgroundColor(const PColor &color)
Definition PWidget.cpp:287
SDL_Surface * mSurface
SDL_Texture * mTexture
SDL_Renderer * mRenderer

References CDT_WINDOW, PEBLObjectBase::mCDT, PlatformWidget::mRenderer, PlatformWidget::mSurface, PlatformWidget::mTexture, NULL, and PWidget::SetBackgroundColor().

◆ ~PlatformWindow() [1/2]

PlatformWindow::~PlatformWindow ( )

Standard Destructor.

Definition at line 75 of file sdl/PlatformWindow.cpp.

76{
77
78
79 SDL_DestroyWindow(mWindow);
80 mWindow = NULL;
81
82}

References NULL.

◆ PlatformWindow() [2/2]

PlatformWindow::PlatformWindow ( PlatformEnvironment env)

◆ ~PlatformWindow() [2/2]

virtual PlatformWindow::~PlatformWindow ( )
virtual

Member Function Documentation

◆ Draw() [1/2]

bool PlatformWindow::Draw ( )
virtual

This draws the subwidgets. It doesn't need a 'parent' argument, because 'this' is it.

Reimplemented from PWindow.

Definition at line 427 of file sdl/PlatformWindow.cpp.

428{
429
430
431
432 //if (SDL_MUSTLOCK(mSurface)) SDL_LockSurface(mSurface);
433
434
435 // Get background color from property system (in case it was modified via nested properties)
436 Variant backgroundColor = PEBLObjectBase::GetProperty("BGCOLOR");
437 PColor* bgColor = nullptr;
438 if(backgroundColor.GetComplexData())
439 {
440 bgColor = dynamic_cast<PColor*>(backgroundColor.GetComplexData()->GetObject().get());
441 }
442
443 // Use property color if available, otherwise fall back to mBackgroundColor
444 if(!bgColor)
445 {
446 bgColor = &mBackgroundColor;
447 }
448
449#ifdef SDL2_DELETE
450 //First, draw the background
451 SDL_FillRect(mSurface, NULL, SDL_MapRGBA(mSurface->format,
452 bgColor->GetRed(),
453 bgColor->GetGreen(),
454 bgColor->GetBlue(),
455 bgColor->GetAlpha()));
456#endif
457
458
459 int result= SDL_SetRenderDrawColor(mRenderer,
460 bgColor->GetRed(),
461 bgColor->GetGreen(),
462 bgColor->GetBlue(),
463 bgColor->GetAlpha());
464
465
466 // while(p != mSubWidgets.begin())
467 // {
468 // p--;
469 //cout << "------drawing Subwidget on window:" << *p << "[" << **p << "]" << endl;
470
471 // }
472
473 SDL_RenderClear(mRenderer);//clear the window
474 if(result < 0)
475 {
476 PError::SignalFatalError("Unable to clear window");
477 std::cerr <<SDL_GetError() << endl;
478 }
479
480
481 //cout << "Number of subwidgets: " << mSubWidgets.size() << endl;
482 //This handles drawing each subwidget.
483 std::list<PWidget *>::iterator p = mSubWidgets.end();
484
485 while(p != mSubWidgets.begin())
486 {
487 //cout <<"Size"<< mSubWidgets.size() << endl;
488
489
490 //decrement iterator--moving backward so we draw things in
491 //reverse order.
492 p--;
493
494 //Draw the subwidget
495 if((*p)->IsVisible())
496 {
497 (*p)->Draw();
498 }
499
500 }
501
502 SDL_RenderPresent(mRenderer);//draw the window.
503
504
505#ifdef PEBL_EMSCRIPTEN
506 // int result = SDL_Flip(mSurface);
507#else
508// int result = SDL_Flip(mSurface);
509#endif
510
511
512 return true;
513}
int GetRed() const
Definition PColor.cpp:226
int GetAlpha() const
Definition PColor.cpp:229
int GetBlue() const
Definition PColor.cpp:228
int GetGreen() const
Definition PColor.cpp:227
counted_ptr< PEBLObjectBase > GetObject() const
Variant GetProperty(std::string) const
std::list< PWidget * > mSubWidgets
Definition PWidget.h:147
PColor mBackgroundColor
The background color of the widget. if alpha = 0, will not be painted.
Definition PWidget.h:144
PComplexData * GetComplexData() const
Definition Variant.cpp:1299
X * get() const
Definition rc_ptrs.h:110
void SignalFatalError(const std::string &message)

References counted_ptr< X >::get(), PColor::GetAlpha(), PColor::GetBlue(), Variant::GetComplexData(), PColor::GetGreen(), PComplexData::GetObject(), PEBLObjectBase::GetProperty(), PColor::GetRed(), PWidget::mBackgroundColor, PlatformWidget::mRenderer, PWidget::mSubWidgets, PlatformWidget::mSurface, NULL, and PError::SignalFatalError().

Referenced by DrawFor(), and Initialize().

◆ Draw() [2/2]

virtual bool PlatformWindow::Draw ( )
virtual

This draws the subwidgets. It doesn't need a 'parent' argument, because 'this' is it.

Reimplemented from PWindow.

◆ DrawFor() [1/2]

long int PlatformWindow::DrawFor ( unsigned int  cycles)

Definition at line 521 of file sdl/PlatformWindow.cpp.

522{
523
524 //Do an initial syncing flip.
525 int result = 0;// = SDL_Flip(mSurface);
526
527 // cout << "Drawforing cycles: " << cycles << endl;
528
529 //Now, draw the subwidgets.
530
531 unsigned int cyclesleft = cycles;
532 unsigned int tstart = SDL_GetTicks();
533
534 while(cyclesleft > 0 )
535 {
536 //Get the time *AFTER* the first cycle.
537 //This method will only really work on a platform wher SDL_Flip blocks.
538
539 //result = SDL_Flip(mSurface);
540 Draw();
541 // cout << ".";
542 cyclesleft--;
543 }
544
545 unsigned int tend = SDL_GetTicks();
546 //cout << "\n";
547 result = tend-tstart;
548
549 //If the return value is positive, it is the time that
550 //this was displayed. Otherwise, it is an error code.
551 return result;
552
553}

References Draw().

Referenced by PEBLObjects::DrawFor().

◆ DrawFor() [2/2]

virtual long int PlatformWindow::DrawFor ( unsigned int  cycles)
inlinevirtual

Definition at line 45 of file validator/PlatformWindow.h.

45{ return 0; }

◆ GetHeight()

virtual pInt PlatformWindow::GetHeight ( ) const
inlinevirtual

Reimplemented from PWidget.

Definition at line 60 of file validator/PlatformWindow.h.

60{ return PWindow::GetHeight(); }
virtual pInt GetHeight() const
Definition PWidget.h:86

References PWidget::GetHeight().

Referenced by PEBLStream::WritePNG().

◆ GetSDLWindow()

SDL_Window * PlatformWindow::GetSDLWindow ( )
inline

Definition at line 72 of file sdl/PlatformWindow.h.

72{return mWindow;};

Referenced by SDLUtility::PopupErrorBox().

◆ GetVideoFlags()

int PlatformWindow::GetVideoFlags ( )

Definition at line 92 of file sdl/PlatformWindow.cpp.

93{
94 return 0;
95
96}

◆ GetWidth()

virtual pInt PlatformWindow::GetWidth ( ) const
inlinevirtual

Reimplemented from PWidget.

Definition at line 59 of file validator/PlatformWindow.h.

59{ return PWindow::GetWidth(); }
virtual pInt GetWidth() const
Definition PWidget.h:85

References PWidget::GetWidth().

Referenced by PEBLStream::WritePNG().

◆ Initialize() [1/2]

virtual bool PlatformWindow::Initialize ( PEBLVideoMode  mode,
PEBLVideoDepth  depth,
bool  windowed,
bool  resizeable,
unsigned int  width,
unsigned int  height 
)
inlinevirtual

Definition at line 43 of file validator/PlatformWindow.h.

43{ return true; }

◆ Initialize() [2/2]

bool PlatformWindow::Initialize ( PEBLVideoMode  mode,
PEBLVideoDepth  vdepth,
bool  windowed,
bool  resizeable,
unsigned int  width,
unsigned int  height 
)

This method initiates everything needed to display the main window.

This shouldn't be necessary, but if we specify the same screensize as the window, it goes to fake fullscreen mode.

Definition at line 102 of file sdl/PlatformWindow.cpp.

108{
109
110 cerr << "Initializing " << width << "--" << height << endl;
111 SDLUtility::GetDriverList(); //print out driver information.
112 Variant v = 0;
113
114 Evaluator * myEval = new Evaluator(v,"Window");
115 //gVideoWidth and gVideoHeight may have been set by the user
116 //in the script. First, get these values, and try them.
117
118 Variant vDp = 0;
119 bool vsync = true;
120 bool softrender = false;
121
122
123
124
125 if(myEval->gGlobalVariableMap.Exists("gVideoDepth"))
126 vDp = myEval->gGlobalVariableMap.RetrieveValue("gVideoDepth");
127
128
129 if(myEval->gGlobalVariableMap.Exists("gVSync"))
130 {
131 vsync = (int)((myEval->gGlobalVariableMap.RetrieveValue("gVsync"))) != 0;
132
133 }
134 //cout <<" vsync state: " << vsync <<"\n";
135
136 if(myEval->gGlobalVariableMap.Exists("gSoftRender"))
137 {
138 softrender = (int)((myEval->gGlobalVariableMap.RetrieveValue("gSoftRender"))) != 0;
139 }
140
141
142
143
144 //Should be direct3d (windows), opengl, opengles2 opengles,software.
145 if(myEval->gGlobalVariableMap.Exists("gDriverHint"))
146 {
147 SDL_SetHint("SDL_HINT_RENDER_DRIVER",
148 ( myEval->gGlobalVariableMap.RetrieveValue("gDriverHint").GetString().c_str()));
149 }
150
151
152 //some other hints available via SDL
153 //SDL_SetHint("SDL_HINT_VIDEO_ALLOW_SCREENSAVER","0");
154 if(!windowed)
155 {
156 //this might not be the best approach.
157 SDL_SetHint("SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES","1");
158 }
159
160
161 if(vsync)
162 {
163 SDL_SetHint("SDL_HINT_RENDER_VSYNC","1");
164 }
165
166
167 SDL_SetHint("SDL_HINT_MOUSE_RELATIVE_MODE_WARP","1");
168
169 //Set the renderer flags. We are by default accelerated.
170 //there we could bump up to vsync, or down to software.
171 //If you try to specify both vsync and software, it will just use software.
172
173 int rflags = SDL_RENDERER_TARGETTEXTURE;
174 if(softrender)
175 {
176 rflags |= SDL_RENDERER_SOFTWARE;
177 }else
178 {
179
180 rflags |= SDL_RENDERER_ACCELERATED;
181
182#ifndef PEBL_EMSCRIPTEN
183 if(vsync)
184 {
185 rflags |= SDL_RENDERER_PRESENTVSYNC;
186
187 }
188#endif
189 }
190
191
192 int depth = vDp;
193
194 // cout << width << "----" << height << " in platformwindow\n";
195
196
197
198 if(!(depth > 0))
199 depth = (int)vdepth;
200
201
202
203 int vflags = 0;//GetVideoFlags();
204
205 if(!windowed)
206 {
207 vflags |= SDL_WINDOW_FULLSCREEN ; // Enable fullscreen
208 }
209
210 if(resizeable)
211 {
212 vflags |= SDL_WINDOW_RESIZABLE; //IS the window resizeable?
213 }
214
215 //Re-store the values
216 myEval->gGlobalVariableMap.AddVariable("gVideoWidth", (long unsigned int)width);
217 myEval->gGlobalVariableMap.AddVariable("gVideoHeight", (long unsigned int)height);
218 myEval->gGlobalVariableMap.AddVariable("gVideoDepth", depth);
219
220 PWidget::SetProperty("WIDTH",(long unsigned int)width);
221 PWidget::SetProperty("HEIGHT",(long unsigned int)height);
222
223 delete myEval;
224
225 bool success = 0;
226 //INitialize the SDL surface with the appropriate flags.
227
228 Variant scriptname = "PEBL Application";
229 if(myEval->gGlobalVariableMap.Exists("gScriptName"))
230 {
231 scriptname = myEval->gGlobalVariableMap.RetrieveValue("gScriptName");
232 }
233
234 std::string sname = scriptname;
235 int x= SDL_WINDOWPOS_CENTERED;
236 int y= 15;//SDL_WINDOWPOS_CENTERED;
237 if(!windowed)
238 {
239 x = SDL_WINDOWPOS_UNDEFINED;
240 y = SDL_WINDOWPOS_UNDEFINED;
241 }
242
243 mWindow =SDL_CreateWindow(sname.c_str(),x,y,
244 //SDL_WINDOWPOS_UNDEFINED,
245 //SDL_WINDOWPOS_UNDEFINED,
246 width,height, vflags);
247
249
250 mRenderer = SDL_CreateRenderer(mWindow, -1,rflags);
251// mRenderer = SDL_CreateRenderer(mWindow,-1, SDL_RENDERER_ACCELERATED|SDL_RENDERER_TARGETTEXTURE|SDL_RENDERER_PRESENTVSYNC);
252 //mRenderer = SDL_CreateSoftwareRenderer(SDL_GetWindowSurface(mWindow));
253 //mRenderer = SDL_CreateRenderer(mWindow, -1, SDL_RENDERER_ACCELERATED|SDL_RENDERER_TARGETTEXTURE);
254
255 if(mRenderer)
256 {
257 success = true;
258 }else{
259 PError::SignalFatalError("Failed to create renderer in PlatformWindow\n");
260 }
261
262
263 mFlags = vflags;
264#ifdef SDL2_DELETE
265 // mSurface = SDL_SetVideoMode(width,height,depth,SDL_HWACCEL | SDL_FULLSCREEN | SDL_DOUBLEBUF);
266 if ( mSurface == NULL )
267 {
268 //If we fail, try to do our best.
269 cerr << "Unable to set " << width << "x" << height << ": " << depth << " video mode: " << SDL_GetError() << endl;
270
271 //This needs to be reworked because of new API that handles multi-screens, etc.
272
273 //Get a list of available resolutions and try these out.
274 SDL_Rect** modes = SDL_ListModes(NULL,vflags);
275 if(modes == (SDL_Rect**)0)
276 {
277 cerr << "No Video Modes Available" << endl;
278 } else{
279 for(int i=0; modes[i];++i)
280 {
281 width=modes[i]->w;
282 height=modes[i]->h;
283
284
285 cerr << "Trying resolution:" << width << "x" << height << ": " << depth << " video mode:\n ";
286 mSurface = SDL_SetVideoMode(width,height,depth,vflags);
287 if(mSurface)
288 {
289 cerr << "Using resolution:" << width << "x" << height << ": " << depth << " video mode:\n ";
290
291 success = true;
292 break;
293 }else{
294 cerr << "..........Resolution failed\n";
295 }
296 }
297
298 cerr<< "Resolution may not be optimal. Alternate resolutions available on system include:\n";
299
300 modes =SDL_ListModes(NULL,vflags);
301 for(int ii=0; modes[ii]; ++ii)
302 {
303 cerr << ii<< ". gVideoWidth <-"<< modes[ii]->w<<"; gVideoHeight<- " << modes[ii]->h <<"\n";
304 }
305}
306
307
308
309
310 if(success)
311 {
312 //something worked out!
313 myEval->gGlobalVariableMap.AddVariable("gVideoWidth", width);
314 myEval->gGlobalVariableMap.AddVariable("gVideoHeight", height);
315 myEval->gGlobalVariableMap.AddVariable("gVideoDepth", depth);
316 }else{
317
318 //None of the resolutions worked out.
319 return false;
320 }
321
322
323 }else{
324 success = true;
325 }
326#endif
327 if(success)
328 {
329 cerr << "\n\n--------------------------------------------------------------------------------\n";
330 cerr << " Application settings:" << endl;
331
332 cerr << "Script name: [" << sname << "]\n";
333 cerr << PEBLEnvironment::TimeStamp(Variant(0)) << endl;
334 cerr << "--------------------------------------------------------------------------------\n";
335
336 cerr << "Display Mode: Width (pixels) [" << width << "]\n";
337 cerr << "Display Mode: Height (pixels) [" << height << "]\n";
338 cerr << "Display Mode: Color Depth (bits) [" << depth << "]\n";
339 cerr << "vsync mode: [" << vsync << "]\n";
340 cerr << "Software renderer mode: [" <<softrender << "]\n";
341 cerr << "Windowed: ["<<windowed<< "]\n";
342 cerr << "Resizeable: ["<<resizeable<< "]\n";
343
344 cerr << "Driver hint (gDriverHint): ";
345
346 if(myEval->gGlobalVariableMap.Exists("gDriverHint"))
347 {
348
349 cerr << "["<<myEval->gGlobalVariableMap.RetrieveValue("gDriverHint") << "]\n";
350 }
351 else
352 {
353 cerr << "[none]\n";
354 }
355
356
357
358 cerr << "Base font (gPEBLBaseFont): ["<<
359 myEval->gGlobalVariableMap.RetrieveValue("gPEBLBaseFont") << "]\n";
360
361 cerr << "Base Mono font (gPEBLBaseFontMono): ["<<
362 myEval->gGlobalVariableMap.RetrieveValue("gPEBLBaseFontMono") << "]\n";
363
364 cerr << "Base serif (gPEBLBaseFontSerif): ["<<
365 myEval->gGlobalVariableMap.RetrieveValue("gPEBLBaseFontSerif") << "]\n";
366
367 cerr << "Language (gLanguage): ["<<
368 myEval->gGlobalVariableMap.RetrieveValue("gLanguage") << "]\n";
369
370 cerr << "Parameter file (gParamFile): ["<<
371 myEval->gGlobalVariableMap.RetrieveValue("gParamFile") << "]\n";
372
373 cerr << "Busy/Easy wait: (gSleepEasy): ["<<
374 myEval->gGlobalVariableMap.RetrieveValue("gSleepEasy") << "]\n";
375
376
377 cerr << "Executable name: (gExecutableName): ["<<
378 myEval->gGlobalVariableMap.RetrieveValue("gExecutableName") << "]\n";
379
380
381 cerr << "Resource path: (gPEBLResourcePath): [" <<
382 myEval->gGlobalVariableMap.RetrieveValue("gPEBLResourcePath") << "]\n";
383
384
385 cerr << "Resource path: (gPEBLBasePath): [" <<
386 myEval->gGlobalVariableMap.RetrieveValue("gPEBLBasePath") << "]\n";
387
388 cerr << "Working directory: (gWorkingDirectory): [" <<
389 myEval->gGlobalVariableMap.RetrieveValue("gWorkingDirectory") << "]\n";
390
391
392
393 SDL_RendererInfo drinfo;
394 cerr << "Renderer information:\n";
395 SDL_GetRendererInfo(mRenderer, &drinfo);
396 cerr << "Driver name: [" << drinfo.name << "]\n";;
397
398 std::cerr << "Software fallback: [";
399
400 if (drinfo.flags & SDL_RENDERER_SOFTWARE)
401 std::cerr << "yes]\n"; else std::cerr << "no]\n";
402
403 std::cerr << "Hardware acceleration: [";
404
405 if (drinfo.flags & SDL_RENDERER_ACCELERATED)
406 std::cerr << "yes]\n"; else std::cerr << "no]\n";
407
408 std::cerr << "Vsync with refresh rate: [";
409 if (drinfo.flags & SDL_RENDERER_PRESENTVSYNC)
410 std::cerr << "yes]\n"; else std::cerr << "no]\n";
411
412 std::cerr << "Rendering to texture support [";
413
414 if (drinfo.flags & SDL_RENDERER_TARGETTEXTURE)
415 std::cerr << "yes]\n"; else std::cerr << "no]\n";
416
417 cerr << "--------------------------------------------------------------------------------\n\n";
418
419 //Do an initial Draw()
420 Draw();
421 return true;
422 }
423 return false;
424}
Evaluator * myEval
Definition PEBL.cpp:188
This class has got everything you need to evaluate stuff.
static VariableMap gGlobalVariableMap
virtual bool SetProperty(std::string, Variant v)
Definition PWidget.cpp:142
bool Exists(const std::string &varname)
void AddVariable(const std::string &varname, const Variant &val)
Variant RetrieveValue(const std::string &varname)
std::string GetString() const
Definition Variant.cpp:1056
Variant TimeStamp(Variant v)
Variant GetDriverList(bool printout=true)

References VariableMap::AddVariable(), Draw(), VariableMap::Exists(), SDLUtility::GetDriverList(), Variant::GetString(), Evaluator::gGlobalVariableMap, PlatformWidget::mRenderer, PlatformWidget::mSurface, myEval, NULL, VariableMap::RetrieveValue(), PWidget::SetProperty(), PError::SignalFatalError(), and PEBLEnvironment::TimeStamp().

Referenced by main(), and PEBLObjects::MakeWindow().

◆ ObjectName() [1/2]

virtual std::string PlatformWindow::ObjectName ( ) const
inlineprotectedvirtual

Reimplemented from PWindow.

Definition at line 78 of file sdl/PlatformWindow.h.

78{return "PlatformWindow";};

◆ ObjectName() [2/2]

virtual std::string PlatformWindow::ObjectName ( ) const
inlinevirtual

Reimplemented from PWindow.

Definition at line 41 of file validator/PlatformWindow.h.

41{ return "PlatformWindow (validator)"; }

◆ Resize() [1/2]

bool PlatformWindow::Resize ( int  w,
int  h 
)

Definition at line 555 of file sdl/PlatformWindow.cpp.

556{
557 //Resize the screen
558
559 // screen = SDL_SetVideoMode( event.resize.w, event.resize.h, SCREEN_BPP, SDL_SWSURFACE | SDL_RESIZABLE );
560 Variant vDp = myEval->gGlobalVariableMap.RetrieveValue("gVideoDepth");
561
562//rework this for SDL2:
563#ifdef SDL2_DELETE
564 mSurface = SDL_SetVideoMode(w,h,(int)vDp,mFlags);
565
566 if(mSurface)
567 {
568 myEval->gGlobalVariableMap.AddVariable("gVideoWidth", w);
569 myEval->gGlobalVariableMap.AddVariable("gVideoHeight", h);
570 }
571
572#endif
573 return true;
574}

References VariableMap::AddVariable(), Evaluator::gGlobalVariableMap, PlatformWidget::mSurface, myEval, and VariableMap::RetrieveValue().

Referenced by PEBLObjects::ResizeWindow().

◆ Resize() [2/2]

virtual bool PlatformWindow::Resize ( int  w,
int  h 
)
inlinevirtual

Definition at line 44 of file validator/PlatformWindow.h.

44{ return true; }

◆ SaveScreenShot() [1/2]

int PlatformWindow::SaveScreenShot ( int  x,
int  y,
int  w,
int  h,
const Variant  fname 
)

Definition at line 578 of file sdl/PlatformWindow.cpp.

579{
580
581 SDL_Rect rect;
582 rect.x = x;
583 rect.y = y;
584 rect.w = w;
585 rect.h = h;
586
587 return SDLUtility::WritePNG(mRenderer,&rect,fname);
588
589
590}
int WritePNG(SDL_Renderer *renderer, SDL_Rect *rect, const std::string fname)

References PlatformWidget::mRenderer, and SDLUtility::WritePNG().

Referenced by PEBLStream::WritePNG().

◆ SaveScreenShot() [2/2]

virtual int PlatformWindow::SaveScreenShot ( int  x,
int  y,
int  w,
int  h,
const Variant  fname 
)
inlinevirtual

Definition at line 42 of file validator/PlatformWindow.h.

42{ return 0; }

◆ SendToStream() [1/2]

std::ostream & PlatformWindow::SendToStream ( std::ostream &  out) const
protectedvirtual

An inheritable printing class used by PEBLObjectBase::operator<<.

Reimplemented from PWindow.

Definition at line 45 of file validator/PlatformWindow.cpp.

45 {
46 out << "PlatformWindow (validator)";
47 return out;
48}

◆ SendToStream() [2/2]

virtual std::ostream & PlatformWindow::SendToStream ( std::ostream &  out) const
protectedvirtual

An inheritable printing class used by PEBLObjectBase::operator<<.

Reimplemented from PWindow.

◆ SetBackgroundColor()

virtual void PlatformWindow::SetBackgroundColor ( const PColor color)
inlinevirtual

Reimplemented from PWidget.

Definition at line 64 of file validator/PlatformWindow.h.

References PWidget::SetBackgroundColor().

Referenced by main(), and PEBLObjects::MakeWindow().

◆ SetPosition()

virtual void PlatformWindow::SetPosition ( pInt  x,
pInt  y 
)
inlinevirtual

This sets the widget's position on its parent widget.

Sets the location of the upper left-hand corner of the image on the parent widget; unless overridden

Reimplemented from PWidget.

Definition at line 63 of file validator/PlatformWindow.h.

63{ PWindow::SetPosition(x, y); }
virtual void SetPosition(pInt x, pInt y)
This sets the widget's position on its parent widget.
Definition PWidget.cpp:220

References PWidget::SetPosition().

◆ SetProperty()

virtual bool PlatformWindow::SetProperty ( std::string  name,
Variant  v 
)
inlinevirtual

Reimplemented from PWindow.

Definition at line 48 of file validator/PlatformWindow.h.

48 {
49 return PWindow::SetProperty(name, v);
50 }
virtual bool SetProperty(std::string, Variant v)
Definition PWindow.cpp:56

References PWindow::SetProperty().

◆ ValidateProperty() [1/2]

virtual ObjectValidationError PlatformWindow::ValidateProperty ( std::string  name) const
inlinevirtual

Reimplemented from PWindow.

Definition at line 54 of file validator/PlatformWindow.h.

54 {
55 return PWindow::ValidateProperty(name);
56 }
virtual ObjectValidationError ValidateProperty(std::string, Variant v) const
Definition PWindow.cpp:77

References PWindow::ValidateProperty().

◆ ValidateProperty() [2/2]

virtual ObjectValidationError PlatformWindow::ValidateProperty ( std::string  name,
Variant  v 
) const
inlinevirtual

Reimplemented from PWindow.

Definition at line 51 of file validator/PlatformWindow.h.

51 {
52 return PWindow::ValidateProperty(name, v);
53 }

References PWindow::ValidateProperty().


The documentation for this class was generated from the following files: