示例#1
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_stuff_and_crossfade();

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

  if (!useAVISound)
    update_polled_stuff_and_crossfade();

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

  OAFilterState filterState = State_Running;
  while ((filterState != State_Stopped) && (!want_exit))
  {
    while (timerloop == 0) Sleep(1);
    timerloop = 0;

    if (!useAVISound)
      update_polled_stuff_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;
}
示例#2
0
//Perform frame by frame updates and blits. Set the stream
//state to STOP if there are no more frames to update.
void RenderToSurface(BITMAP *vscreen) {
    //update each frame
    if (g_pSample->Update(0, NULL, NULL, 0) != S_OK) {
        g_bAppactive = FALSE;
        g_pMMStream->SetState(STREAMSTATE_STOP);
    }
    else {
        g_bAppactive = TRUE;
        acquire_screen();
        // Because vscreen is a DX Video Bitmap, it can be stretched
        // onto the screen (also a Video Bmp) but not onto a memory
        // bitmap (which is what "screen" is when using gfx filters)
        if (is_video_bitmap(screen))
        {
            stretch_blit(vscreen, screen, 0, 0, vscreen->w, vscreen->h,
                         screen->w / 2 - newWidth / 2,
                         screen->h / 2 - newHeight / 2,
                         newWidth, newHeight);
        }
        else
        {
            blit(vscreen, vsMemory, 0, 0, 0, 0, vscreen->w, vscreen->h);
            stretch_blit(vsMemory, screen, 0, 0, vscreen->w, vscreen->h,
                         screen->w / 2 - newWidth / 2,
                         screen->h / 2 - newHeight / 2,
                         newWidth, newHeight);
        }
        release_screen();

        render_to_screen(screen, 0, 0);
        // if we're not playing AVI sound, poll the game MP3
        if (!useSound)
            update_polled_stuff_and_crossfade();
    }
}
示例#3
0
int theora_playing_callback(BITMAP *theoraBuffer)
{
  if (theoraBuffer == NULL)
  {
    // No video, only sound
    return check_if_user_input_should_cancel_video();
  }

  int drawAtX = 0, drawAtY = 0;
  if (fli_ddb == NULL)
  {
    fli_ddb = gfxDriver->CreateDDBFromBitmap(theoraBuffer, false, true);
  }
  if (stretch_flc) 
  {
    drawAtX = scrnwid / 2 - fliTargetWidth / 2;
    drawAtY = scrnhit / 2 - fliTargetHeight / 2;
    if (!gfxDriver->HasAcceleratedStretchAndFlip())
    {
      stretch_blit(theoraBuffer, fli_target, 0, 0, BMP_W(theoraBuffer), BMP_H(theoraBuffer), 
                   drawAtX, drawAtY, fliTargetWidth, fliTargetHeight);
      gfxDriver->UpdateDDBFromBitmap(fli_ddb, fli_target, false);
      drawAtX = 0;
      drawAtY = 0;
    }
    else
    {
      gfxDriver->UpdateDDBFromBitmap(fli_ddb, theoraBuffer, false);
      fli_ddb->SetStretch(fliTargetWidth, fliTargetHeight);
    }
  }
  else
  {
    gfxDriver->UpdateDDBFromBitmap(fli_ddb, theoraBuffer, false);
    drawAtX = scrnwid / 2 - BMP_W(theoraBuffer) / 2;
    drawAtY = scrnhit / 2 - BMP_H(theoraBuffer) / 2;
  }

  gfxDriver->DrawSprite(drawAtX, drawAtY, fli_ddb);
  render_to_screen(virtual_screen, 0, 0);
  update_polled_stuff_and_crossfade ();

  return check_if_user_input_should_cancel_video();
}
示例#4
0
int __cdecl fli_callback() {
#else
int fli_callback(...) {
#endif
  block usebuf = fli_buffer;

  update_polled_stuff_and_crossfade ();

  if (game.color_depth > 1) {
    blit(fli_buffer,hicol_buf,0,0,0,0,fliwidth,fliheight);
    usebuf=hicol_buf;
  }
  if (stretch_flc == 0)
    blit(usebuf, fli_target, 0,0,scrnwid/2-fliwidth/2,scrnhit/2-fliheight/2,scrnwid,scrnhit);
  else 
    stretch_blit(usebuf, fli_target, 0,0,fliwidth,fliheight,0,0,scrnwid,scrnhit);

  gfxDriver->UpdateDDBFromBitmap(fli_ddb, fli_target, false);
  gfxDriver->DrawSprite(0, 0, fli_ddb);
  render_to_screen(fli_target, 0, 0);

  return check_if_user_input_should_cancel_video();
}