This repository has been archived by the owner on Oct 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
RenderTarget.h
67 lines (57 loc) · 2.06 KB
/
RenderTarget.h
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
#pragma once
#include "typedefs3D.h"
class RenderDevice;
class RenderTarget final
{
public:
RenderTarget(RenderDevice* rd, int width = -1, int height = -1); // Default output render target
RenderTarget(RenderDevice* rd, const int width, const int height, const colorFormat format, bool with_depth, int nMSAASamples, StereoMode stereo, const char* failureMessage, RenderTarget* sharedDepth = nullptr);
~RenderTarget();
void Activate(const bool ignoreStereo = false);
static RenderTarget* GetCurrentRenderTarget();
Sampler* GetColorSampler() { return m_color_sampler; }
void UpdateDepthSampler();
Sampler* GetDepthSampler() { return m_depth_sampler; }
RenderTarget* Duplicate(const bool shareDepthSurface = false);
void CopyTo(RenderTarget* dest, const bool copyColor = true, const bool copyDepth = true);
void SetSize(const int w, const int h) { assert(m_is_back_buffer); m_width = w; m_height = h; }
int GetWidth() const { return m_width; }
int GetHeight() const { return m_height; }
StereoMode GetStereo() const { return m_stereo; }
bool IsMSAA() const { return m_nMSAASamples > 1; }
bool HasDepth() const { return m_has_depth; }
colorFormat GetColorFormat() const { return m_format; }
#ifdef _DEBUG
void SaveToPng(string filename);
#endif
#ifdef ENABLE_SDL
GLuint GetCoreFrameBuffer() const { return m_framebuffer; }
#else
IDirect3DSurface9* GetCoreColorSurface() { return m_color_surface; }
#endif
private:
int m_width;
int m_height;
colorFormat m_format;
StereoMode m_stereo;
RenderDevice* m_rd;
Sampler* m_color_sampler;
Sampler* m_depth_sampler;
bool m_is_back_buffer;
bool m_has_depth;
bool m_shared_depth;
int m_nMSAASamples;
static RenderTarget* current_render_target;
#ifdef ENABLE_SDL
static int m_current_stereo_mode;
GLuint m_framebuffer;
GLuint m_color_tex;
GLuint m_depth_tex;
#else
bool m_use_alternate_depth;
IDirect3DSurface9* m_color_surface;
IDirect3DTexture9* m_color_tex;
IDirect3DSurface9* m_depth_surface;
IDirect3DTexture9* m_depth_tex;
#endif
};