summaryrefslogtreecommitdiff
path: root/Widgets/FrameBuffer.h
blob: 03da7eab91bf40d9a958f230b1086f11023b83c9 (plain)
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
#pragma once

#include "AbstractScreen.h"
#include "Color.h"

#ifdef USE_SDL
#include <SDL.h>
#endif

class GraphicsBitmap;

class FrameBuffer final : public AbstractScreen {
public:
    FrameBuffer(unsigned width, unsigned height);
    virtual ~FrameBuffer() override;

    void show();

#ifdef USE_SDL
    SDL_Surface* surface() { return m_surface; }
#endif

    static FrameBuffer& the();

    RGBA32* scanline(int y);

    void blit(const Point&, GraphicsBitmap&);
    void flush();

private:
#ifdef USE_SDL
    void initializeSDL();
    SDL_Window* m_window { nullptr };
    SDL_Surface* m_surface { nullptr };
#endif
};