Beispiel #1
0
        public uint32_t screen_update(screen_device screen, bitmap_rgb32 bitmap, rectangle cliprect)
        {
            uint32_t  flags   = PRIMFLAG_ANTIALIAS(1) | PRIMFLAG_BLENDMODE(BLENDMODE_ADD) | PRIMFLAG_VECTOR(1);
            rectangle visarea = screen.visible_area();
            float     xscale  = 1.0f / (65536 * visarea.width());
            float     yscale  = 1.0f / (65536 * visarea.height());
            float     xoffs   = (float)visarea.min_x;
            float     yoffs   = (float)visarea.min_y;

            int curpointIdx = 0;  //point *curpoint;
            int lastx       = 0;
            int lasty       = 0;

            curpointIdx = 0;  //curpoint = m_vector_list.get();
            var curpoint = m_vector_list;

            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) | PRIMFLAG_VECTORBUF(1));

            for (int i = 0; i < m_vector_index; i++)
            {
                render_bounds coords = new render_bounds();

                float intensity        = (float)curpoint[curpointIdx].intensity / 255.0f; //float intensity = (float)curpoint->intensity / 255.0f;
                float intensity_weight = normalized_sigmoid(intensity, vector_options.s_beam_intensity_weight);

                // check for static intensity
                float beam_width = m_min_intensity == m_max_intensity
                    ? vector_options.s_beam_width_min
                    : vector_options.s_beam_width_min + intensity_weight * (vector_options.s_beam_width_max - vector_options.s_beam_width_min);

                // normalize width
                beam_width *= 1.0f / (float)VECTOR_WIDTH_DENOM;

                // apply point scale for points
                if (lastx == curpoint[curpointIdx].x && lasty == curpoint[curpointIdx].y)  //if (lastx == curpoint->x && lasty == curpoint->y)
                {
                    beam_width *= vector_options.s_beam_dot_size;
                }

                coords.x0 = ((float)lastx - xoffs) * xscale;
                coords.y0 = ((float)lasty - yoffs) * yscale;
                coords.x1 = ((float)curpoint[curpointIdx].x - xoffs) * xscale; //coords.x1 = ((float)curpoint->x - xoffs) * xscale;
                coords.y1 = ((float)curpoint[curpointIdx].y - yoffs) * yscale; //coords.y1 = ((float)curpoint->y - yoffs) * yscale;

                if (curpoint[curpointIdx].intensity != 0)                      //if (curpoint->intensity != 0)
                {
                    screen.container().add_line(
                        coords.x0, coords.y0, coords.x1, coords.y1,
                        beam_width,
                        new rgb_t(((uint32_t)curpoint[curpointIdx].intensity << 24) | (curpoint[curpointIdx].col & 0xffffff)),  //(curpoint->intensity << 24) | (curpoint->col & 0xffffff),
                        flags);
                }

                lastx = curpoint[curpointIdx].x; //lastx = curpoint->x;
                lasty = curpoint[curpointIdx].y; //lasty = curpoint->y;

                curpointIdx++;                   //curpoint++;
            }

            return(0);
        }
Beispiel #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);
        }