コード例 #1
0
ファイル: c_system.cpp プロジェクト: Bong1236/europa
    void C_System::Update(unsigned int ticks)
    {
        SetTicks(ticks);

        for(unsigned int i = 0; i < GetDiffTicks(); i++)
            UpdateCode();
    }
コード例 #2
0
ファイル: plotter.cpp プロジェクト: DapengChalmers/ZSLAM_TX2
Plotter::Plotter(
    DataLog* log,
    float left, float right, float bottom, float top,
    float tickx, float ticky,
    Plotter* linked_plotter_x,
    Plotter* linked_plotter_y
)   : default_log(log),
      colour_wheel(0.6f),
      rview_default(left,right,bottom,top), rview(rview_default), target(rview),
      selection(0,0,0,0),
      track(false), track_x("$i"), track_y(""),
      trigger_edge(0), trigger("$0"),
      linked_plotter_x(linked_plotter_x),
      linked_plotter_y(linked_plotter_y)
{
    if(!log) {
        throw std::runtime_error("DataLog not specified");
    }
    // Prevent links to ourselves - this could cause infinite recursion.
    if(linked_plotter_x == this) this->linked_plotter_x = 0;
    if(linked_plotter_y == this) this->linked_plotter_y = 0;

    // Handle our own mouse / keyboard events
    this->handler = this;
    hover[0] = 0;
    hover[1] = 0;

    // Default colour scheme
    colour_bg = Colour(0.0f, 0.0f, 0.0f);
    colour_tk = Colour(0.2f, 0.2f, 0.2f);
    colour_ax = Colour(0.5f, 0.5f, 0.5f);

    SetTicks(tickx, ticky);

    // Create shader for drawing simple primitives
    prog_lines.AddShader( GlSlVertexShader,
                         "attribute vec2 a_position;\n"
                         "uniform vec4 u_color;\n"
                         "uniform vec2 u_scale;\n"
                         "uniform vec2 u_offset;\n"
                         "varying vec4 v_color;\n"
                         "void main() {\n"
                         "    gl_Position = vec4(u_scale * (a_position + u_offset),0,1);\n"
                         "    v_color = u_color;\n"
                         "}\n"
                         );
    prog_lines.AddShader( GlSlFragmentShader,
                      #ifdef HAVE_GLES_2
                          "precision mediump float;\n"
                      #endif // HAVE_GLES_2
                         "varying vec4 v_color;\n"
                         "void main() {\n"
                         "  gl_FragColor = v_color;\n"
                         "}\n"
                         );
    prog_lines.BindPangolinDefaultAttribLocationsAndLink();

    prog_text.AddShader( GlSlVertexShader,
                         "attribute vec2 a_position;\n"
                         "attribute vec2 a_texcoord;\n"
                         "uniform vec4 u_color;\n"
                         "uniform vec2 u_scale;\n"
                         "uniform vec2 u_offset;\n"
                         "varying vec4 v_color;\n"
                         "varying vec2 v_texcoord;\n"
                         "void main() {\n"
                         "    gl_Position = vec4(u_scale * (a_position + u_offset),0,1);\n"
                         "    v_color = u_color;\n"
                         "    v_texcoord = a_texcoord;\n"
                         "}\n"
                         );
    prog_text.AddShader( GlSlFragmentShader,
                     #ifdef HAVE_GLES_2
                         "precision mediump float;\n"
                     #endif // HAVE_GLES_2
                         "varying vec4 v_color;\n"
                         "varying vec2 v_texcoord;\n"
                         "uniform sampler2D u_texture;\n"
                         "void main() {\n"
                         "  gl_FragColor = v_color;\n"
                         "  gl_FragColor.a *= texture2D(u_texture, v_texcoord).a;\n"
                         "}\n"
                         );
    prog_text.BindPangolinDefaultAttribLocationsAndLink();

    const size_t RESERVED_SIZE = 100;

    // Setup default PlotSeries
    plotseries.reserve(RESERVED_SIZE);
    for(unsigned int i=0; i< 10; ++i) {
        std::ostringstream oss;
        oss << "$" << i;
        plotseries.push_back( PlotSeries() );
        plotseries.back().CreatePlot( "$i", oss.str(),
            colour_wheel.GetUniqueColour(),
            i < log->Labels().size() ? log->Labels()[i] : oss.str()
        );
    }

    // Setup test PlotMarkers
    plotmarkers.reserve(RESERVED_SIZE);
//    plotmarkers.push_back( Marker( Marker::Vertical, 10, Marker::GreaterThan, Colour(1,0,0,0.2)) );
//    plotmarkers.push_back( Marker( Marker::Horizontal, 1, Marker::LessThan, Colour(0,1,0,0.2)) );

    // Setup test implicit plots.
    plotimplicits.reserve(RESERVED_SIZE);
//    plotimplicits.push_back( PlotImplicit() );
//    plotimplicits.back().CreateInequality("x+y <= 150.0", colour_wheel.GetUniqueColour().WithAlpha(0.2) );
//    plotimplicits.push_back( PlotImplicit() );
//    plotimplicits.back().CreateInequality("x+2.0*y <= 170.0", colour_wheel.GetUniqueColour().WithAlpha(0.2) );
//    plotimplicits.push_back( PlotImplicit() );
//    plotimplicits.back().CreateInequality("3.0*y <= 180.0", colour_wheel.GetUniqueColour().WithAlpha(0.2) );

    // Setup texture spectogram style plots
    // ...

}