OpenXcom  1.0
Open-source clone of the original X-Com
Screen.h
1  #pragma once
2 /*
3  * Copyright 2010-2016 OpenXcom Developers.
4  *
5  * This file is part of OpenXcom.
6  *
7  * OpenXcom is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * OpenXcom is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with OpenXcom. If not, see <http://www.gnu.org/licenses/>.
19  */
20 #include <SDL.h>
21 #include <string>
22 #include "OpenGL.h"
23 
24 namespace OpenXcom
25 {
26 
27 class Surface;
28 class Action;
29 
38 class Screen
39 {
40 private:
41  SDL_Surface *_screen;
42  int _bpp;
43  int _baseWidth, _baseHeight;
44  double _scaleX, _scaleY;
45  int _topBlackBand, _bottomBlackBand, _leftBlackBand, _rightBlackBand, _cursorTopBlackBand, _cursorLeftBlackBand;
46  Uint32 _flags;
47  SDL_Color deferredPalette[256];
48  int _numColors, _firstColor;
49  bool _pushPalette;
50  OpenGL glOutput;
51  Surface *_surface;
52  SDL_Rect _clear;
54  void makeVideoFlags();
55 public:
56  static const int ORIGINAL_WIDTH;
57  static const int ORIGINAL_HEIGHT;
58 
60  Screen();
62  ~Screen();
64  int getDX() const;
66  int getDY() const;
70  void handle(Action *action);
72  void flip();
74  void clear();
76  void setPalette(SDL_Color *colors, int firstcolor = 0, int ncolors = 256, bool immediately = false);
78  SDL_Color *getPalette() const;
80  int getWidth() const;
82  int getHeight() const;
84  void resetDisplay(bool resetVideo = true);
86  double getXScale() const;
88  double getYScale() const;
90  int getCursorTopBlackBand() const;
92  int getCursorLeftBlackBand() const;
94  void screenshot(const std::string &filename) const;
96  static bool use32bitScaler();
98  static bool useOpenGL();
100  static void updateScale(int type, int &width, int &height, bool change);
101 };
102 
103 }
Container for all the information associated with a given user action, like mouse clicks...
Definition: Action.h:32
void clear()
Clears the screen.
Definition: Screen.cpp:214
Screen()
Creates a new display screen.
Definition: Screen.cpp:107
int getWidth() const
Gets the screen&#39;s width.
Definition: Screen.cpp:283
int getHeight() const
Gets the screen&#39;s height.
Definition: Screen.cpp:292
int getCursorTopBlackBand() const
Gets the screen&#39;s top black forbidden to cursor band&#39;s height.
Definition: Screen.cpp:492
int getCursorLeftBlackBand() const
Gets the screen&#39;s left black forbidden to cursor band&#39;s width.
Definition: Screen.cpp:501
~Screen()
Cleans up the display screen.
Definition: Screen.cpp:117
int getDY() const
Get vertical offset.
Definition: Screen.cpp:598
void handle(Action *action)
Handles keyboard events.
Definition: Screen.cpp:137
static bool use32bitScaler()
Checks whether a 32bit scaler is requested and works for the selected resolution. ...
Definition: Screen.cpp:545
int getDX() const
Get horizontal offset.
Definition: Screen.cpp:589
static bool useOpenGL()
Checks whether OpenGL output is requested.
Definition: Screen.cpp:576
double getXScale() const
Gets the screen&#39;s X scale.
Definition: Screen.cpp:474
Element that is blit (rendered) onto the screen.
Definition: Surface.h:38
static void updateScale(int type, int &width, int &height, bool change)
update the game scale as required.
Definition: Screen.cpp:610
Definition: OpenGL.h:39
double getYScale() const
Gets the screen&#39;s Y scale.
Definition: Screen.cpp:483
void setPalette(SDL_Color *colors, int firstcolor=0, int ncolors=256, bool immediately=false)
Sets the screen&#39;s 8bpp palette.
Definition: Screen.cpp:228
Surface * getSurface()
Gets the internal buffer.
Definition: Screen.cpp:127
A display screen, handles rendering onto the game window.
Definition: Screen.h:38
void screenshot(const std::string &filename) const
Takes a screenshot.
Definition: Screen.cpp:510
SDL_Color * getPalette() const
Gets the screen&#39;s 8bpp palette.
Definition: Screen.cpp:274
void flip()
Renders the screen onto the game window.
Definition: Screen.cpp:181
Definition: BaseInfoState.cpp:40
void resetDisplay(bool resetVideo=true)
Resets the screen display.
Definition: Screen.cpp:302