Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Rubberduckycooly
GitHub Repository: Rubberduckycooly/RSDKv5-Decompilation
Path: blob/master/RSDKv5/RSDK/Graphics/SDL2/SDL2RenderDevice.hpp
1168 views
1
using ShaderEntry = ShaderEntryBase;
2
3
class RenderDevice : public RenderDeviceBase
4
{
5
public:
6
struct WindowInfo {
7
union {
8
struct {
9
// i wanna do uint32 : 32 but idk if other compilers like that
10
uint32 _pad;
11
int32 width;
12
int32 height;
13
int32 refresh_rate;
14
};
15
SDL_DisplayMode internal;
16
} * displays;
17
SDL_Rect viewport;
18
};
19
static WindowInfo displayInfo;
20
21
static bool Init();
22
static void CopyFrameBuffer();
23
static void FlipScreen();
24
static void Release(bool32 isRefresh);
25
26
static void RefreshWindow();
27
static void GetWindowSize(int32 *width, int32 *height);
28
29
static void SetupImageTexture(int32 width, int32 height, uint8 *imagePixels);
30
static void SetupVideoTexture_YUV420(int32 width, int32 height, uint8 *yPlane, uint8 *uPlane, uint8 *vPlane, int32 strideY, int32 strideU,
31
int32 strideV);
32
static void SetupVideoTexture_YUV422(int32 width, int32 height, uint8 *yPlane, uint8 *uPlane, uint8 *vPlane, int32 strideY, int32 strideU,
33
int32 strideV);
34
static void SetupVideoTexture_YUV444(int32 width, int32 height, uint8 *yPlane, uint8 *uPlane, uint8 *vPlane, int32 strideY, int32 strideU,
35
int32 strideV);
36
37
static bool ProcessEvents();
38
39
static void InitFPSCap();
40
static bool CheckFPSCap();
41
static void UpdateFPSCap();
42
43
static bool InitShaders();
44
static void LoadShader(const char *fileName, bool32 linear);
45
46
static inline void ShowCursor(bool32 shown) { SDL_ShowCursor(shown); }
47
static inline bool GetCursorPos(Vector2 *pos)
48
{
49
SDL_GetMouseState(&pos->x, &pos->y);
50
return true;
51
};
52
53
static inline void SetWindowTitle() { SDL_SetWindowTitle(window, gameVerInfo.gameTitle); };
54
55
static SDL_Window *window;
56
static SDL_Renderer *renderer;
57
static SDL_Texture *screenTexture[SCREEN_COUNT];
58
59
static SDL_Texture *imageTexture;
60
61
private:
62
static bool SetupRendering();
63
static void InitVertexBuffer();
64
static bool InitGraphicsAPI();
65
66
static void GetDisplays();
67
68
static void ProcessEvent(SDL_Event event);
69
70
static uint32 displayModeIndex;
71
static int32 displayModeCount;
72
73
static unsigned long long targetFreq;
74
static unsigned long long curTicks;
75
static unsigned long long prevTicks;
76
77
static RenderVertex vertexBuffer[!RETRO_REV02 ? 24 : 60];
78
79
// thingo majigo for handling video/image swapping
80
static uint8 lastTextureFormat;
81
};
82
83