Beispiel #1
0
  void* nativeHandle() override {
#ifdef WIN32
    return reinterpret_cast<void*>(win_get_window());
#else
    return NULL;
#endif
  }
Beispiel #2
0
/* update_mouse_pointer:
 *  Worker function that updates the mouse pointer.
 */
static void update_mouse_pointer(int x, int y, int retrace)
{
   HDC hdc;
   HWND allegro_wnd = win_get_window();

   /* put the screen contents located at the new position into the frontbuffer */
   blit(gdi_screen, mouse_frontbuffer, x, y, 0, 0, mouse_frontbuffer->w, mouse_frontbuffer->h);

   /* draw the mouse pointer onto the frontbuffer */
   draw_sprite(mouse_frontbuffer, wgdi_mouse_sprite, 0, 0);

   hdc = GetDC(allegro_wnd);

   if (_color_depth == 8)
      set_palette_to_hdc(hdc, palette);

   if (retrace) {
      /* restore the screen contents located at the old position */
      blit_to_hdc(mouse_backbuffer, hdc, 0, 0, mouse_xpos, mouse_ypos, mouse_backbuffer->w, mouse_backbuffer->h);
   }

   /* blit the mouse pointer onto the screen */
   blit_to_hdc(mouse_frontbuffer, hdc, 0, 0, x, y, mouse_frontbuffer->w, mouse_frontbuffer->h);

   ReleaseDC(allegro_wnd, hdc);

   /* save the screen contents located at the new position into the backbuffer */
   blit(gdi_screen, mouse_backbuffer, x, y, 0, 0, mouse_backbuffer->w, mouse_backbuffer->h);

   /* save the new position */
   mouse_xpos = x;
   mouse_ypos = y;
}
Beispiel #3
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;
}
Beispiel #4
0
/* mouse_winapi_select_system_cursor:
 *  Select an OS native cursor
 */
static int mouse_winapi_select_system_cursor(int cursor)
{
   HCURSOR wc;
   HWND allegro_wnd = win_get_window();

   wc = NULL;
   switch(cursor) {
     case MOUSE_CURSOR_ARROW:
       wc = LoadCursor(NULL, IDC_ARROW);
       break;
     case MOUSE_CURSOR_BUSY:
       wc = LoadCursor(NULL, IDC_WAIT);
       break;
     case MOUSE_CURSOR_QUESTION:
       wc = LoadCursor(NULL, IDC_HELP);
       break;
     case MOUSE_CURSOR_EDIT:
       wc = LoadCursor(NULL, IDC_IBEAM);
       break;
#ifdef ALLEGRO4_WITH_EXTRA_CURSORS
     case MOUSE_CURSOR_CROSS:
       wc = LoadCursor(NULL, IDC_CROSS);
       break;
     case MOUSE_CURSOR_MOVE:
       wc = LoadCursor(NULL, IDC_SIZEALL);
       break;
     case MOUSE_CURSOR_LINK:
       wc = LoadCursor(NULL, IDC_HAND);
       break;
     case MOUSE_CURSOR_FORBIDDEN:
       wc = LoadCursor(NULL, IDC_NO);
       break;
     case MOUSE_CURSOR_SIZE_N:
     case MOUSE_CURSOR_SIZE_S:
     case MOUSE_CURSOR_SIZE_NS:
       wc = LoadCursor(NULL, IDC_SIZENS);
       break;
     case MOUSE_CURSOR_SIZE_E:
     case MOUSE_CURSOR_SIZE_W:
     case MOUSE_CURSOR_SIZE_WE:
       wc = LoadCursor(NULL, IDC_SIZEWE);
       break;
     case MOUSE_CURSOR_SIZE_NW:
     case MOUSE_CURSOR_SIZE_SE:
       wc = LoadCursor(NULL, IDC_SIZENWSE);
       break;
     case MOUSE_CURSOR_SIZE_NE:
     case MOUSE_CURSOR_SIZE_SW:
       wc = LoadCursor(NULL, IDC_SIZENESW);
       break;
#endif
     default:
       return 0;
   }

   _win_hcursor = wc;
   SetCursor(_win_hcursor);

   return cursor;
}
/* mouse_directx_select_system_cursor:
 *  Select an OS native cursor 
 */
static int mouse_directx_select_system_cursor (int cursor)
{
   HCURSOR wc;
   HWND allegro_wnd = win_get_window();
   
   wc = NULL;
   switch(cursor) {
      case MOUSE_CURSOR_ARROW:
         wc = LoadCursor(NULL, IDC_ARROW);
         break;
      case MOUSE_CURSOR_BUSY:
         wc = LoadCursor(NULL, IDC_WAIT);
         break;
      case MOUSE_CURSOR_QUESTION:
         wc = LoadCursor(NULL, IDC_HELP);
         break;
      case MOUSE_CURSOR_EDIT:
         wc = LoadCursor(NULL, IDC_IBEAM);
         break;
      default:
         return 0;
   }

   _win_hcursor = wc;
   SetCursor(_win_hcursor);
   PostMessage(allegro_wnd, WM_MOUSEMOVE, 0, 0);
   
   return cursor;
}
Beispiel #6
0
  bool isMaximized() const override {
#ifdef WIN32
    return (::GetWindowLong(win_get_window(), GWL_STYLE) & WS_MAXIMIZE ? true: false);
#else
    return false;
#endif
  }
Beispiel #7
0
/* sys_directx_set_window_title:
 *  Alters the application title.
 */
static void sys_directx_set_window_title(AL_CONST char *name)
{
    HWND allegro_wnd = win_get_window();

    do_uconvert(name, U_CURRENT, wnd_title, U_ASCII, WND_TITLE_SIZE);
    SetWindowText(allegro_wnd, wnd_title);
}
Beispiel #8
0
/* sys_directx_set_close_button_callback:
 *  Sets the close button callback function.
 */
static int sys_directx_set_close_button_callback(void (*proc)(void))
{
    DWORD class_style;
    HMENU sys_menu;
    HWND allegro_wnd = win_get_window();

    user_close_proc = proc;

    /* get the old class style */
    class_style = GetClassLong(allegro_wnd, GCL_STYLE);

    /* and the system menu handle */
    sys_menu = GetSystemMenu(allegro_wnd, FALSE);

    /* enable or disable the no_close_button flag and the close menu option */
    if (proc) {
        class_style &= ~CS_NOCLOSE;
        EnableMenuItem(sys_menu, SC_CLOSE, MF_BYCOMMAND | MF_ENABLED);
    }
    else {
        class_style |= CS_NOCLOSE;
        EnableMenuItem(sys_menu, SC_CLOSE, MF_BYCOMMAND | MF_GRAYED);
    }

    /* change the class to the new style */
    SetClassLong(allegro_wnd, GCL_STYLE, class_style);

    /* Redraw the whole window to display the changes of the button.
     * (we use this because UpdateWindow() only works for the client area)
     */
    RedrawWindow(allegro_wnd, NULL, NULL, RDW_FRAME | RDW_INVALIDATE | RDW_UPDATENOW);

    return 0;
}
Beispiel #9
0
void ui::clipboard::set_text(const char *text)
{
  lowlevel_set_clipboard_text(text);

#ifdef WIN32
  if (IsClipboardFormatAvailable(CF_UNICODETEXT)) {
    if (OpenClipboard(win_get_window())) {
      EmptyClipboard();

      if (!clipboard_text.empty()) {
        std::wstring wstr = base::from_utf8(clipboard_text);
        int len = wstr.size();

        HGLOBAL hglobal = GlobalAlloc(GMEM_MOVEABLE |
                                      GMEM_ZEROINIT, sizeof(WCHAR)*(len+1));

        LPWSTR lpstr = static_cast<LPWSTR>(GlobalLock(hglobal));
        std::copy(wstr.begin(), wstr.end(), lpstr);
        GlobalUnlock(hglobal);

        SetClipboardData(CF_UNICODETEXT, hglobal);
      }
      CloseClipboard();
    }
  }
#endif
}
Beispiel #10
0
void gui::clipboard::set_text(const char *text)
{
  lowlevel_set_clipboard_text(text);

#ifdef WIN32
  if (IsClipboardFormatAvailable(CF_TEXT)) {
    if (OpenClipboard(win_get_window())) {
      EmptyClipboard();

      if (!clipboard_text.empty()) {
        int len = clipboard_text.size();

        HGLOBAL hglobal = GlobalAlloc(GMEM_MOVEABLE |
                                      GMEM_ZEROINIT, sizeof(char)*(len+1));

        LPSTR lpstr = static_cast<LPSTR>(GlobalLock(hglobal));
        std::copy(clipboard_text.begin(), clipboard_text.end(), lpstr);
        GlobalUnlock(hglobal);

        SetClipboardData(CF_TEXT, hglobal);
      }
      CloseClipboard();
    }
  }
#endif
}
Beispiel #11
0
static void unsubclass_hwnd()
{
  HWND hwnd = win_get_window();

  // restore the old wndproc
  SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)base_wnd_proc);
  base_wnd_proc = NULL;
}
Beispiel #12
0
bool Alleg4Display::isMaximized() const
{
#ifdef _WIN32
  return (::GetWindowLong(win_get_window(), GWL_STYLE) & WS_MAXIMIZE ? true: false);
#else
  return false;
#endif
}
Beispiel #13
0
void* Alleg4Display::nativeHandle()
{
#ifdef _WIN32
  return reinterpret_cast<void*>(win_get_window());
#elif defined __APPLE__
  return get_osx_window();
#else
  return nullptr;
#endif
}
Beispiel #14
0
static void subclass_hwnd()
{
  HWND hwnd = win_get_window();

  // add the WS_EX_ACCEPTFILES
  SetWindowLong(hwnd, GWL_EXSTYLE,
                GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_ACCEPTFILES);

  // set the GWL_WNDPROC to globalWndProc
  base_wnd_proc = (wndproc_t)SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)ase_wnd_proc);
}
Beispiel #15
0
static void update_mouse_position()
{
  m_x[0] = JI_SCREEN_W * mouse_x / SCREEN_W;
  m_y[0] = JI_SCREEN_H * mouse_y / SCREEN_H;

  if (is_windowed_mode()) {
#ifdef ALLEGRO_WINDOWS
    // This help us (in windows) to get mouse feedback when we capture
    // the mouse but we are outside the window.
    POINT pt;
    RECT rc;

    if (GetCursorPos(&pt) && GetClientRect(win_get_window(), &rc)) {
      MapWindowPoints(win_get_window(), NULL, (LPPOINT)&rc, 2);

      if (!PtInRect(&rc, pt)) {
        // If the mouse is free we can hide the cursor putting the
        // mouse outside the screen (right-bottom corder).
        if (!Manager::getDefault()->getCapture()) {
          if (mouse_cursor) {
            m_x[0] = JI_SCREEN_W + mouse_cursor->getFocus().x;
            m_y[0] = JI_SCREEN_H + mouse_cursor->getFocus().y;
          }
        }
        // If the mouse is captured we can put it in the edges of the
        // screen.
        else {
          pt.x -= rc.left;
          pt.y -= rc.top;

          m_x[0] = JI_SCREEN_W * pt.x / SCREEN_W;
          m_y[0] = JI_SCREEN_H * pt.y / SCREEN_H;

          m_x[0] = MID(0, m_x[0], JI_SCREEN_W-1);
          m_y[0] = MID(0, m_y[0], JI_SCREEN_H-1);
        }
      }
    }
#endif
  }
}
Beispiel #16
0
/* key_dinput_handle_scancode: [input thread]
 *  Handles a single scancode.
 */
static void key_dinput_handle_scancode(unsigned char scancode, int pressed)
{
   HWND allegro_wnd = win_get_window();
   static int ignore_three_finger_flag = FALSE;
   /* ignore special Windows keys (alt+tab, alt+space, (ctrl|alt)+esc) */
   if (((scancode == DIK_TAB) && (_key_shifts & KB_ALT_FLAG))
       || ((scancode == DIK_SPACE) && (_key_shifts & KB_ALT_FLAG))
       || ((scancode == DIK_ESCAPE) && (_key_shifts & (KB_CTRL_FLAG | KB_ALT_FLAG))))
      return;

   /* alt+F4 triggers a WM_CLOSE under Windows */
   if ((scancode == DIK_F4) && (_key_shifts & KB_ALT_FLAG)) {
      if (pressed)
         PostMessage(allegro_wnd, WM_CLOSE, 0, 0);
      return;
   }

   /* Special case KEY_PAUSE as flip-flop key. */
   if (scancode == DIK_PAUSE) {
      if (!pressed)
         return;
      if (key[KEY_PAUSE])
         pressed = 0;
      else
         pressed = 1;
   }

   /* if not foreground, filter out press codes and handle only release codes */
   if (!wnd_sysmenu || !pressed) {
      /* three-finger salute for killing the program */
      if (three_finger_flag && (_key_shifts & KB_CTRL_FLAG) && (_key_shifts & KB_ALT_FLAG)) {
         if (scancode == 0x00) {
            /* when pressing CTRL-ALT-DEL, Windows launches CTRL-ALT-EVERYTHING */
            ignore_three_finger_flag = TRUE;
	 }
	 else if (!ignore_three_finger_flag && (scancode == DIK_END || scancode == DIK_NUMPAD1)) {
	    /* we can now safely assume the user hit CTRL-ALT-END as opposed to CTRL-ALT-DEL */
	    _TRACE(PREFIX_I "Terminating application\n");
	    abort();
	 }
	 else if (ignore_three_finger_flag && scancode == 0xff) {
	    /* Windows is finished with CTRL-ALT-EVERYTHING - lets return to normality */
	    ignore_three_finger_flag = FALSE;
	    _key_shifts = 0;
	 }
      }

      if (pressed)
         handle_key_press(scancode);
      else
         handle_key_release(scancode);
   }
}
/* mouse_set_syscursor: [window thread]
 *  Selects whatever system cursor we should display.
 */
int mouse_set_syscursor(void)
{
   HWND allegro_wnd = win_get_window();
   if ((mouse_dinput_device && _mouse_on) || (gfx_driver && !gfx_driver->windowed)) {
      SetCursor(_win_hcursor);
      /* Make sure the cursor is removed by the system. */
      PostMessage(allegro_wnd, WM_MOUSEMOVE, 0, 0);
   }
   else
      SetCursor(LoadCursor(NULL, IDC_ARROW));

   return 0;
}
Beispiel #18
0
/* sys_directx_message:
 *  Displays a message.
 */
static void sys_directx_message(AL_CONST char *msg)
{
    char *tmp1 = _AL_MALLOC_ATOMIC(ALLEGRO_MESSAGE_SIZE);
    char tmp2[WND_TITLE_SIZE*2];
    HWND allegro_wnd = win_get_window();

    while ((ugetc(msg) == '\r') || (ugetc(msg) == '\n'))
        msg += uwidth(msg);

    MessageBoxW(allegro_wnd,
                (unsigned short *)uconvert(msg, U_CURRENT, tmp1, U_UNICODE, ALLEGRO_MESSAGE_SIZE),
                (unsigned short *)uconvert(wnd_title, U_ASCII, tmp2, U_UNICODE, sizeof(tmp2)),
                MB_OK);

    _AL_FREE(tmp1);
}
Beispiel #19
0
/* sys_directx_restore_console_state:
 *  Restores console window size and position.
 */
static void sys_directx_restore_console_state(void)
{
    HWND allegro_wnd = win_get_window();
    /* unacquire input devices */
    wnd_schedule_proc(key_dinput_unacquire);
    wnd_schedule_proc(mouse_dinput_unacquire);
    wnd_schedule_proc(joystick_dinput_unacquire);

    /* reset switch mode */
    _win_reset_switch_mode();

    /* re-size and hide window */
    SetWindowPos(allegro_wnd, HWND_TOP, wnd_rect.left, wnd_rect.top,
                 wnd_rect.right - wnd_rect.left, wnd_rect.bottom - wnd_rect.top,
                 SWP_NOCOPYBITS);
    ShowWindow(allegro_wnd, SW_SHOW);
}
Beispiel #20
0
bool JamulSoundInit(HINSTANCE hInst,const char *wndName, int numBuffers)
{
	int i;
	
    // Used to have to make another window, now we just steal Allegro's
    dsoundHwnd = win_get_window();

	if(!dsoundHwnd)
		return FALSE;

	if(DirectSoundCreate(NULL,&dsound,NULL)!=DS_OK)
		return FALSE;
	if(dsound->SetCooperativeLevel(dsoundHwnd, DSSCL_NORMAL)!=DS_OK)
	{
		dsound->Release();
		return FALSE;
	}
	dsoundBufferCount=numBuffers;
	soundbuf=(soundbuf_t*)calloc(sizeof(soundbuf_t)*(numBuffers+MAX_SOUNDS_AT_ONCE),1);
	if(soundbuf==NULL)
	{
		dsound->Release();
		return FALSE;
	}
	soundHandle=(int *)malloc(sizeof(int)*numBuffers);
	if(soundHandle==NULL)
	{
		dsound->Release();
		free(soundbuf);
		return FALSE;
	}
	for(i=0;i<numBuffers;i++)
		soundHandle[i]=-1;	// start them all empty

	nextOpenBuffer=0;

	for(i=0;i<MAX_SOUNDS_AT_ONCE;i++)
	{
		playBuffer[i].soundNum=-1;
		playBuffer[i].dsHandle=-1;
		playBuffer[i].flags=0;
	}
	return TRUE;
}
Beispiel #21
0
const char* gui::clipboard::get_text()
{
#ifdef WIN32
  if (IsClipboardFormatAvailable(CF_TEXT)) {
    if (OpenClipboard(win_get_window())) {
      HGLOBAL hglobal = GetClipboardData(CF_TEXT);
      if (hglobal != NULL) {
        LPSTR lpstr = static_cast<LPSTR>(GlobalLock(hglobal));
        if (lpstr != NULL) {
          lowlevel_set_clipboard_text(lpstr);
          GlobalUnlock(hglobal);
        }
      }
      CloseClipboard();
    }
  }
#endif

  return clipboard_text.c_str();
}
Beispiel #22
0
/* gfx_gdi_hide_mouse:
 */
static void gfx_gdi_hide_mouse(void)
{
   HDC hdc;
   HWND allegro_wnd = win_get_window();

   if (!mouse_on)
      return; 

   hdc = GetDC(allegro_wnd);

   if (_color_depth == 8)
      set_palette_to_hdc(hdc, palette);

   /* restore the screen contents located at the old position */
   blit_to_hdc(mouse_backbuffer, hdc, 0, 0, mouse_xpos, mouse_ypos, mouse_backbuffer->w, mouse_backbuffer->h);

   ReleaseDC(allegro_wnd, hdc);

   mouse_on = FALSE;
}
/* mouse_dinput_grab: [window thread]
 *  Grabs the mouse device.
 */
int mouse_dinput_grab(void)
{
   HRESULT hr;
   DWORD level;
   HWND allegro_wnd = win_get_window();

   if (mouse_dinput_device) {
      /* necessary in order to set the cooperative level */
      mouse_dinput_unacquire();

      if (gfx_driver && !gfx_driver->windowed) {
         level = DISCL_FOREGROUND | DISCL_EXCLUSIVE;
         _TRACE(PREFIX_I "foreground exclusive cooperative level requested for mouse\n");
      }
      else {
         level = DISCL_FOREGROUND | DISCL_NONEXCLUSIVE;
         _TRACE(PREFIX_I "foreground non-exclusive cooperative level requested for mouse\n");
      }

      /* set cooperative level */
      hr = IDirectInputDevice_SetCooperativeLevel(mouse_dinput_device, allegro_wnd, level);
      if (FAILED(hr)) {
         _TRACE(PREFIX_E "set cooperative level failed: %s\n", dinput_err_str(hr));
         return -1;
      }

      mouse_dinput_acquire();

      /* update the system cursor */
      mouse_set_syscursor();

      return 0;
   }
   else {
      /* update the system cursor */
      mouse_set_syscursor();

      return -1;
   }
}
Beispiel #24
0
//Enable OpenGL 2.0 Context
void CreateGLContext()
{
	PIXELFORMATDESCRIPTOR pfd;
	int iFormat;
	// Get the device context (DC)
	hDC = GetDC(win_get_window());
	// Set the pixel format for the DC
	ZeroMemory(&pfd, sizeof(pfd));
	pfd.nSize = sizeof(pfd);
	pfd.nVersion = 1;
	pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
	pfd.iPixelType = PFD_TYPE_RGBA;
	pfd.cColorBits = 24;
	pfd.cDepthBits = 16;
	pfd.iLayerType = PFD_MAIN_PLANE;
	iFormat = ChoosePixelFormat(hDC, &pfd);
	SetPixelFormat(hDC, iFormat, &pfd);

	// Create and enable the render context (RC)
	hRC = wglCreateContext(hDC);
	wglMakeCurrent(hDC, hRC);
}
Beispiel #25
0
/* wnd_set_video_mode:
 *  Called by window thread to set a gfx mode; this is needed because DirectDraw can only
 *  change the mode in the thread that handles the window.
 */
static int wnd_set_video_mode(void)
{
   HRESULT hr;
   HWND allegro_wnd = win_get_window();

   /* set the cooperative level to allow fullscreen access */
   hr = IDirectDraw2_SetCooperativeLevel(directdraw, allegro_wnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
   if (FAILED(hr)) {
      _TRACE(PREFIX_E "SetCooperativeLevel() failed (%x)\n", hr);
      return -1;
   }

   /* switch to fullscreen mode */
   hr = IDirectDraw2_SetDisplayMode(directdraw, _wnd_width, _wnd_height, _wnd_depth,
                                                _wnd_refresh_rate, _wnd_flags);
   if (FAILED(hr)) {
      _TRACE(PREFIX_E "SetDisplayMode(%u, %u, %u, %u, %u) failed (%x)\n", _wnd_width, _wnd_height, _wnd_depth,
                                                                 _wnd_refresh_rate, _wnd_flags, hr);
      return -1;
   }

   return 0;
}
Beispiel #26
0
/* gdi_update_window:
 *  Updates the window.
 */
static void gdi_update_window(RECT *rect)
{
   HDC hdc;
   HWND allegro_wnd = win_get_window();

   _enter_gfx_critical();

   if (!gdi_screen) {
      _exit_gfx_critical();
      return;
   }

   hdc = GetDC(allegro_wnd);

   if (_color_depth == 8)
      set_palette_to_hdc(hdc, palette);

   blit_to_hdc(gdi_screen, hdc, rect->left, rect->top, rect->left, rect->top,
               rect->right - rect->left, rect->bottom - rect->top);

   ReleaseDC(allegro_wnd, hdc);

   _exit_gfx_critical();
}
Beispiel #27
0
void Alleg4Display::maximize()
{
#ifdef _WIN32
  ::ShowWindow(win_get_window(), SW_MAXIMIZE);
#endif
}
Beispiel #28
0
  void maximize() override {
#ifdef WIN32
    ::ShowWindow(win_get_window(), SW_MAXIMIZE);
#endif
  }
Beispiel #29
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;
}
Beispiel #30
0
/* sys_directx_save_console_state:
 *  Saves console window size and position.
 */
static void sys_directx_save_console_state(void)
{
    HWND allegro_wnd = win_get_window();
    GetWindowRect(allegro_wnd, &wnd_rect);
}