hx3d  1
2D/3D Simple Game Framework
display.cpp
1 /*
2  Audio effect display.
3  Copyright (C) 2015 Denis BOURGE
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
18  USA
19 */
20 
21 #include "hx3d/audio/display.hpp"
22 
23 namespace hx3d {
24 namespace audio {
25 
26 using ::hx3d::graphics::Color;
27 
29 Display::Display(const int refreshDelay): _refreshDelay(refreshDelay), _initialized(false) {}
30 Display::~Display() {}
31 
32 void Display::initialize(const unsigned int width, const unsigned int height) {
33  _image.create(width, height);
36 
37  Sprite::setTexture(_image.getTexture());
38 
40 
41  _initialized = true;
42 }
43 
44 void Display::setRefreshDelay(const int refreshDelay) {
45  _refreshDelay = refreshDelay;
47 }
48 
50 
52  _image.setRect(0, 0, _image.getWidth(), 1, Color::White);
53  _image.setRect(0, 0, 1, _image.getHeight(), Color::White);
54  _image.setRect(_image.getWidth() - 1, 0, 1, _image.getHeight(), Color::White);
55  _image.setRect(0, _image.getHeight() - 1, _image.getWidth(), 1, Color::White);
56 }
57 
58 } /* audio */
59 } /* hx3d */
void drawBorders()
Draw white borders.
Definition: display.cpp:51
void setRefreshDelay(const int refreshDelay)
Set the refresh delay.
Definition: display.cpp:44
void setRect(unsigned int x, unsigned int y, unsigned int w, unsigned int h, Color color)
Set a rectangle with a color.
Definition: image.cpp:52
void initialize(long delay, bool loop=false)
Initialize the timer with a delay.
Definition: timer.cpp:34
Audio effect display.
Definition: display.hpp:41
unsigned int getHeight()
Get the image height.
Definition: image.cpp:112
void buildTexture()
Recreate a texture from the image.
Definition: image.cpp:81
hx3d framework namespace
Definition: audio.hpp:26
Timer _timer
Refresh timer.
Definition: display.hpp:99
void initialize(const unsigned int width, const unsigned int height)
Initialize the display.
Definition: display.cpp:32
Display()
Create an empty display with a refresh delay of 50.
Definition: display.cpp:28
unsigned int getWidth()
Get the image width.
Definition: image.cpp:108
int _refreshDelay
Refresh delay.
Definition: display.hpp:101
Ptr< Texture > getTexture()
Get the texture.
Definition: image.cpp:74
graphics::Image _image
Drawing image.
Definition: display.hpp:97
void create(unsigned int width, unsigned int height)
Initialize an image.
Definition: image.cpp:37
bool _initialized
Is the display initialized ?
Definition: display.hpp:103
virtual void onInitialization()
Use this to execute code after initialization.
Definition: display.cpp:49