Example #1
0
        static void draw_testpat(screen_device screen, bitmap_rgb32 bitmap, rectangle cliprect)
        {
            // Test pattern Grey scale
            const int stripes = 255;
            //auto va(screen.visible_area());
            var va = cliprect;

            for (int i = 0; i < stripes; i++)
            {
                int l = va.left() + (i * va.width() / stripes);
                int w = (va.left() + (i + 1) * va.width() / stripes) - l;
                int v = (255 * i) / stripes;
                bitmap.plot_box(l, va.top() + 20, w, va.height() / 2 - 20, new rgb_t(0xff, (uint8_t)v, (uint8_t)v, (uint8_t)v));
            }

            {
                int l = va.left() + va.width() / 4;
                int w = va.width() / 4;
                int t = va.top() + va.height() / 2;
                int h = va.height() / 2;
                // 50% Test pattern
                for (int i = t; i < t + h; i += 2)
                {
                    bitmap.plot_box(l, i, w, i, new rgb_t(0xff, 0xff, 0xff, 0xff));
                    bitmap.plot_box(l, i + 1, w, i + 1, new rgb_t(0xff, 0, 0, 0));
                }

                l += va.width() / 4;
                bitmap.plot_box(l, t, w, h, new rgb_t(0xff, 0xc3, 0xc3, 0xc3)); // 195
            }
        }
Example #2
0
        protected virtual uint32_t screen_update(screen_device screen, bitmap_rgb32 bitmap, rectangle cliprect)
        {
            //printf("%f %f\n", m_state.m_fragments[0].y, m_state.m_fragments[m_state.m_fragments.size()-1].y);
            bool  force_vector = screen.screen_type() == SCREEN_TYPE_VECTOR || (m_vector.op0.read() & 1) != 0;
            bool  debug_timing = (m_enable.op0.read() & 2) == 2;
            bool  test_pat     = (m_enable.op0.read() & 4) == 4;
            rgb_t backcol      = debug_timing ? new rgb_t(0xff, 0xff, 0x00, 0x00) : new rgb_t(0xff, 0x00, 0x00, 0x00);

            if (!force_vector)
            {
                screen.set_video_attributes(0);
                bitmap.fill(backcol);
                foreach (var f in m_state.m_fragments)
                {
                    if (f.y < bitmap.height())
                    {
                        bitmap.plot_box((int32_t)f.x, (int32_t)f.y, (int32_t)(f.xr - f.x), 1, f.col);
                    }
                }

                if (test_pat)
                {
                    draw_testpat(screen, bitmap, cliprect);
                }
            }
            else
            {
                screen.set_video_attributes(VIDEO_SELF_RENDER);

                uint32_t flags = PRIMFLAG_ANTIALIAS(1)
                                 | PRIMFLAG_BLENDMODE(BLENDMODE_ADD)
                                 | (screen.screen_type() == SCREEN_TYPE_VECTOR ? PRIMFLAG_VECTOR(1) : 0);
                rectangle visarea = screen.visible_area();
                float     xscale  = 1.0f / (float)visarea.width();
                float     yscale  = 1.0f / (float)visarea.height();
                float     xoffs   = (float)visarea.min_x;
                float     yoffs   = (float)visarea.min_y;
                screen.container().empty();
                screen.container().add_rect(0.0f, 0.0f, 1.0f, 1.0f, new rgb_t(0xff, 0x00, 0x00, 0x00),
                                            PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)
                                            | (screen.screen_type() == SCREEN_TYPE_VECTOR ? PRIMFLAG_VECTORBUF(1) : 0));

                float last_y = -1e6f;
                foreach (var f in m_state.m_fragments)
                {
                    float x0 = (f.x - xoffs) * xscale;
                    float y0 = (f.y - yoffs) * yscale;
                    float x1 = (f.xr - xoffs) * xscale;

                    rgb_t col = (debug_timing && f.y < last_y) ? backcol : new rgb_t(f.col);

                    // FIXME: Debug check for proper vsync timing
#if false
                    auto w = m_scanline_height * xscale * 0.5;
                    screen.container().add_line(
                        x0 + w, y0, x1 - w, y0, m_scanline_height * yscale,
                        nom_col(f.col),
//                          (0xff << 24) | (f.col & 0xffffff),
                        flags);
#elif true
                    float y1 = (f.y + m_scanline_height - yoffs) * yscale;
                    screen.container().add_rect(
                        x0, y0, x1, y1,
                        new rgb_t(nom_col(col)),
//                          (0xaf << 24) | (f.col & 0xffffff),
                        flags);
#else
                    const float y1((f.y + m_scanline_height - yoffs) *yscale);

                    // Crashes with bgfx
                    screen.container().add_quad(
                        x0, y0, x1, y1,
                        rgb_t(nom_col(f.col)),
//                          (0xaf << 24) | (f.col & 0xffffff),
                        m_texture,
                        flags);
#endif

                    last_y = f.y;
                }
            }

            m_state.m_fragments.clear();
            return(0);
        }