AnimPageAVI.cpp
资源名称:gloop.zip [点击查看]
上传用户:shxiangxiu
上传日期:2007-01-03
资源大小:1101k
文件大小:8k
源码类别:
OpenGL
开发平台:
Visual C++
- /////////////////////////////////////////////////////////////////////////////
- // AnimPageAVI.cpp : implementation file
- //
- // glOOP (OpenGL Object Oriented Programming library)
- // Copyright (c) Craig Fahrnbach 1997, 1998
- //
- // OpenGL is a registered trademark of Silicon Graphics
- //
- //
- // This program is provided for educational and personal use only and
- // is provided without guarantee or warrantee expressed or implied.
- //
- // Commercial use is strickly prohibited without written permission
- // from ImageWare Development.
- //
- // This program is -not- in the public domain.
- //
- /////////////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "glOOP.h"
- #include "AnimationDialog.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char BASED_CODE THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CAnimPageAVI
- IMPLEMENT_DYNCREATE(CAnimPageAVI, CPropertyPage)
- /////////////////////////////////////////////////////////////////////////////
- // CAnimPageAVI dialog construction
- CAnimPageAVI::CAnimPageAVI()
- : CPropertyPage(CAnimPageAVI::IDD)
- {
- //{{AFX_DATA_INIT(CAnimPageAVI)
- m_iEnableAudio = 0;
- m_iPlayContinuous = -1;
- m_szName = _T("");
- //}}AFX_DATA_INIT
- }
- /////////////////////////////////////////////////////////////////////////////
- // CAnimPageAVI Destructor
- CAnimPageAVI::~CAnimPageAVI()
- {
- }
- void CAnimPageAVI::DoDataExchange(CDataExchange* pDX)
- {
- CPropertyPage::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CAnimPageAVI)
- DDX_Control(pDX, IDC_SLIDER_VOLUMN, m_SliderVolumn);
- DDX_Control(pDX, IDC_SLIDER_PITCH, m_SliderPitch);
- DDX_Radio(pDX, IDC_RADIO_ENABLE_AUDIO, m_iEnableAudio);
- DDX_Radio(pDX, IDC_RADIO_PLAY_CONTINUOUS, m_iPlayContinuous);
- DDX_Text(pDX, IDC_TEXTURE_FILENAME, m_szName);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CAnimPageAVI, CPropertyPage)
- //{{AFX_MSG_MAP(CAnimPageAVI)
- ON_BN_CLICKED(IDC_RADIO_ENABLE_AUDIO, OnRadioEnableAudio)
- ON_BN_CLICKED(IDC_RADIO_PLAY_CONTINUOUS, OnRadioPlayContinuous)
- ON_WM_VSCROLL()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CAnimPageAVI message handlers
- BOOL CAnimPageAVI::OnInitDialog()
- {
- // Let the base class do the default work
- CPropertyPage::OnInitDialog();
- // Set our local values to the Objects' values
- if(m_pAnimation)
- {
- m_szName = m_pAnimation->m_pAviMovie->m_szFileName;
- if(m_pAnimation->m_pAviMovie->m_bPlayContinuous)
- m_iPlayContinuous = 0;
- if(!m_pAnimation->m_pAviMovie->m_bEnableAudio)
- // Turn off the radio button
- m_iEnableAudio = -1;
- if(!m_pAnimation->m_pAviMovie->m_pAudioPlayer)
- {
- // Audio device is not open so disable the associated windows
- // Disable radio button
- GetDlgItem(IDC_RADIO_ENABLE_AUDIO)->EnableWindow(FALSE);
- // Disable slider controls
- GetDlgItem(IDC_SLIDER_PITCH)->EnableWindow(FALSE);
- GetDlgItem(IDC_SLIDER_VOLUMN)->EnableWindow(FALSE);
- // Turn off the radio button
- m_iEnableAudio = -1;
- }
- else
- {
- DWORD wResult; // error code
- DWORD dwVolumn;
- DWORD dwPitch;
- CAudioPlayer* pAudioPlayer = m_pAnimation->m_pAviMovie->m_pAudioPlayer;
- // Set the range of the volumn slider
- // (multiply return value by 3276.75 for a range of 0 to 65535)
- m_SliderVolumn.SetRange(0, 20); // Vertical slider: 0 = TOP
- // Set the range of the pitch slider
- // (multiply return value by 0.1 for a range of 0.0 to 2.0)
- m_SliderPitch.SetRange(0, 20); // Vertical slider: 0 = TOP
- wResult = pAudioPlayer->GetVolumn(&dwVolumn);
- if(!wResult)
- {
- UINT uLeftChannel; // Left channel volumn setting
- UINT uRightChannel; // Right channel volumn setting
- float fPos; // slider position (float)
- // Left channel is the lower 16 bits
- uLeftChannel = (UINT)dwVolumn & 0x0000FFFF;
- // Right channel is the upper 16 bits
- uRightChannel = (UINT)(dwVolumn & 0xFFFF0000) >> 16;
- // Since we only display volumn settings for both channesl
- // we will use the left channel setting
- fPos = uLeftChannel/3276.75f;
- m_SliderVolumn.SetPos((int)(20-fPos));
- }
- wResult = pAudioPlayer->GetPitch(&dwPitch);
- if(!wResult)
- {
- int iValue; // Signed integer value of the pitch
- float fValue; // Fractional portion of the pitch
- iValue = dwPitch >> 16; // Get the upper 16 bits
- fValue = (float)((dwPitch & 0x0000FFFF)/65535)*10;
- int pos = (iValue*10)+(int)fValue;
- m_SliderVolumn.SetPos(pos);
- }
- else
- // Pitch function not supported by device :(
- GetDlgItem(IDC_SLIDER_PITCH)->EnableWindow(FALSE);
- }
- }
- // Dialog box is being initialized (FALSE)
- // or data is being retrieved (TRUE).
- UpdateData(FALSE);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void CAnimPageAVI::OnOK()
- {
- // Dialog box is being initialized (FALSE)
- // or data is being retrieved (TRUE).
- UpdateData(TRUE);
- // Set our Objects' values to the local values
- if(m_pAnimation)
- {
- }
- CPropertyPage::OnOK();
- }
- void CAnimPageAVI::OnRadioEnableAudio()
- {
- if(m_pAnimation)
- {
- // Toggle the radio selection
- if(m_pAnimation->m_pAviMovie->m_bEnableAudio)
- {
- m_pAnimation->m_pAviMovie->m_bEnableAudio = FALSE;
- m_iEnableAudio = -1;
- // Stop the AVI audio track
- m_pAnimation->m_pAviMovie->StopAudio();
- }
- else
- {
- m_pAnimation->m_pAviMovie->m_bEnableAudio = TRUE;
- m_iEnableAudio = 0;
- // Ensure that the 'StartAudio' flag is set. This
- // will allow the audio track to synch with the
- // video track.
- m_pAnimation->m_pAviMovie->m_bStartAudio = TRUE;
- }
- // Initialize the Dialog Data (forces DoDataExchange)
- UpdateData(FALSE);
- }
- }
- void CAnimPageAVI::OnRadioPlayContinuous()
- {
- if(m_pAnimation)
- {
- // Toggle the radio selection
- if(m_pAnimation->m_pAviMovie->m_bPlayContinuous)
- {
- m_pAnimation->m_pAviMovie->m_bPlayContinuous = FALSE;
- m_iPlayContinuous = -1;
- }
- else
- {
- m_pAnimation->m_pAviMovie->m_bPlayContinuous = TRUE;
- m_iPlayContinuous = 0;
- }
- // Initialize the Dialog Data (forces DoDataExchange)
- UpdateData(FALSE);
- }
- }
- void CAnimPageAVI::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
- {
- CWnd* pWnd;
- // Determine which CScrollBar has send the OnVScroll message
- pWnd = GetDlgItem(IDC_SLIDER_VOLUMN);
- if(pWnd)
- {
- if(pWnd == pScrollBar)
- ProcessVolumnSlider(nSBCode, nPos, pScrollBar);
- }
- pWnd = GetDlgItem(IDC_SLIDER_PITCH);
- if(pWnd)
- {
- if(pWnd == pScrollBar)
- ProcessPitchSlider(nSBCode, nPos, pScrollBar);
- }
- // Call the base class procedure
- CPropertyPage::OnVScroll(nSBCode, nPos, pScrollBar);
- }
- void CAnimPageAVI::ProcessVolumnSlider(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
- {
- CAudioPlayer* pAudioPlayer; // Audio player pointer
- UINT uLeftChannel; // Left channel volumn setting
- UINT uRightChannel; // Right channel volumn setting
- DWORD dwVolumn;
- // Get a pointer to our Audio player
- pAudioPlayer = m_pAnimation->m_pAviMovie->m_pAudioPlayer;
- if(!pAudioPlayer)
- return;
- // Process the slider commands
- if(nSBCode == SB_LINEUP) // nSBCode = 0
- {
- }
- if(nSBCode == SB_LINEDOWN) // nSBCode = 1
- {
- }
- if(nSBCode == SB_PAGEUP) // nSBCode = 2
- {
- }
- if(nSBCode == SB_PAGEDOWN) // nSBCode = 3
- {
- }
- if(nSBCode == SB_THUMBPOSITION) // nSBCode = 4
- {
- }
- if(nSBCode == SB_THUMBTRACK) // nSBCode = 5
- {
- // Left channel is the lower 16 bits
- uLeftChannel = (UINT)((20-nPos)*3276.75f);
- // Right channel is the upper 16 bits
- uRightChannel = uLeftChannel << 16;
- dwVolumn = uLeftChannel+uRightChannel;
- pAudioPlayer->SetVolumn(dwVolumn);
- }
- }
- void CAnimPageAVI::ProcessPitchSlider(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
- {
- CAudioPlayer* pAudioPlayer; // Audio player pointer
- // Get a pointer to our Audio player
- pAudioPlayer = m_pAnimation->m_pAviMovie->m_pAudioPlayer;
- if(!pAudioPlayer)
- return;
- // Process the slider commands
- if(nSBCode == SB_LINEUP) // nSBCode = 0
- {
- }
- if(nSBCode == SB_LINEDOWN) // nSBCode = 1
- {
- }
- if(nSBCode == SB_PAGEUP) // nSBCode = 2
- {
- }
- if(nSBCode == SB_PAGEDOWN) // nSBCode = 3
- {
- }
- if(nSBCode == SB_THUMBPOSITION) // nSBCode = 4
- {
- }
- if(nSBCode == SB_THUMBTRACK) // nSBCode = 5
- {
- }
- }