Bink Player
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的更多相关文章
- 基于Composer Player 模型加载和相关属性设置
主要是基于达索软件Composer Player.的基础上做些二次开发. public class ComposerToolBarSetting { public bool AntiAliasingO ...
- 解决浏览器Adobe Flash Player不是最新版本问题
关键:选择谷歌浏览器的PPAPI版本的flash下载直接安装即可 搜索: Adobe Flash Player PPAPI 下载地址: http://www.wmzhe.com/soft-30259. ...
- Xamarin的不归路-使用Gorilla Player实时预览XAML
搞了一天,才安装好,记录一下遇到的坑,为大家节约些时间. 一.下载软件 软件下载地址:http://gorillaplayer.com/ 没有FQ前用360极速浏览器和迅雷下载了好多次都失败了.用了蓝 ...
- Composer Player 属性设置
/// <summary> /// 设置选中名称 /// </summary> /// <param name="name"></para ...
- 《InsideUE4》-9-GamePlay架构(八)Player
你们对力量一无所知 引言 回顾上文,我们谈完了World和Level级别的逻辑操纵控制,如同分离组合的AController一样,UE在World的层次上也采用了一个分离的AGameMode来抽离了游 ...
- [转]Flash Player、AIR、Flex SDK 大全
平时不断看到有朋友在各种论坛.空间.知道.群里求 Flash 平台各种版本的运行时(Flash Player)和SDK(Flex.AIR).今天就看到不下10次!所以决定把 Macromedia.Ad ...
- chrome 'adobe flash player 已过期'解决方法
http://labs.adobe.com/downloads/flashplayer.html下载 WindowsDownload Flash Player for Opera and Chromi ...
- chrome一直提示adobe flash player 因过期而遭阻止
链接:https://www.zhihu.com/question/32223811/answer/128088278 很多新用户在安装了Chrome浏览器或者更新过的的时候,经常提示 adobe f ...
- unity 发布web player版,网页打开报Failed to initialize player's 3D settings
开始时我装的是unity 5.0.0b1,不知道在哪找的这个版本. web player 装的什么版本也忘了. 最后卸载了web player,重新安装web player并另外安装一个unity4. ...
随机推荐
- HtmlHelper用法大全
HTML扩展类的所有方法都有2个参数: 以textbox为例子 public static string TextBox( this HtmlHelper htmlHelper, string nam ...
- git技巧记录--子模块删除方法
把子模块推进去了,删掉吧(将子模块删除,然后提交推送),删除子模块步骤: 1.在Platform.Web库下,右键->Git Bash,进入git命令行窗口,输入:git rm –-cached ...
- 你知道哪些linux命令,能把文件上传到远程linux服务器
多数情况下 企业的服务基本都是部署在linux服务器 那对于测试同学,必须掌握基本的linux命令 至少要知道怎么部署整体环境 部署过程中,经常需要的操作,是向服务器上传部署包 你一般都是 ...
- Apache 反向代理实现为http添加https的外衣
Apache 反向代理 金天:坚持写东西,不是一件容易的事,换句话说其实坚持本身都不是一件容易的事.如果学习有捷径,那就是不断实践,不断积累.写笔记,其实是给自己看的,是体现积累的一种方式,要坚持. ...
- python基础(五)缩进和选择
作者:Vamei 出处:http://www.cnblogs.com/vamei 欢迎转载,也请保留这段声明.谢谢! 缩进 Python最具特色的是用缩进来标明成块的代码.我下面以if选择结构来举例. ...
- iOS tabbar 自定义小红点 消息显示,定制边框、颜色、高宽
一般我们需要显示消息数,会利用到系统提供的api UIApplication.sharedApplication().applicationIconBadgeNumber = 10 但如果我们不想显示 ...
- WIN 程序员的 Linux 互斥类
作者:黄山松,发表于cnblogs:http://www.cnblogs.com/tomview/ 对于一个 win 的程序员,要把在 win 下的程序移植到 linux 下,需要把一些平台相关的功能 ...
- python可分组字典
# -*- encoding: UTF-8 -*- from collections import defaultdict class News(object): def __init__(self, ...
- sql in按照指定顺序排序
如下 Select * FROM table1 ,,,,) order by field (3,5,1,4,2)
- 嵌入式开发平台-iTOP-4418开发板
详情转自:http://topeetboard.com S5P4418核心板可以无缝支持核心系统S5P6818,并保持底板设计不变,将兼顾更高端 的应用领域,为项目和产品提供更好的灵活性以及可伸缩性. ...