-
Notifications
You must be signed in to change notification settings - Fork 0
/
Screen.hpp
81 lines (67 loc) · 1.76 KB
/
Screen.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
* Particle simulation program using the SDL library
* Based on examples by John Purcell's (from Cave of Programming)
*
* @author J. Alvarez
*/
#include "SDL2/SDL.h"
#ifndef SCREEN_HPP
#define SCREEN_HPP
typedef const unsigned int cint;
namespace ParticleSimulation {
/**
* This class represents the graphic interface where the particles are shown
*/
class Screen {
public:
const static unsigned int S_WIDTH = 800;
const static unsigned int S_HEIGHT = 600;
private:
SDL_Window * m_window;
SDL_Renderer * m_renderer;
SDL_Texture * m_texture;
Uint32 * m_mainBuffer;
Uint32 * m_backBuffer;
public:
/**
* Creates a Screen instance and initializes it fields
*/
Screen();
/**
* Initializes window, renderer, texture, and buffer
* @return boolean indicating success of the initialization process
*/
bool init();
/**
* Unstacks events from the event pool and processes them
* @return boolean indicating whether the program should continue or not
*/
bool processEvents();
/**
* Updates the Screen's elements according to the information in the buffer
*/
void update();
/**
* Applies a box blur to the previous state of the Screen
*/
void boxBlur();
/**
* Sets a pixel in the buffer with the specified (x,y) position, and colors
* @param x The x position
* @param y The y position
* @param red The value of the red color component
* @param green The value of the green color component
* @param blue The value of the blue color component
*/
void setPixel(int x, int y, Uint8 red, Uint8 green, Uint8 blue);
/**
* Clears the Screen's main buffer (set it to all zeros)
*/
void clear();
/**
* Closes the Screen and cleans memory from all its elements
*/
void close();
};
} // namespace ParticleSimulation
#endif // SCREEN_HPP