3 * (c) 2016 K.Ohta <whatisthis.sowhat@gmail.com>
5 * Renderer with OpenGL v4.5 (extend from renderer with OpenGL v2.0).
7 * Jan 22, 2016 : Initial.
10 #ifndef _QT_COMMON_GLUTIL_4_5_H
11 #define _QT_COMMON_GLUTIL_4_5_H
14 #include "../gl/qt_glutil_gl_tmpl.h"
19 class QOpenGLFunctions_4_5_Core;
21 class QOpenGLVertexArrayObject;
22 class QOpenGLShaderProgram;
23 class QOpenGLPixelTransferOptions;
26 class DLL_PREFIX GLDraw_4_5 : public GLDraw_Tmpl
30 QOpenGLFunctions_4_5_Core *extfunc;
33 const float luma_filter[24 + 1] = {
60 const float chroma_filter[24 + 1] = {
87 const float rot0[4] = {1, -0, 0, 1};
88 const float rot90[4] = {0, 1, -1, 0};
89 const float rot180[4] = {-1, 0, 0, -1};
90 const float rot270[4] = {0, -1, 1, 0};
97 GLuint main_texture_buffer;
98 GLuint main_read_texture_buffer;
101 scrntype_t *map_base_address;
103 GLScreenPack *main_pass;
104 GLScreenPack *std_pass;
105 GLScreenPack *ntsc_pass1;
106 GLScreenPack *ntsc_pass2;
107 GLScreenPack *bitmap_block;
108 GLScreenPack *led_pass;
109 GLScreenPack *osd_pass;
110 QOpenGLBuffer *led_pass_vbuffer[32];
111 QOpenGLVertexArrayObject *led_pass_vao[32];
112 QOpenGLBuffer *osd_pass_vbuffer[32];
113 QOpenGLVertexArrayObject *osd_pass_vao[32];
115 VertexTexCoord_t vertexTmpTexture[4];
117 QOpenGLShaderProgram *grids_shader;
118 QOpenGLBuffer *grids_horizonal_buffer;
119 QOpenGLVertexArrayObject *grids_horizonal_vertex;
120 QOpenGLBuffer *grids_vertical_buffer;
121 QOpenGLVertexArrayObject *grids_vertical_vertex;
123 GLuint uTmpTextureID;
125 bool main_texture_ready;
127 virtual void setNormalVAO(QOpenGLShaderProgram *prg, QOpenGLVertexArrayObject *vp,
128 QOpenGLBuffer *bp, VertexTexCoord_t *tp, int size = 4);
129 virtual bool initGridShaders(const QString vertex_fixed, const QString vertex_rotate, const QString fragment);
130 virtual bool initGridVertexObject(QOpenGLBuffer **vbo, QOpenGLVertexArrayObject **vao, int alloc_size);
131 virtual void set_texture_vertex(float wmul = 1.0f, float hmul = 1.0f);
132 virtual void updateGridsVAO(QOpenGLBuffer *bp,
133 QOpenGLVertexArrayObject *vp,
137 virtual void drawGridsMain(QOpenGLShaderProgram *prg,
139 QOpenGLVertexArrayObject *vp,
141 GLfloat lineWidth = 0.2f,
142 QVector4D color = QVector4D(0.0, 0.0, 0.0, 1.0));
143 virtual void resizeGL_Screen(void);
144 virtual void initPackedGLObject(GLScreenPack **p,
145 int _width, int _height,
146 const QString vertex_shader, const QString fragment_shader,
148 bool req_float = false, bool req_highp = false,
149 bool req_alpha_channel = true);
151 virtual void drawGridsHorizonal(void);
152 virtual void drawGridsVertical(void);
153 virtual void drawGrids();
155 virtual void drawMain(QOpenGLShaderProgram *prg,
156 QOpenGLVertexArrayObject *vp,
161 bool do_chromakey = false,
162 QVector3D chromakey = QVector3D(0.0f, 0.0f, 0.0f));
163 virtual void drawMain(GLScreenPack *obj,
165 QVector4D color, bool f_smoosing,
166 bool do_chromakey = false,
167 QVector3D chromakey = QVector3D(0.0f, 0.0f, 0.0f));
168 virtual void renderToTmpFrameBuffer_nPass(GLuint src_texture,
171 GLScreenPack *renderObject,
174 bool use_chromakey = false);
175 virtual void drawBitmapTexture(void);
176 virtual void drawButtonsMain(int num, bool f_smoosing);
177 virtual void drawOsdLeds();
178 virtual void drawOsdIcons();
179 virtual void drawLedMain(GLScreenPack *obj, int num, QVector4D color);
180 virtual void set_led_vertex(int bit);
181 virtual void set_osd_vertex(int bit);
182 virtual void initBitmapVertex(void);
183 virtual QOpenGLTexture *createMainTexture(QImage *img);
184 void updateButtonTexture(void);
187 GLDraw_4_5(GLDrawClass *parent, USING_FLAGS *p, CSP_Logger *logger, EMU_TEMPLATE *emu = 0);
189 void drawButtons(void);
190 virtual void initGLObjects();
191 virtual void initLocalGLObjects(void);
192 virtual void initFBO(void);
193 void initButtons(void);
194 //virtual void initBitmapVertex(void);
196 virtual void uploadMainTexture(QImage *p, bool chromakey, bool was_mapped);
197 virtual void drawScreenTexture(void);
198 virtual void do_set_screen_multiply(float mul);
199 virtual void doSetGridsHorizonal(int lines, bool force);
200 virtual void doSetGridsVertical(int pixels, bool force);
201 void uploadBitmapTexture(QImage *p);
203 // Note: Mapping vram from draw_thread does'nt work well.
204 // This feature might be disable. 20180728 K.Ohta.
205 void get_screen_geometry(int *w, int *h);
206 bool copy_screen_buffer(scrntype_t* target,int w, int h, int stride);
208 scrntype_t *get_screen_buffer(int y);
209 bool is_ready_to_map_vram_texture(void);
210 bool map_vram_texture(void);
211 bool unmap_vram_texture(void);
212 virtual bool is_mapped_buffer(void) {
213 if(main_texture_buffer == 0) {
218 // ToDo: Double buffer
219 virtual GLuint get_mapped_buffer_num(int region) {
220 return (GLuint)main_texture_buffer;
224 void updateBitmap(QImage *);
225 void uploadIconTexture(QPixmap *p, int icon_type, int localnum);
226 void setBrightness(GLfloat r, GLfloat g, GLfloat b);
227 void do_set_texture_size(QImage *p, int w, int h);
228 void do_set_horiz_lines(int lines);
229 virtual void paintGL(void);
230 virtual void resizeGL(int width, int height);
231 void do_set_display_osd(bool onoff);
232 void do_display_osd_leds(int lednum, bool onoff);