Debian Codegraph @

src/gui/render/renderGL.h

raw
1 /**
2 * Furnace Tracker - multi-system chiptune tracker
3 * Copyright (C) 2021-2025 tildearrow and contributors
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #include "../gui.h"
21
22 class FurnaceGUIRenderGL: public FurnaceGUIRender {
23 SDL_GLContext context;
24 SDL_Window* sdlWin;
25 float quadVertex[4][3];
26 unsigned int quadBuf;
27 float oscVertex[4][4];
28 unsigned int oscVertexBuf;
29 unsigned int oscDataTex;
30 float oscData[2048];
31
32 // SHADERS //
33 // -> wipe
34 int sh_wipe_vertex;
35 int sh_wipe_fragment;
36 int sh_wipe_program;
37 int sh_wipe_uAlpha;
38 bool sh_wipe_have;
39 // -> oscRender
40 int sh_oscRender_vertex;
41 int sh_oscRender_fragment;
42 int sh_oscRender_program;
43 int sh_oscRender_uColor;
44 int sh_oscRender_uLineWidth;
45 int sh_oscRender_uResolution;
46 int sh_oscRender_oscVal;
47 bool sh_oscRender_have;
48
49 bool swapIntervalSet;
50 unsigned char glVer;
51
52 int maxWidth, maxHeight;
53 String backendName, vendorName, deviceName, apiVersion;
54
55 bool createShader(const char* vertexS, const char* fragmentS, int& vertex, int& fragment, int& program, const char** attribNames);
56
57 public:
58 ImTextureID getTextureID(FurnaceGUITexture* which);
59 FurnaceGUITextureFormat getTextureFormat(FurnaceGUITexture* which);
60 bool lockTexture(FurnaceGUITexture* which, void** data, int* pitch);
61 bool unlockTexture(FurnaceGUITexture* which);
62 bool updateTexture(FurnaceGUITexture* which, void* data, int pitch);
63 FurnaceGUITexture* createTexture(bool dynamic, int width, int height, bool interpolate=true, FurnaceGUITextureFormat format=GUI_TEXFORMAT_ABGR32);
64 bool destroyTexture(FurnaceGUITexture* which);
65 void setTextureBlendMode(FurnaceGUITexture* which, FurnaceGUIBlendMode mode);
66 void setBlendMode(FurnaceGUIBlendMode mode);
67 void clear(ImVec4 color);
68 void newFrame();
69 bool canVSync();
70 void renderGUI();
71 void wipe(float alpha);
72 void drawOsc(float* data, size_t len, ImVec2 pos0, ImVec2 pos1, ImVec4 color, ImVec2 canvasSize, float lineWidth);
73 void present();
74 bool getOutputSize(int& w, int& h);
75 bool supportsDrawOsc();
76 int getWindowFlags();
77 int getMaxTextureWidth();
78 int getMaxTextureHeight();
79 unsigned int getTextureFormats();
80 const char* getBackendName();
81 const char* getVendorName();
82 const char* getDeviceName();
83 const char* getAPIVersion();
84 void setSwapInterval(int swapInterval);
85 void preInit(const DivConfig& conf);
86 bool init(SDL_Window* win, int swapInterval);
87 void initGUI(SDL_Window* win);
88 void quitGUI();
89 bool quit();
90 bool isDead();
91 void setVersion(unsigned char ver);
92 FurnaceGUIRenderGL():
93 context(NULL),
94 sdlWin(NULL),
95 swapIntervalSet(true),
96 glVer(3),
97 maxWidth(0),
98 maxHeight(0),
99 backendName("What?") {
100 memset(quadVertex,0,4*3*sizeof(float));
101 memset(oscVertex,0,4*5*sizeof(float));
102 memset(oscData,0,2048*sizeof(float));
103 }
104 };