Exemplo n.º 1
0
void IAGSEngine::PollSystem () {
  
  NEXT_ITERATION();
  domouse(DOMOUSE_NOCURSOR);
  update_polled_stuff(true);
  int mbut = mgetbutton();
  if (mbut > NONE)
    pl_run_plugin_hooks (AGSE_MOUSECLICK, mbut);

  if (rec_kbhit()) {
    int kp = rec_getch();
    if (kp == 0) kp = rec_getch()+300;
    pl_run_plugin_hooks (AGSE_KEYPRESS, kp);
  }

}
Exemplo n.º 2
0
int dxmedia_play_video_3d(const char* filename, IDirect3DDevice9 *device, bool useAVISound, int canskip, int stretch) 
{
  HWND gameWindow = win_get_window();

  if (graph == NULL)
  {
    graph = new CVMR9Graph(gameWindow, device);
  }

  if (!useAVISound)
    update_polled_audio_and_crossfade();

  if (!graph->SetMediaFile(filename, useAVISound))
  {
    dxmedia_shutdown_3d();
    return -1;
  }
  graph->SetLayerZOrder(0, 0);

  if (!useAVISound)
    update_polled_audio_and_crossfade();

  if (!graph->PlayGraph())
  {
    dxmedia_shutdown_3d();
    return -1;
  }

  OAFilterState filterState = State_Running;
  while ((filterState != State_Stopped) && (!want_exit))
  {
    while (timerloop == 0)
      platform->Delay(1);
    timerloop = 0;

    if (!useAVISound)
      update_polled_audio_and_crossfade();

    next_iteration();
    filterState = graph->GetState();

    if (rec_kbhit()) {
      int key = rec_getch();
      
      if ((canskip == 1) && (key == 27))
        break;
      if (canskip >= 2)
        break;
    }
    if ((rec_mgetbutton() >= 0) && (canskip == 3))
      break;

    //device->Present(NULL, NULL, 0, NULL);
	}

  graph->StopGraph();

  dxmedia_shutdown_3d();
  return 0;
}
Exemplo n.º 3
0
int dxmedia_play_video(const char* filename, bool pUseSound, int canskip, int stretch) {
    HRESULT hr;

    useSound = pUseSound;
    ghWnd = win_get_window();

    CoInitialize(NULL);

    if (!useSound)
        update_polled_stuff();

    hr = RenderFileToMMStream(filename);
    if (FAILED(hr)) {
        ExitCode();
        CoUninitialize();
        return -1;
    }

    if (!useSound)
        update_polled_stuff();

    hr = InitRenderToSurface();
    if (FAILED(hr)) {
        ExitCode();
        CoUninitialize();
        return -1;
    }

    newWidth = vscreen->w;
    newHeight = vscreen->h;

    if ((stretch == 1) || (vscreen->w > screen->w) || (vscreen->h > screen->h)) {
        // If they want to stretch, or if it's bigger than the screen, then stretch
        float widthRatio = (float)vscreen->w / (float)screen->w;
        float heightRatio = (float)vscreen->h / (float)screen->h;

        if (widthRatio > heightRatio) {
            newWidth = vscreen->w / widthRatio;
            newHeight = vscreen->h / widthRatio;
        }
        else {
            newWidth = vscreen->w / heightRatio;
            newHeight = vscreen->h / heightRatio;
        }
    }

    //Now set the multimedia stream to RUN
    hr = g_pMMStream->SetState(STREAMSTATE_RUN);
    g_bAppactive = TRUE;

    if (FAILED(hr)) {
        sprintf(lastError, "Unable to play stream: 0x%08X", hr);
        ExitCode();
        CoUninitialize();
        destroy_bitmap (vscreen);
        return -1;
    }
    // in case we're not full screen, clear the background
    clear(screen);

    currentlyPlaying = true;

    gfxDriver->ClearDrawList();
    BITMAP *savedBackBuffer = gfxDriver->GetMemoryBackBuffer();
    gfxDriver->SetMemoryBackBuffer(screen);

    while ((g_bAppactive) && (!want_exit)) {

        while (currentlyPaused) ;

        next_iteration();
        RenderToSurface(vscreen);
        //Sleep(0);
        if (rec_kbhit()) {
            int key = rec_getch();

            if ((canskip == 1) && (key == 27))
                break;
            if (canskip >= 2)
                break;
        }
        if ((rec_mgetbutton() >= 0) && (canskip == 3))
            break;
    }

    dxmedia_abort_video();

    gfxDriver->SetMemoryBackBuffer(savedBackBuffer);

    return 0;
}