コード例 #1
0
ファイル: proxy_win32.cpp プロジェクト: dtozik/GHL
bool func_2(const char* event_name, const GHL::Byte* param_0, const GHL::ULong32 param_1)
{
    if (std::strcmp("platform:make_screen_shoot", event_name) == 0)
    {
        GHL::VFS* fs = GHL_CreateVFS();
        GHL::DataStream* ds = fs->OpenFile("e:/test.jpg", GHL::FILE_WRITE);
        ds->Write(param_0, param_1);
        ds->Release();
        GHL_DestroyVFS(fs);
        return true;
    }

    char buf[80];
    sprintf(buf, "call event \"%s\" not implement.", event_name);
    LOG_INFO("buf");
    return false;
}
コード例 #2
0
GHL_API int GHL_CALL GHL_StartApplication( GHL::Application* app , int /*argc*/, char** /*argv*/) {
    
    g_application = app;
    
    LOG_INFO(  "start" );
    SDL_Init(SDL_INIT_VIDEO);


    GHL::VFS* vfs = GHL_CreateVFS();


    g_application->SetVFS(vfs);

    SystemSDL system;
    g_application->SetSystem(&system);

    {
        GHL::Event e;
        e.type = GHL::EVENT_TYPE_APP_STARTED;
        g_application->OnEvent(&e);
    }

    GHL::Settings settings;
    settings.width = 800;
    settings.height = 600;
    settings.depth = false;
    app->FillSettings(&settings);

    GHL::ImageDecoderImpl image_decoder;
    g_application->SetImageDecoder(&image_decoder);

    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
    if (settings.depth) {
        SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
        SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
    }
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
    
    g_window = SDL_CreateWindow(
        "GHL", 0, 0, settings.width, settings.height, 
        SDL_WINDOW_OPENGL);

    SDL_GLContext glcontext = SDL_GL_CreateContext(g_window);

    g_height = settings.height;

    g_render = GHL_CreateRenderOpenGL(settings.width,settings.height,settings.depth);
    if ( g_render && g_application ) {
        g_application->SetRender(g_render);
        g_application->Load();
    } else {
         LOG_ERROR(  "not started" );
    }

    g_last_time = SDL_GetTicks();

    g_done = false;

#ifdef GHL_PLATFORM_EMSCRIPTEN
    emscripten_set_main_loop_arg((em_arg_callback_func)loop_iteration, g_window, 0, 1);
#else
    while (!g_done) {
        loop_iteration(g_window);
    }
#endif

    LOG_INFO(  "done" );
    SDL_GL_DeleteContext(glcontext);  
    // Cleanup
   
    GHL_DestroyVFS(vfs);
    SDL_Quit();

    return 0;
}