OSDN Git Service

[Ui][Qt][OpenGL] OSD: Make icons transparent.
authorK.Ohta <whatisthis.sowhat@gmail.com>
Wed, 9 Aug 2017 18:12:41 +0000 (03:12 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Wed, 9 Aug 2017 18:12:41 +0000 (03:12 +0900)
[Ui][Qt][OpenGL] OSD: Add support OpenGL 2.0.

source/src/qt/common/emu_thread.cpp
source/src/qt/common/qrc/shaders.qrc
source/src/qt/gui/icon_fragment_shader.glsl [new file with mode: 0644]
source/src/qt/gui/qt_drawitem.cpp
source/src/qt/gui/qt_drawitem.h
source/src/qt/gui/qt_gldraw.h
source/src/qt/gui/qt_glutil.cpp
source/src/qt/gui/qt_glutil_gl2_0.cpp
source/src/qt/gui/qt_glutil_gl2_0.h
source/src/qt/gui/qt_glutil_gl3_0.cpp
source/src/qt/gui/qt_glutil_gl3_0.h

index 54dd4f8..00ed9bd 100644 (file)
@@ -227,7 +227,7 @@ void EmuThreadClass::get_tape_string()
                        tmpstr = QString::fromUtf8("<FONT COLOR=BLUE>   EMPTY   </FONT>");
                }
                if(tmpstr != cmt_text[i]) {
-                       //emit sig_set_access_lamp(i + 12 + ((readwrite) ? 2 : 0), inserted);
+                       emit sig_set_access_lamp(i + 12 + ((readwrite) ? 2 : 0), inserted);
                        emit sig_change_osd(CSP_DockDisks_Domain_CMT, i, tmpstr);
                        cmt_text[i] = tmpstr;
                }
index 74852fa..e7f2358 100644 (file)
@@ -7,6 +7,7 @@
     <file alias="chromakey_fragment_shader2.glsl">../../gui/chromakey_fragment_shader2.glsl</file>
     <file alias="led_fragment_shader.glsl">../../gui/led_fragment_shader.glsl</file>
     <file alias="led_vertex_shader.glsl">../../gui/led_vertex_shader.glsl</file>
+    <file alias="icon_fragment_shader.glsl">../../gui/icon_fragment_shader.glsl</file>
     <file alias="vertex_shader.glsl">../../gui/vertex_shader.glsl</file>
     <file alias="grids_fragment_shader.glsl">../../gui/grids_fragment_shader.glsl</file>
     <file alias="grids_vertex_shader.glsl">../../gui/grids_vertex_shader.glsl</file>
diff --git a/source/src/qt/gui/icon_fragment_shader.glsl b/source/src/qt/gui/icon_fragment_shader.glsl
new file mode 100644 (file)
index 0000000..6874238
--- /dev/null
@@ -0,0 +1,19 @@
+varying vec2 v_texcoord;
+uniform vec4 color;
+uniform vec3 chromakey;
+uniform bool do_chromakey;
+uniform sampler2D a_texture;
+void main ()
+{
+       vec4 pixel_r_1;
+       vec4 pixel;
+       float alpha;
+       pixel_r_1 = texture2D(a_texture, v_texcoord);
+       //alpha = pixel_r_1.a * color.a;
+
+       pixel_r_1 = pixel_r_1 * color;
+       pixel = pixel_r_1 * color; //;vec4(pixel_r_1.rgb, alpha);
+       gl_FragColor = pixel;
+
+}
+
index d35d4f4..6da412b 100644 (file)
@@ -90,7 +90,7 @@ void CSP_DrawItem::drawPolygonItem(QPointF _points[], int members,
 }
 
 
-void CSP_DrawItem::drawFloppy5Inch(QColor &BGColor, QColor &FGColor, QColor &TextColor, float text_pt, QString text)
+void CSP_DrawItem::drawFloppy5Inch(QColor &BGColor, QColor &FGColor, QColor &FGColor2, QColor &TextColor, float text_pt, QString text)
 {
        double __width = (double)_width;
        double __height = (double)_height;
@@ -103,12 +103,12 @@ void CSP_DrawItem::drawFloppy5Inch(QColor &BGColor, QColor &FGColor, QColor &Tex
                int ybase = (int)((__height - _nwidth) * 0.5);
                int wbase = (int)_nwidth;
                int hbase = wbase;
-               drawRectItem(xbase, ybase, wbase, hbase, toned_brush_mid, FGColor, FGColor);
+               drawRectItem(xbase, ybase, wbase, hbase, fill_brush, FGColor, FGColor);
                {
                        int r = (int)((_nwidth * 0.35) / 2.0);
                        int x = xbase + wbase / 2 - r;
                        int y = ybase + hbase / 2 - r;
-                       drawCircleItem(x, y, r, 0, 360 * 16, fill_brush, FGColor, FGColor);
+                       drawCircleItem(x, y, r, 0, 360 * 16, fill_brush, FGColor2, FGColor2);
                }
                {
                        int r = (int)((_nwidth * 0.15) / 2.0);
@@ -121,7 +121,7 @@ void CSP_DrawItem::drawFloppy5Inch(QColor &BGColor, QColor &FGColor, QColor &Tex
                        double h = _nwidth * (1.0 - 0.35 - 0.2) / 2.0;
                        int x = (xbase + wbase / 2) - (int)(w / 2.0); 
                        int y = (ybase + wbase / 2) + (int)(_nwidth * 0.45 / 2.0); 
-                       drawRectItem(x, y, w, h, fill_brush, FGColor, FGColor);
+                       drawRectItem(x, y, w, h, fill_brush, FGColor2, FGColor2);
                }
                if(!text.isEmpty()) {
                        int x = xbase + (int)(_nwidth * 0.65); 
@@ -136,7 +136,7 @@ void CSP_DrawItem::drawFloppy5Inch(QColor &BGColor, QColor &FGColor, QColor &Tex
 }
        
 
-void CSP_DrawItem::drawFloppy3_5Inch(QColor &BGColor, QColor &FGColor, QColor &TextColor, float text_pt, QString text)
+void CSP_DrawItem::drawFloppy3_5Inch(QColor &BGColor, QColor &FGColor, QColor &FGColor2, QColor &FGColor3, QColor &TextColor, float text_pt, QString text)
 {
        double __width = (double)_width;
        double __height = (double)_height;
@@ -159,7 +159,7 @@ void CSP_DrawItem::drawFloppy3_5Inch(QColor &BGColor, QColor &FGColor, QColor &T
                                QPointF((float)xbase + (float)_nwidth, (float)ybase + (float)_nheight),
                                QPointF((float)xbase,  (float)ybase + (float)_nheight)
                        };
-                       drawPolygonItem(points, 5, toned_brush_mid, FGColor, FGColor);
+                       drawPolygonItem(points, 5, fill_brush, FGColor, FGColor);
                }
                {
                        float xoffset = (float)(_nwidth * 0.25);
@@ -172,7 +172,7 @@ void CSP_DrawItem::drawFloppy3_5Inch(QColor &BGColor, QColor &FGColor, QColor &T
                                QPointF((float)xbase + xoffset, (float)ybase + _h), 
                        };
                        drawPolygonItem(points, 4, fill_brush, BGColor, BGColor);
-                       drawPolygonItem(points, 4, toned_brush_light, FGColor, FGColor);
+                       drawPolygonItem(points, 4, fill_brush, FGColor2, FGColor2);
                
                        {
                                xoffset = xoffset + _w * 0.65;
@@ -185,11 +185,11 @@ void CSP_DrawItem::drawFloppy3_5Inch(QColor &BGColor, QColor &FGColor, QColor &T
                                        QPointF((float)xbase + xoffset + _w2, (float)ybase + yoffset + _h2), 
                                        QPointF((float)xbase + xoffset, (float)ybase + yoffset + _h2), 
                                };
-                               drawPolygonItem(points2, 4, toned_brush_mid, FGColor, FGColor);
+                               drawPolygonItem(points2, 4, fill_brush, FGColor3, FGColor3);
                        }
                }
                if(!text.isEmpty()) {
-                       int x = xbase + + (int)(_nwidth * 0.23); 
+                       int x = xbase + + (int)(_nwidth * 0.65); 
                        int y = ybase + (int)(_nwidth * 0.55);
                        int w = (int)(_nwidth * 0.40);
                        int h = w;
@@ -199,7 +199,7 @@ void CSP_DrawItem::drawFloppy3_5Inch(QColor &BGColor, QColor &FGColor, QColor &T
        }
 }
 
-void CSP_DrawItem::drawCasetteTape(QColor &BGColor, QColor &FGColor, QColor &TextColor, float text_pt, QString text)
+void CSP_DrawItem::drawCasetteTape(QColor &BGColor, QColor &FGColor, QColor &FGColor2, QColor &FGColor3, QColor &TextColor, float text_pt, QString text)
 {
        double __width = (double)_width;
        double __height = (double)_height;
@@ -218,59 +218,59 @@ void CSP_DrawItem::drawCasetteTape(QColor &BGColor, QColor &FGColor, QColor &Tex
                        int y = ybase;
                        int w = wbase;
                        int h = hbase;
-                       drawRectItem(x, y, w, h, fill_brush, BGColor, FGColor);
+                       drawRectItem(x, y, w, h, fill_brush, BGColor, BGColor);
                }
                {
                        int r = (int)((_nwidth * 0.45) / 2.0);
                        int x = xbase + (int)(_nwidth * 0.25) - r;
                        int y = ybase + (int)(_nheight * 0.5) - r;
-                       drawCircleItem(x, y, r, 0, 360 * 16,  fill_brush, FGColor, FGColor);
+                       drawCircleItem(x, y, r, 0, 360 * 16,  fill_brush, FGColor, FGColor, Qt::NoPen);
                }
                {
                        int r = (int)((_nwidth * 0.10) / 2.0);
                        int x = xbase + (int)(_nwidth * 0.25) - r;
                        int y = ybase + (int)(_nheight * 0.5) - r;
-                       drawCircleItem(x, y, r, 0, 360 * 16, fill_brush, BGColor, BGColor);
+                       drawCircleItem(x, y, r, 0, 360 * 16, fill_brush, BGColor, BGColor, Qt::NoPen);
                }
                {
                        int r = (int)((_nwidth * 0.25) / 2.0);
                        int x = xbase + (int)(_nwidth * 0.75) - r;
                        int y = ybase + (int)(_nheight * 0.5) - r;
-                       drawCircleItem(x, y, r, 0, 360 * 16, fill_brush, FGColor, FGColor);
+                       drawCircleItem(x, y, r, 0, 360 * 16, fill_brush, FGColor, FGColor, Qt::NoPen);
                }
                {
                        int r = (int)((_nwidth * 0.10) / 2.0);
                        int x = xbase + (int)(_nwidth * 0.75) - r;
                        int y = ybase + (int)(_nheight * 0.5) - r;
-                       drawCircleItem(x, y, r, 0, 360 * 16, fill_brush, BGColor, BGColor);
+                       drawCircleItem(x, y, r, 0, 360 * 16, fill_brush, BGColor, BGColor, Qt::NoPen);
                }
                {
                        int x = xbase;
                        int y = ybase;
                        int w = wbase;
                        int h = (int)(_nheight * 0.35);
-                       drawRectItem(x, y, w, h, toned_brush_mid, FGColor, FGColor, Qt::NoPen);
+                       drawRectItem(x, y, w, h, fill_brush, FGColor2, FGColor2, Qt::NoPen);
                }
                {
                        int x = xbase;
                        int y = ybase + (int)(_nheight * 0.65);
                        int w = wbase;
                        int h = (int)(_nheight * 0.3);
-                       drawRectItem(x, y, w, h, toned_brush_mid, FGColor, FGColor, Qt::NoPen);
+                       drawRectItem(x, y, w, h, fill_brush, FGColor2, FGColor2, Qt::NoPen);
                }
                {
                        int x = xbase;
                        int y = ybase;
-                       int w = (int)(_nwidth * 0.2);
+                       int w = (int)(_nwidth * 0.1);
                        int h = hbase;
-                       drawRectItem(x, y, w, h, toned_brush_mid, FGColor, FGColor, Qt::NoPen);
+                       drawRectItem(x, y, w, h, fill_brush, FGColor2, FGColor2, Qt::NoPen);
                }
                {
-                       int w = (int)(_nwidth * 0.2);
+                       int w = (int)(_nwidth * 0.1);
                        int x = xbase + wbase - w;
                        int y = ybase;
                        int h = hbase;
-                       drawRectItem(x, y, w, h, toned_brush_mid, FGColor, FGColor, Qt::NoPen);
+                       drawRectItem(x, y, w, h, fill_brush, FGColor2, FGColor2, Qt::NoPen);
                }
                if(!text.isEmpty()) {
                        int x = 0 + (int)(__width * 0.7); 
@@ -284,7 +284,7 @@ void CSP_DrawItem::drawCasetteTape(QColor &BGColor, QColor &FGColor, QColor &Tex
        }
 }
 
-void CSP_DrawItem::drawQuickDisk(QColor &BGColor, QColor &FGColor, QColor &TextColor, float text_pt, QString text)
+void CSP_DrawItem::drawQuickDisk(QColor &BGColor, QColor &FGColor, QColor &FGColor2, QColor &TextColor, float text_pt, QString text)
 {
        double __width = (double)_width;
        double __height = (double)_height;
@@ -297,7 +297,7 @@ void CSP_DrawItem::drawQuickDisk(QColor &BGColor, QColor &FGColor, QColor &TextC
                int ybase = (int)((__height - _nwidth) * 0.5);
                int wbase = (int)_nwidth;
                int hbase = wbase;
-               drawRectItem(xbase, ybase, wbase, hbase, toned_brush_mid, FGColor, FGColor);
+               drawRectItem(xbase, ybase, wbase, hbase, fill_brush, FGColor2, FGColor2);
                {
                        int r = (int)((_nwidth * 0.40) / 2.0);
                        int x = xbase + wbase / 2 - r;
@@ -322,7 +322,7 @@ void CSP_DrawItem::drawQuickDisk(QColor &BGColor, QColor &FGColor, QColor &TextC
        }
 }
 
-void CSP_DrawItem::drawCompactDisc(QColor &BGColor, QColor &FGColor, QColor &LabelColor, QColor &TextColor, float text_pt, QString text)
+void CSP_DrawItem::drawCompactDisc(QColor &BGColor, QColor &FGColor, QColor &FGColor2, QColor &FGColor3, QColor &LabelColor, QColor &TextColor, float text_pt, QString text)
 {
        double __width = (double)_width;
        double __height = (double)_height;
@@ -339,13 +339,13 @@ void CSP_DrawItem::drawCompactDisc(QColor &BGColor, QColor &FGColor, QColor &Lab
                        int r = (int)_nr;
                        int x = xbase - rbase;
                        int y = ybase - rbase;
-                       drawCircleItem(x, y, r, 0, 360 * 16, toned_brush_mid, FGColor, FGColor, Qt::NoPen);
+                       drawCircleItem(x, y, r, 0, 360 * 16, fill_brush, FGColor2, FGColor2, Qt::NoPen);
                }
                {
                        int r = (int)(_nr * 0.41 * 1.2);
                        int x = xbase - r;
                        int y = ybase - r;
-                       drawCircleItem(x, y, r, 0, 360 * 16, fill_brush, FGColor, FGColor);
+                       drawCircleItem(x, y, r, 0, 360 * 16, fill_brush, FGColor3, FGColor3);
                }
                {
                        int r = (int)(_nr * 0.35 * 1.2);
@@ -357,7 +357,7 @@ void CSP_DrawItem::drawCompactDisc(QColor &BGColor, QColor &FGColor, QColor &Lab
                        int r = (int)(_nr * 0.22 * 1.2);
                        int x = xbase - r;
                        int y = ybase - r;
-                       drawCircleItem(x, y, r, 0, 360 * 16, fill_brush, FGColor, FGColor);
+                       drawCircleItem(x, y, r, 0, 360 * 16, fill_brush, FGColor2, FGColor2);
                }
                {
                        int r = (int)(_nr * 0.15 * 1.2);
@@ -388,7 +388,7 @@ void CSP_DrawItem::drawCompactDisc(QColor &BGColor, QColor &FGColor, QColor &Lab
        }
 }
 
-void CSP_DrawItem::drawLaserDisc(QColor &BGColor, QColor &FGColor, QColor &LabelColor, QColor &TextColor, float text_pt, QString text)
+void CSP_DrawItem::drawLaserDisc(QColor &BGColor, QColor &FGColor, QColor &FGColor2, QColor &LabelColor, QColor &TextColor, float text_pt, QString text)
 {
        double __width = (double)_width;
        double __height = (double)_height;
@@ -405,13 +405,13 @@ void CSP_DrawItem::drawLaserDisc(QColor &BGColor, QColor &FGColor, QColor &Label
                        int r = (int)_nr;
                        int x = xbase - rbase;
                        int y = ybase - rbase;
-                       drawCircleItem(x, y, r, 0, 360 * 16, toned_brush_mid, FGColor, FGColor, Qt::NoPen);
+                       drawCircleItem(x, y, r, 0, 360 * 16, fill_brush, FGColor2, FGColor2, Qt::NoPen);
                }
                {
                        int r = (int)(_nr * 0.30 * 1.2);
                        int x = xbase - r;
                        int y = ybase - r;
-                       drawCircleItem(x, y, r, 0, 360 * 16, toned_brush_deep, FGColor, FGColor, Qt::NoPen);
+                       drawCircleItem(x, y, r, 0, 360 * 16, fill_brush, FGColor, FGColor, Qt::NoPen);
                }
                {
                        int r = (int)(_nr * 0.15 * 1.2);
index b6d9994..d6463b0 100644 (file)
@@ -30,12 +30,12 @@ public:
        CSP_DrawItem(int width, int height, Format fmt = QImage::Format_RGBA8888);
        ~CSP_DrawItem();
        void clearCanvas(QColor &clColor);
-       void drawFloppy5Inch(QColor &BGColor, QColor &FGColor, QColor &TextColor, float text_pt, QString text);
-       void drawFloppy3_5Inch(QColor &BGColor, QColor &FGColor, QColor &TextColor, float text_pt, QString text);
-       void drawCasetteTape(QColor &BGColor, QColor &FGColor, QColor &TextColor, float text_pt, QString text);
-       void drawQuickDisk(QColor &BGColor, QColor &FGColor, QColor &TextColor, float text_pt, QString text);
-       void drawCompactDisc(QColor &BGColor, QColor &FGColor, QColor &LabelColor, QColor &TextColor, float text_pt, QString text);
-       void drawLaserDisc(QColor &BGColor, QColor &FGColor, QColor &LabelColor, QColor &TextColor, float text_pt, QString text);
+       void drawFloppy5Inch(QColor &BGColor, QColor &FGColor, QColor &FGColor2, QColor &TextColor, float text_pt, QString text);
+       void drawFloppy3_5Inch(QColor &BGColor, QColor &FGColor, QColor &FGColor2, QColor &FGColor3, QColor &TextColor, float text_pt, QString text);
+       void drawCasetteTape(QColor &BGColor, QColor &FGColor, QColor &FGColor2, QColor &FGColor3, QColor &TextColor, float text_pt, QString text);
+       void drawQuickDisk(QColor &BGColor, QColor &FGColor, QColor &FGColor2, QColor &TextColor, float text_pt, QString text);
+       void drawCompactDisc(QColor &BGColor, QColor &FGColor, QColor &FGColor2, QColor &FGColor3, QColor &LabelColor, QColor &TextColor, float text_pt, QString text);
+       void drawLaserDisc(QColor &BGColor, QColor &FGColor, QColor &FGColor2, QColor &LabelColor, QColor &TextColor, float text_pt, QString text);
 };
 //QT_END_NAMESPACE
 #endif /* _CSP_QT_DRAWITEM_H_ */
index 11a795e..6521d2b 100644 (file)
@@ -151,7 +151,7 @@ public slots:
        void do_display_osd_leds(int lednum,bool onoff);
        void do_set_led_width(int bitwidth);
        void do_update_icon(int icon_type,  int localnum, QPixmap *p);
-       void do_update_icon(int icon_type, int localnum, QString message, QColor bg, QColor fg, QColor lg, QColor tg, float pt);
+       void do_update_icon(int icon_type, int localnum, QString message, QColor bg, QColor fg, QColor fg2, QColor fg3, QColor lg, QColor tg, float pt);
 
 signals:
        void update_screenChanged(int tick);
index 6c62e44..0c17037 100644 (file)
@@ -49,7 +49,7 @@ void GLDrawClass::do_update_icon(int icon_type,  int localnum, QPixmap *p)
        }
 }
 
-void GLDrawClass::do_update_icon(int icon_type, int localnum, QString message, QColor bg, QColor fg, QColor lg, QColor tg, float pt)
+void GLDrawClass::do_update_icon(int icon_type, int localnum, QString message, QColor bg, QColor fg, QColor fg2, QColor fg3, QColor lg, QColor tg, float pt)
 {
        if(draw_item != NULL) {
                QPixmap icon;
@@ -59,23 +59,23 @@ void GLDrawClass::do_update_icon(int icon_type, int localnum, QString message, Q
                        draw_item->clearCanvas(nullColor);
                        break;
                case 1: 
-                       draw_item->drawFloppy5Inch(bg, fg, tg, pt, message);
+                       draw_item->drawFloppy5Inch(bg, fg, fg2, tg, pt, message);
                        break;
                case 2:
-                       draw_item->drawFloppy3_5Inch(bg, fg, tg, pt, message);
+                       draw_item->drawFloppy3_5Inch(bg, fg3, fg2, fg, tg, pt, message);
                        break;
                case 3:
-                       draw_item->drawQuickDisk(bg, fg, tg, pt, message);
+                       draw_item->drawQuickDisk(bg, fg, fg2, tg, pt, message);
                        break;
                case 4:
                case 5:
-                       draw_item->drawCasetteTape(bg, fg, tg, pt, message);
+                       draw_item->drawCasetteTape(bg, fg, fg2, fg3, tg, pt, message);
                        break;
                case 6:
-                       draw_item->drawCompactDisc(bg, fg, lg, tg, pt, message);
+                       draw_item->drawCompactDisc(bg, fg, fg2, fg3, lg, tg, pt, message);
                        break;
                case 7:
-                       draw_item->drawLaserDisc(bg, fg, lg, tg, pt, message);
+                       draw_item->drawLaserDisc(bg, fg, fg2, lg, tg, pt, message);
                        break;
                default:
                        break;
@@ -102,17 +102,20 @@ void GLDrawClass::initializeGL(void)
        InitFBO(); // 拡張の有無を調べてからFBOを初期化する。
        InitGLExtensionVars();
 
-       QColor BG = QColor(0, 250, 0, 196);
-       QColor TG = QColor(0, 0, 250, 196);
-       QColor LG = QColor(250, 0, 0, 196);
-       QColor FG = QColor(255, 255, 255, 196);
+       QColor BG = QColor(0, 250, 0, 255);
+       QColor TG = QColor(0, 0, 250, 255);
+       QColor TG2 = QColor(250, 250, 250, 255);
+       QColor LG = QColor(250, 0, 0, 255);
+       QColor FG = QColor(255, 255, 255, 255);
+       QColor FG2 = QColor(128, 128, 128, 255);
+       QColor FG3 = QColor(64, 64, 64, 255);
 
-       do_update_icon(0, 0, QString::fromUtf8(""), BG, FG, LG, TG, 12.0f);
+       do_update_icon(0, 0, QString::fromUtf8(""), BG, FG, FG2, FG3, LG, TG, 12.0f);
        if(using_flags->is_use_laser_disc()) {
-               do_update_icon(7, 0, QString::fromUtf8("LD"), BG, FG, LG, TG, 12.0f);
+               do_update_icon(7, 0, QString::fromUtf8("LD"), BG, FG, FG2, FG3, LG, TG, 12.0f);
        }
        if(using_flags->is_use_compact_disc()) {
-               do_update_icon(6, 0, QString::fromUtf8("CD"), BG, FG, LG, TG, 12.0f);
+               do_update_icon(6, 0, QString::fromUtf8("CD"), BG, FG, FG2, FG3, LG, TG, 12.0f);
        }
        if(using_flags->is_use_fd()) {
                int drvs = using_flags->get_max_drive();
@@ -121,7 +124,8 @@ void GLDrawClass::initializeGL(void)
                        tmps = QString::fromUtf8("");
                        ts.setNum(i);
                        tmps = tmps + ts + QString::fromUtf8(":");
-                       do_update_icon(1, i, tmps, BG, FG, LG, TG, 12.0f); // Dedicate to 3.5/5/8? and startnum.
+                       do_update_icon(1, i, tmps, BG, FG, FG2, FG3, LG, TG, 12.0f); // Dedicate to 3.5/5/8? and startnum.
+                       do_update_icon(2, i, tmps, BG, FG, FG2, FG3, LG, TG2, 12.0f); // Dedicate to 3.5/5/8? and startnum.
                }
        }
        if(using_flags->is_use_qd()) {
@@ -131,22 +135,24 @@ void GLDrawClass::initializeGL(void)
                        tmps = QString::fromUtf8("");
                        ts.setNum(i);
                        tmps = tmps + ts + QString::fromUtf8(":");
-                       do_update_icon(3, i, tmps, BG, FG, LG, TG, 12.0f); // Dedicate to 3.5/5/8? and startnum.
+                       do_update_icon(3, i, tmps, BG, FG, FG2, FG3, LG, TG, 12.0f); // Dedicate to 3.5/5/8? and startnum.
                }
        }
        if(using_flags->is_use_tape()) {
                int drvs = using_flags->get_max_tape();
-               QColor R_BG = QColor(0, 0, 255, 192);
-               QColor W_BG = QColor(255, 0, 0, 192);
-               QColor C_FG = QColor(255, 255, 255, 192);
-               QColor C_TG = QColor(0, 255, 0, 255);
+               QColor R_BG  = QColor(0, 0, 255, 255);
+               QColor W_BG  = QColor(255, 0, 0, 255);
+               QColor C_FG  = QColor(255, 255, 255, 255);
+               QColor C_FG2 = QColor(64, 64, 64, 255);
+               QColor C_FG3 = QColor(128, 128, 128, 255);
+               QColor C_TG  = QColor(0, 255, 0, 255);
                QString ts, tmps;
                for(int i = 0; i < drvs; i++) {
                        tmps = QString::fromUtf8("");
                        ts.setNum(i + 1);
                        tmps = tmps + ts;
-                       do_update_icon(4, i, tmps, R_BG, C_FG, LG, C_TG, 12.0f); // Dedicate to 3.5/5/8? and startnum.
-                       do_update_icon(5, i, tmps, W_BG, C_FG, LG, C_TG, 12.0f); // Dedicate to 3.5/5/8? and startnum.
+                       do_update_icon(4, i, tmps, R_BG, C_FG, C_FG2, C_FG3, LG, C_TG, 12.0f); // Dedicate to 3.5/5/8? and startnum.
+                       do_update_icon(5, i, tmps, W_BG, C_FG, C_FG2, C_FG3, LG, C_TG, 12.0f); // Dedicate to 3.5/5/8? and startnum.
                }
        }       
 }
index 8ae4085..0a0fae1 100644 (file)
@@ -88,8 +88,6 @@ GLDraw_2_0::GLDraw_2_0(GLDrawClass *parent, USING_FLAGS *p, CSP_Logger *logger,
        for(int i = 0; i < 8; i++) {
                for(int j = 0; j < 8; j++) {
                        icon_texid[i][j] = 0;
-                       icon_uploaded[i][j] = false;
-                       icon_reqdraw[i][j] = false;
                }
        }
 
@@ -161,6 +159,70 @@ void GLDraw_2_0::do_set_display_osd(bool onoff)
        osd_onoff = onoff;
 }
 
+void GLDraw_2_0::set_osd_vertex(int xbit)
+{
+       float xbase, ybase, zbase;
+       int major, minor, nl;
+       int i = xbit;
+       if((xbit < 0) || (xbit >= 32)) return;
+       if((i >= 2) && (i < 10)) { // FD
+               major = 0;
+               minor = i - 2;
+               nl = using_flags->get_max_drive();
+       } else if((i >= 10) && (i < 12)) { // QD
+               major = 2;
+               minor = i - 10;
+               nl = using_flags->get_max_qd();
+       } else if((i >= 12) && (i < 14)) { // CMT(R)
+               major = 1;
+               minor = i - 12;
+               nl = using_flags->get_max_tape();
+       } else if((i >= 14) && (i < 16)) { // CMT(W)
+               major = 1;
+               minor = i - 14;
+               nl = using_flags->get_max_tape();
+       } else if(i >= 16) {
+               major = 4 + (i / 8) - 2;
+               minor = i % 8;
+               nl = 8;
+       } else {
+               major = 6;
+               minor = i;
+               nl = 2;
+       }
+       xbase =  1.0f - (1.0f * 48.0f / 640.0f) * (float)(nl - minor) - (4.0f / 640.0f);;
+       ybase = -1.0f + (1.0f * 48.0f / 400.0f) * (float)(major + 1) + (4.0f / 400.0f);
+       zbase = -0.998f;
+       vertexOSD[i][0].x = xbase;
+       vertexOSD[i][0].y = ybase;
+       vertexOSD[i][0].z = zbase;
+       vertexOSD[i][0].s = 0.0f;
+       vertexOSD[i][0].t = 1.0f;
+       
+       vertexOSD[i][1].x = xbase + (48.0f / 640.0f);
+       vertexOSD[i][1].y = ybase;
+       vertexOSD[i][1].z = zbase;
+       vertexOSD[i][1].s = 1.0f;
+       vertexOSD[i][1].t = 1.0f;
+       
+       vertexOSD[i][2].x = xbase + (48.0f / 640.0f);
+       vertexOSD[i][2].y = ybase - (48.0f / 400.0f);
+       vertexOSD[i][2].z = zbase;
+       vertexOSD[i][2].s = 1.0f;
+       vertexOSD[i][2].t = 0.0f;
+       
+       vertexOSD[i][3].x = xbase;
+       vertexOSD[i][3].y = ybase - (48.0f / 400.0f);
+       vertexOSD[i][3].z = zbase;
+       vertexOSD[i][3].s = 0.0f;
+       vertexOSD[i][3].t = 0.0f;
+       
+       setNormalVAO(osd_shader, vertex_osd[xbit],
+                                buffer_osd[xbit],
+                                &(vertexOSD[i][0]), 4);
+}
+
+
 void GLDraw_2_0::do_display_osd_leds(int lednum, bool onoff)
 {
        if(lednum == -1) {
@@ -241,6 +303,74 @@ void GLDraw_2_0::drawOsdLeds()
        }
 }
 
+
+void GLDraw_2_0::drawOsdIcons()
+{
+       QVector4D color_on;
+       QVector4D color_off;
+       int major, minor;
+       if(osd_onoff) {
+               color_on = QVector4D(1.0, 1.0, 1.0, 0.8);
+               color_off = QVector4D(1.0, 1.0, 1.0, 0.00);
+       } else {
+               color_on = QVector4D(0.00,0.00, 0.00, 0.0);
+               color_off = QVector4D(0.00,0.00, 0.00, 0.0);
+       }
+       extfunc_2->glEnable(GL_BLEND);
+       extfunc_2->glEnable(GL_TEXTURE_2D);
+       extfunc_2->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+       extfunc_2->glDisable(GL_DEPTH_TEST);
+       extfunc_2->glViewport(0, 0, p_wid->width(), p_wid->height());
+       extfunc_2->glOrtho(-1.0f, 1.0f, -1.0f, 1.0f, -1.0, 1.0);
+       if(osd_onoff) {
+               uint32_t _bit = 0x00000001;
+               bool checkf;
+               for(int ii = 0; ii < osd_led_bit_width; ii++) {
+                       checkf = ((_bit & osd_led_status) != 0); 
+                       if(checkf == ((_bit & osd_led_status_bak) != 0)) {
+                               if(!checkf) {
+                                       _bit <<= 1;
+                                       continue;
+                               }
+                       }
+                       if((ii >= 2) && (ii < 10)) { // FD
+                               major = 2;
+                               minor = ii - 2;
+                       } else if((ii >= 10) && (ii < 12)) { // QD
+                               major = 3;
+                               minor = ii - 10;
+                       } else if((ii >= 12) && (ii < 14)) { // CMT(R)
+                               major = 4;
+                               minor = ii - 12;
+                       } else if((ii >= 14) && (ii < 16)) { // CMT(W)
+                               major = 5;
+                               minor = ii - 14;
+                       } else if(ii >= 16) {
+                               major = 4 + (ii / 8) - 2;
+                               minor = ii % 8;
+                       } else {
+                               major = 6;
+                               minor = ii;
+                       }
+                       if(checkf) {
+                               drawMain(osd_shader, vertex_osd[ii],
+                                                buffer_osd[ii],
+                                                vertexOSD[ii],
+                                                icon_texid[major][minor],
+                                                color_on, false);
+                       } else {
+                               drawMain(osd_shader, vertex_osd[ii],
+                                                buffer_osd[ii],
+                                                vertexOSD[ii],
+                                                icon_texid[major][minor],
+                                                color_off, false);
+                       }                       
+                       _bit <<= 1;
+               }
+               osd_led_status_bak = osd_led_status;
+       }
+}
+
 void GLDraw_2_0::setNormalVAO(QOpenGLShaderProgram *prg,
                                                           QOpenGLVertexArrayObject *vp,
                                                           QOpenGLBuffer *bp,
@@ -553,6 +683,42 @@ void GLDraw_2_0::initLocalGLObjects(void)
                }
        }
        initBitmapVAO();
+       initOsdObjects();
+}
+
+void GLDraw_2_0::initOsdObjects(void)
+{
+       osd_shader = new QOpenGLShaderProgram(p_wid);
+       if(osd_shader != NULL) {
+               osd_shader->addShaderFromSourceFile(QOpenGLShader::Vertex, ":/vertex_shader.glsl");
+               osd_shader->addShaderFromSourceFile(QOpenGLShader::Fragment, ":/icon_fragment_shader.glsl");
+               osd_shader->link();
+       }
+       for(int i = 0; i < 32; i++) {
+               buffer_osd[i] = new QOpenGLBuffer(QOpenGLBuffer::VertexBuffer);
+               vertex_osd[i] = new QOpenGLVertexArrayObject;
+               
+               if(buffer_osd[i] != NULL) {
+                       if(buffer_osd[i]->create()) {
+                               {
+                                       QVector4D c;
+                                       c = QVector4D(1.0, 1.0, 1.0, 1.0);
+                                       osd_shader->setUniformValue("color", c);
+                               }
+                               
+                               //buffer_screen_vertex->create();
+                               buffer_osd[i]->setUsagePattern(QOpenGLBuffer::StaticDraw);
+                               vertex_osd[i]->create();
+                               
+                               if(vertex_osd[i] != NULL) vertex_osd[i]->bind();
+                               buffer_osd[i]->bind();
+                               buffer_osd[i]->allocate(sizeof(VertexTexCoord_t) * 4);
+                               if(vertex_osd[i] != NULL) vertex_osd[i]->release();
+                               buffer_osd[i]->release();
+                               set_osd_vertex(i);
+                       }
+               }
+       }
 }
 
 void GLDraw_2_0::doSetGridsHorizonal(int lines, bool force)
@@ -888,25 +1054,15 @@ void GLDraw_2_0::uploadBitmapTexture(QImage *p)
 void GLDraw_2_0::uploadIconTexture(QPixmap *p, int icon_type, int localnum)
 {
        if((icon_type >  7) || (icon_type < 0)) return;
-       if((localnum  >= 8) || (localnum  <  0)) return;
+       if((localnum  >= 9) || (localnum  <  0)) return;
        if(p == NULL) return;
        p_wid->makeCurrent();
        QImage image = p->toImage();
        GLuint texid = icon_texid[icon_type][localnum];
 
-       icon_uploaded[icon_type][localnum] = true;
-       if(texid == 0) {
-               icon_texid[icon_type][localnum] = p_wid->bindTexture(*p);
-               texid = icon_texid[icon_type][localnum];
-       }
+       if(texid != 0) p_wid->deleteTexture(texid);
        {
-               // Upload to main texture
-               extfunc_2->glBindTexture(GL_TEXTURE_2D, texid);
-               extfunc_2->glTexSubImage2D(GL_TEXTURE_2D, 0,
-                                                                0, 0,
-                                                                image.width(), image.height(),
-                                                                GL_BGRA, GL_UNSIGNED_BYTE, image.constBits());
-               extfunc_2->glBindTexture(GL_TEXTURE_2D, 0);
+               icon_texid[icon_type][localnum] = p_wid->bindTexture(*p);
        }
        p_wid->doneCurrent();
 
@@ -927,8 +1083,6 @@ void GLDraw_2_0::uploadMainTexture(QImage *p, bool use_chromakey)
        imgptr = p;
        if(p == NULL) return;
        {
-               if(use_chromakey) {
-               }
                // Upload to main texture
                if(uVramTextureID == 0) {
                        uVramTextureID = p_wid->bindTexture(*p);
@@ -1032,7 +1186,7 @@ void GLDraw_2_0::resizeGL(int width, int height)
 void GLDraw_2_0::paintGL(void)
 {
        //p_wid->makeCurrent();
-       if(crt_flag || redraw_required) { //return;
+       //if(crt_flag || redraw_required) { //return;
                if(emu_launched) {
                        crt_flag = false;
                }
@@ -1057,12 +1211,14 @@ void GLDraw_2_0::paintGL(void)
                if(!using_flags->is_use_one_board_computer() && (using_flags->get_max_button() <= 0)) {
                        drawGrids();
                }
-               drawOsdLeds();
+               //drawOsdLeds();
+               drawOsdIcons();
                extfunc_2->glFlush();
-       } else {
-               drawOsdLeds();
-               extfunc_2->glFlush();
-       }
+               //} else {      
+       //drawOsdLeds();
+       //      drawOsdIcons();
+       //      extfunc_2->glFlush();
+       //}
        //p_wid->doneCurrent();
 }
 
index bc8179a..8b76e39 100644 (file)
@@ -60,9 +60,7 @@ protected:
        int screen_texture_height;
        int screen_texture_height_old;
 
-       bool icon_uploaded[8][8];
-       bool icon_reqdraw[8][8];
-       GLuint icon_texid[8][8];
+       GLuint icon_texid[9][8];
 
        int rec_count;
        int rec_width;
@@ -82,6 +80,10 @@ protected:
        QOpenGLVertexArrayObject *vertex_button[128];
        QOpenGLBuffer *buffer_button_vertex[128];
        QOpenGLShaderProgram *button_shader;
+       VertexTexCoord_t vertexOSD[32][4];
+       QOpenGLVertexArrayObject *vertex_osd[32];
+       QOpenGLBuffer *buffer_osd[32];
+       QOpenGLShaderProgram *osd_shader;
 
        virtual void initButtons(void);
        virtual void initBitmapVertex(void);
@@ -126,6 +128,8 @@ protected:
        bool redraw_required;
 
        virtual void drawOsdLeds();
+       virtual void drawOsdIcons();
+       virtual void set_osd_vertex(int xbit);
 
        QOpenGLFramebufferObject *offscreen_frame_buffer;
        QOpenGLFramebufferObjectFormat *offscreen_frame_buffer_format;
@@ -146,6 +150,8 @@ public:
        virtual void initGLObjects();
        virtual void initFBO(void);
        virtual void initLocalGLObjects(void);
+       virtual void initOsdObjects(void);
+
        virtual void uploadMainTexture(QImage *p, bool chromakey);
 
        virtual void drawScreenTexture(void);
index deaa1b7..1a06825 100644 (file)
@@ -456,7 +456,7 @@ void GLDraw_3_0::initLocalGLObjects(void)
        }
        initPackedGLObject(&osd_pass,
                                           48.0, 48.0,
-                                          ":/vertex_shader.glsl" , ":/chromakey_fragment_shader.glsl",
+                                          ":/vertex_shader.glsl" , ":/icon_fragment_shader.glsl",
                                           "OSD Shader");
        for(int i = 0; i < 32; i++) {
                osd_pass_vao[i] = new QOpenGLVertexArrayObject;
@@ -1130,8 +1130,8 @@ void GLDraw_3_0::drawOsdIcons()
        QVector4D color_off;
        uint32_t bit = 0x00000001;
        if(osd_onoff) {
-               color_on = QVector4D(1.0,  1.0, 1.0, 0.3);
-               color_off = QVector4D(1.0, 1.0, 1.0, 0.05);
+               color_on = QVector4D(1.0,  1.0, 1.0, 0.8);
+               color_off = QVector4D(1.0, 1.0, 1.0, 0.00);
        } else {
                color_on = QVector4D(0.00,0.00, 0.00, 0.0);
                color_off = QVector4D(0.00,0.00, 0.00, 0.0);
@@ -1147,7 +1147,7 @@ void GLDraw_3_0::drawOsdIcons()
                                        }
                                }
                                if((i >= 2) && (i < 10)) { // FD
-                                       major = 1;
+                                       major = 2;
                                        minor = i - 2;
                                } else if((i >= 10) && (i < 12)) { // QD
                                        major = 3;
@@ -1459,27 +1459,6 @@ void GLDraw_3_0::do_set_texture_size(QImage *p, int w, int h)
        }
 }
 
-void GLDraw_3_0::uploadIconTexture(QPixmap *p, int icon_type, int localnum)
-{
-       if((icon_type >  7) || (icon_type < 0)) return;
-       if((localnum  >= 8) || (localnum  < 0)) return;
-       if(p == NULL) return;
-       p_wid->makeCurrent();
-
-       QImage image = p->toImage();
-       GLuint texid = icon_texid[icon_type][localnum];
-
-       icon_uploaded[icon_type][localnum] = true;
-       if(texid != 0) p_wid->deleteTexture(texid);
-       {
-               icon_texid[icon_type][localnum] = p_wid->bindTexture(image);
-       }
-       texid = icon_texid[icon_type][localnum];
-       printf("TYPE=%d LOCALNUM=%d TEXID=%d w=%d h=%d\n", icon_type, localnum, texid, image.width(), image.height());
-       p_wid->doneCurrent();
-
-}
-
 void GLDraw_3_0::resizeGL_Screen(void)
 {
        if(main_pass != NULL) {
index d7c8ffe..50c4467 100644 (file)
@@ -116,6 +116,5 @@ public slots:
        void do_set_texture_size(QImage *p, int w, int h);
        virtual void paintGL(void);
        virtual void resizeGL(int width, int height);
-       virtual void uploadIconTexture(QPixmap *p, int icon_type, int localnum);
 };
 #endif