| e8555c89 Andy McCall |
1 |
#ifndef OUTPUTSURFACE_HH |
| 2 |
#define OUTPUTSURFACE_HH |
| 3 |
|
| 4 |
#include "PixelOperations.hh" |
| 5 |
#include "gl_vec.hh" |
| 6 |
|
| 7 |
#include <cassert> |
| 8 |
#include <cstdint> |
| 9 |
#include <string> |
| 10 |
|
| 11 |
namespace openmsx { |
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
class OutputSurface |
| 21 |
{ |
| 22 |
public: |
| 23 |
using Pixel = uint32_t; |
| 24 |
|
| 25 |
OutputSurface(const OutputSurface&) = delete; |
| 26 |
OutputSurface(OutputSurface&&) = delete; |
| 27 |
OutputSurface& operator=(const OutputSurface&) = delete; |
| 28 |
OutputSurface& operator=(OutputSurface&&) = delete; |
| 29 |
virtual ~OutputSurface() = default; |
| 30 |
|
| 31 |
[[nodiscard]] int getLogicalWidth() const { return m_logicalSize.x; } |
| 32 |
[[nodiscard]] int getLogicalHeight() const { return m_logicalSize.y; } |
| 33 |
[[nodiscard]] gl::ivec2 getLogicalSize() const { return m_logicalSize; } |
| 34 |
[[nodiscard]] gl::ivec2 getPhysicalSize() const { return m_physSize; } |
| 35 |
|
| 36 |
[[nodiscard]] gl::ivec2 getViewOffset() const { return m_viewOffset; } |
| 37 |
[[nodiscard]] gl::ivec2 getViewSize() const { return m_viewSize; } |
| 38 |
[[nodiscard]] gl::vec2 getViewScale() const { return m_viewScale; } |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
[[nodiscard]] uint32_t mapRGB(gl::vec3 rgb) const |
| 45 |
{ |
| 46 |
return mapRGB255(gl::ivec3(rgb * 255.0f)); |
| 47 |
} |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
[[nodiscard]] uint32_t mapRGB255(gl::ivec3 rgb) const |
| 52 |
{ |
| 53 |
auto [r, g, b] = rgb; |
| 54 |
PixelOperations pixelOps; |
| 55 |
return pixelOps.combine(r, g, b); |
| 56 |
} |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
[[nodiscard]] Pixel getKeyColor() const |
| 61 |
{ |
| 62 |
return 0x00000000; |
| 63 |
} |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
virtual void saveScreenshot(const std::string& filename) = 0; |
| 69 |
|
| 70 |
protected: |
| 71 |
OutputSurface() = default; |
| 72 |
|
| 73 |
|
| 74 |
void calculateViewPort(gl::ivec2 logSize, gl::ivec2 physSize); |
| 75 |
|
| 76 |
private: |
| 77 |
gl::ivec2 m_logicalSize; |
| 78 |
gl::ivec2 m_physSize; |
| 79 |
gl::ivec2 m_viewOffset; |
| 80 |
gl::ivec2 m_viewSize; |
| 81 |
gl::vec2 m_viewScale{1.0f}; |
| 82 |
}; |
| 83 |
|
| 84 |
} |
| 85 |
|
| 86 |
#endif |