コード例 #1
0
ファイル: sosi2osm.cpp プロジェクト: Gnonthgol/sosi2osm
int main(int argc, char** args) {
    if (argc < 3 || argc > 4) {
        usage();
        return 1;
    }
    
    execname = args[0];
    char* input_filename = args[1];
    char* output_filename = "-";
    if (argc > 3) output_filename = args[3];
    
    FILE* output;
    if (strcmp(output_filename, "-") == 0)
        output = stdout;
    else
        output = fopen(output_filename, "w");
    if (output == NULL) {
        fprintf(stderr, "Could not open file for output '%s'\n", output_filename);
        return 1;
    }
    
    loadLua(args[2]);
    
    if (!openSOSI(input_filename)) {
        closeSOSI();
        return 1;
    }
    
    fprintf(output, "<?xml version=\"1.0\"?>\n"
        "<osm version=\"0.6\" upload=\"false\" generator=\"sosi2osm\">\n");
    
    while (nextSOSIObject()) {
        short type = getSOSIType();
        switch(type) {
        case L_HODE:
            handleHead();
            break;
        case L_FLATE:
            outputRelation(output);
            break;
        case L_PUNKT:
        case L_SYMBOL:
        case L_TEKST:
            outputNode(output);
            break;
        case L_KURVE:
        case L_LINJE:
        case L_BUEP:
            outputWay(output);
            break;
        }
    }
    
    fprintf(output, "</osm>\n");
    
    closeSOSI();
    fclose(output);
    
    return 0;
}
コード例 #2
0
ファイル: embedded_game.cpp プロジェクト: Aitchwing/CorsixTH
void EmbeddedGamePanel::_onPaint(wxPaintEvent& evt)
{
    wxPaintDC dc(this);
    m_pGLContext->SetCurrent(*m_pGLCanvas);

    if(m_L == NULL)
    {
        // Its rather hacky to be loading the Lua side of things from within
        // the paint handler, but Lua needs an OpenGL context to be active, and
        // we cannot give it one during the EmbeddedGamePanel constructor.
        loadLua();
    }

    // Update the OpenGL projection matrix and Lua window size settings to keep
    // a 1:1 mapping between world space and screen space
    const wxSize szClient = GetClientSize();
    glViewport(0, 0, szClient.x, szClient.y);
    GLdouble fWidth = (GLdouble)szClient.x;
    GLdouble fHeight = (GLdouble)szClient.y;
    THRenderTarget::setGLProjection(fWidth, fHeight);
    if(m_L)
    {
        lua_getglobal(m_L, "TheApp");
        if(lua_isnil(m_L, -1))
            lua_pop(m_L, 1);
        else
        {
            lua_getfield(m_L, -1, "config");
            lua_pushinteger(m_L, szClient.x);
            lua_setfield(m_L, -2, "width");
            lua_pushinteger(m_L, szClient.y);
            lua_setfield(m_L, -2, "height");
            lua_pop(m_L, 2);
        }
    }

    // Do the actual painting
    if(m_Lthread)
    {
        lua_State *L = lua_tothread(m_Lthread, 1);
        if(L == NULL)
        {
            for(int i = 1; i <= lua_gettop(m_L); ++i)
            {
                wxPrintf("m_L stack %i: %s\n", i, lua_typename(m_L, lua_type(m_L, i)));
            }
            for(int i = 1; i <= lua_gettop(m_Lthread); ++i)
            {
                wxPrintf("m_Lthread stack %i: %s\n", i, lua_typename(m_Lthread, lua_type(m_Lthread, i)));
            }
        }
        lua_pushliteral(L, "frame");
        _resume(L, 1, 0);
    }
}