class CBIKMaterial
{
public:
CBIKMaterial();
~CBIKMaterial(); bool Init(const char *pFileName);
void Shutdown(void);
bool Update(void);
int GetTexture(void);
void GetFrameSize(int *pWidth, int *pHeight);
int GetFrameRate(void);
int GetFrameCount(void);
void SetFrame(float flFrame);
void SetLoop(bool state); private:
void CreateProceduralTexture(void);
void DestroyProceduralTexture(void); int m_Texture; HBINK m_pHBINK; U8 *m_pBuffer;
U32 m_nBufferSize; int m_nBIKWidth;
int m_nBIKHeight; int m_nFrameRate;
int m_nFrameCount; bool m_bLoop; HBINKTRACK m_hTrack; U8 *m_pSampleData;
U32 m_nSampleSize; public:
float *m_pWaveData;
U32 m_nWaveSize;
}; CBIKMaterial::CBIKMaterial()
{
m_pHBINK = NULL;
} CBIKMaterial::~CBIKMaterial()
{
} bool CBIKMaterial::Init(const char *pFileName)
{
m_pHBINK = BinkOpen(pFileName, BINKSNDTRACK); if (!m_pHBINK)
{
m_nBIKWidth = ;
m_nBIKHeight = ;
m_nFrameRate = ;
m_nFrameCount = ; return false;
} m_nBIKWidth = m_pHBINK->Width;
m_nBIKHeight = m_pHBINK->Height; m_nFrameRate = (int)((float)m_pHBINK->FrameRate / (float)m_pHBINK->FrameRateDiv);
m_nFrameCount = m_pHBINK->Frames; m_nBufferSize = m_nBIKWidth * m_nBIKHeight * ; // RGB(A) m_pBuffer = new U8[m_nBufferSize];
memset(m_pBuffer, , m_nBufferSize); CreateProceduralTexture(); if (m_pHBINK->NumTracks)
{
m_hTrack = BinkOpenTrack(m_pHBINK, ); BINKTRACK *track = (BINKTRACK *)m_hTrack; m_nSampleSize = track->MaxSize;
m_pSampleData = new U8[m_nSampleSize]; m_nWaveSize = ;
m_pWaveData = new float[m_nWaveSize];
} for (int i = ; i < m_pHBINK->NumTracks; ++i)
{
BinkSetVolume(m_pHBINK, BinkGetTrackID(m_pHBINK, i), 0xFFFF);
} return true;
} void CBIKMaterial::Shutdown(void)
{
DestroyProceduralTexture(); if (m_pHBINK)
{
BinkClose(m_pHBINK);
m_pHBINK = NULL;
} if (m_pBuffer)
{
delete[] m_pBuffer;
m_pBuffer = NULL;
}
} bool CBIKMaterial::Update(void)
{
BinkDoFrame(m_pHBINK); if (BinkWait(m_pHBINK))
return true; while (BinkShouldSkip(m_pHBINK))
{
BinkNextFrame(m_pHBINK);
BinkDoFrame(m_pHBINK);
} if (m_pHBINK->FrameNum == m_pHBINK->Frames)
{
if (m_bLoop)
{
BinkGoto(m_pHBINK, , );
} return false;
} BinkCopyToBuffer(m_pHBINK, m_pBuffer, m_nBIKWidth * , m_nBIKHeight, , , BINKSURFACE24R);
glBindTexture(GL_TEXTURE_2D, m_Texture);
glTexSubImage2D(GL_TEXTURE_2D, , , , m_nBIKWidth, m_nBIKHeight, GL_RGB, GL_UNSIGNED_BYTE, m_pBuffer); if (m_pHBINK->NumTracks && m_pSampleData)
{
memset(m_pSampleData, , m_nSampleSize);
BinkGetTrackData(m_hTrack, m_pSampleData); BINKTRACK *track = (BINKTRACK *)m_hTrack;
int i, n; memset(m_pWaveData, , m_nWaveSize); if (track->Channels == && track->Bits == )
{
for (i = , n = ; i < m_nSampleSize && n < m_nWaveSize; )
{
m_pWaveData[n] = (float)m_pSampleData[i] / 128.0f;
++i;
++n;
}
}
else if (track->Channels == && track->Bits == )
{
for (i = , n = ; i < m_nSampleSize && n < m_nWaveSize; )
{
float l = (float)m_pSampleData[i] / 128.0f;
++i;
float r = (float)m_pSampleData[i] / 128.0f;
++i; m_pWaveData[n] = (l + r) / 2.0f;
++n;
}
}
else if (track->Channels == && track->Bits == )
{
for (i = , n = ; i < m_nSampleSize && n < m_nWaveSize; )
{
m_pWaveData[n] = (float)( (m_pSampleData[i + ] << ) +
m_pSampleData[i]) / 32767.0f; i += ;
++n;
}
}
else if (track->Channels == && track->Bits == )
{
for (i = , n = ; i < m_nSampleSize && n < m_nWaveSize; )
{
float l = (float)( (m_pSampleData[i + ] << ) +
m_pSampleData[i]) / 32767.0f;
float r = (float)( (m_pSampleData[i + ] << ) +
m_pSampleData[i + ]) / 32767.0f; i += ; m_pWaveData[n] = (l + r) / 2.0f;
++n;
}
}
} BinkNextFrame(m_pHBINK); return true;
} int CBIKMaterial::GetTexture(void)
{
return m_Texture;
} void CBIKMaterial::GetFrameSize(int *pWidth, int *pHeight)
{
*pWidth = m_nBIKWidth;
*pHeight = m_nBIKHeight;
} int CBIKMaterial::GetFrameRate(void)
{
return m_nFrameRate;
} int CBIKMaterial::GetFrameCount(void)
{
return m_nFrameCount;
} void CBIKMaterial::SetFrame(float flFrame)
{
U32 iFrame = (U32)flFrame + ; if (m_pHBINK->LastFrameNum != iFrame)
{
BinkGoto(m_pHBINK, iFrame, );
}
} void CBIKMaterial::SetLoop(bool state)
{
m_bLoop = state;
} void CBIKMaterial::CreateProceduralTexture(void)
{
glGenTextures(, (GLuint *)&m_Texture); glBindTexture(GL_TEXTURE_2D, m_Texture);
glTexImage2D(GL_TEXTURE_2D, , GL_RGB, m_nBIKWidth, m_nBIKHeight, , GL_RGB, GL_UNSIGNED_BYTE, m_pBuffer);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
} void CBIKMaterial::DestroyProceduralTexture(void)
{
glDeleteTextures(, (GLuint *)&m_Texture);
}

Bink Player的更多相关文章

  1. 基于Composer Player 模型加载和相关属性设置

    主要是基于达索软件Composer Player.的基础上做些二次开发. public class ComposerToolBarSetting { public bool AntiAliasingO ...

  2. 解决浏览器Adobe Flash Player不是最新版本问题

    关键:选择谷歌浏览器的PPAPI版本的flash下载直接安装即可 搜索: Adobe Flash Player PPAPI 下载地址: http://www.wmzhe.com/soft-30259. ...

  3. Xamarin的不归路-使用Gorilla Player实时预览XAML

    搞了一天,才安装好,记录一下遇到的坑,为大家节约些时间. 一.下载软件 软件下载地址:http://gorillaplayer.com/ 没有FQ前用360极速浏览器和迅雷下载了好多次都失败了.用了蓝 ...

  4. Composer Player 属性设置

    /// <summary> /// 设置选中名称 /// </summary> /// <param name="name"></para ...

  5. 《InsideUE4》-9-GamePlay架构(八)Player

    你们对力量一无所知 引言 回顾上文,我们谈完了World和Level级别的逻辑操纵控制,如同分离组合的AController一样,UE在World的层次上也采用了一个分离的AGameMode来抽离了游 ...

  6. [转]Flash Player、AIR、Flex SDK 大全

    平时不断看到有朋友在各种论坛.空间.知道.群里求 Flash 平台各种版本的运行时(Flash Player)和SDK(Flex.AIR).今天就看到不下10次!所以决定把 Macromedia.Ad ...

  7. chrome 'adobe flash player 已过期'解决方法

    http://labs.adobe.com/downloads/flashplayer.html下载 WindowsDownload Flash Player for Opera and Chromi ...

  8. chrome一直提示adobe flash player 因过期而遭阻止

    链接:https://www.zhihu.com/question/32223811/answer/128088278 很多新用户在安装了Chrome浏览器或者更新过的的时候,经常提示 adobe f ...

  9. unity 发布web player版,网页打开报Failed to initialize player's 3D settings

    开始时我装的是unity 5.0.0b1,不知道在哪找的这个版本. web player 装的什么版本也忘了. 最后卸载了web player,重新安装web player并另外安装一个unity4. ...

随机推荐

  1. 简述MVC框架模式以及在你(Android)项目中的应用

    标题是阿里电话面试的问题,一直以为自己很清楚MVC模式,结果被问到时,居然没法将MVC和Android中各个组件对应起来,所以,面试肯定挂了,不过面试也是学习的一种方式,可以知道大公司看中什么,以及自 ...

  2. [20140829]spinlock导致cpu居高不下

    背景: 出现cpu高于常规的告警 排查: 1.开跟踪,没有发现cup特别高的查询 2.查看内核cpu使用量,看是否是sql server 端引起 3.查看负荷,是否负荷特别高这里使用 batch re ...

  3. WEB压力测试

    原文地址:WEB压力测试 作者:鸟哥のlinux webbench最多可以模拟3万个并发连接去测试网站的负载能力,个人感觉要比Apache自带的ab压力测试工具好,安装使用也特别方便. 1.适用系统: ...

  4. 安装mysql odbc遇到error 1918.errror installing ODBC driver mysql ODBC 5.3 ANSI Drive

    环境:Windows server2008r2 安装mysql-connector-odbc-5.3.6-win32 报错 相信错误信息:Error 1918.errror installing OD ...

  5. 说一下output子句

    Output子句日常灰常有用,而且用的地方也挺多,但是确好多时候被我们忽视,今天我就也简单扫盲一下这个语句的用法. Output子句 返回受 INSERT.UPDATE.DELETE 或 MERGE ...

  6. 与POS机通信时的3DES(双倍长)加密解密

    项目中有个SocketServer要和移动便携POS机通信,POS开发商就告诉我们他们用的3DES(双倍长)加密,给了个Key.数据和结果,让我们实现. c#用TripleDESCryptoServi ...

  7. 烂泥:【转】rsync命令参数详解

    本文由秀依林枫提供友情赞助,首发于烂泥行天下. rsync安装完毕后,我们可以通过rsync –help查看rysnc命令的使用.如下: 有关rsync的命令格式,在此我们就不多介绍了.如果有想了解的 ...

  8. iOS UIScrollView 无法滚动 没有弹簧效果解决方案

    一般情况下,检查如下: 1.没有设置contentSize或者contentSize的尺寸小于等于该scrollView的尺寸 2.scrollView.enable = NO;(仅仅是让scroll ...

  9. 制作OS X 10.9 Mavericks 安装U盘

    转载:http://www.macx.cn/forum.php?mod=viewthread&tid=2094799 安装win7的话,在mac中使用bootcamp制作一个win7安装盘即可 ...

  10. FTP定时批量下载文件(SHELL脚本及使用方法 )

    1. 脚本实例 将以下脚本保存为 getftp.sh #!/bin/bash  datesign=`date -d -95day +%Y%m%d` ftp -nv 12.2.2.28 << ...