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. ...
随机推荐
- Lambda 表达式(C# 编程指南) 微软microsoft官方说明
Visual Studio 2013 其他版本 Lambda 表达式是一种可用于创建委托或表达式目录树类型的匿名函数. 通过使用 lambda 表达式,可以写入可作为参数传递或作为函数调用值返回的本地 ...
- SSH框架搭建详解 及 乱码处理
http://www.360doc.com/content/15/1031/21/21693298_509739569.shtml struts 除了struts的mvc外,还有拦截器,国际化,str ...
- 0004 plsql的安装
PL/SQL是Oracle开发的主要工具,安装很简单,在官网 “https://www.allroundautomations.com/plsqldev.html” 选择合适的版本,也有多国语言包,下 ...
- 给锁住的行解锁(oracle)
1.查看数据库锁,诊断锁的来源及类型: select object_id,session_id,locked_mode from v$locked_object; 或者用以下命令: select b. ...
- linux基础-第十单元 系统的初始化和服务
第十单元 系统的初始化和服务 Linux系统引导的顺序 Linux系统引导的顺序 BOIS的初始化和引导加载程序 什么是BIOS GRUB程序和grub.conf文件 什么是grub grub配置文件 ...
- linux网站服务Apache+php+mysql的安装
1.挂载光盘 自己习惯将光盘挂载在/media/cdrom目录,在做本地yum源的时候此目录为默认目录之一 [root@localhost /]# mount /dev/cdrom /media/cd ...
- C语言中链表任意位置怎么插入数据?然后写入文件中?
链表插入示意图:(图是个人所画)因为链表指针指来指去,难以理解,所以辅助画图更加方便. 插入某个学号后面图: 定义的结构体: struct student { ]; //学生学号 ]; //学生姓名 ...
- 跨应用程序域(AppDomain)的单例(Singleton)实现
转载自: 跨应用程序域(AppDomain)的单例(Singleton)实现 - CorePlex代码库 - CorePlex官方网站,Visual Studio插件,代码大全,代码仓库,代码整理,分 ...
- Android adb push 和 pull操作
由于安卓真机本地调试时,每次启动并生成apk然后安装到设备比较费时,而很多情况是仅仅修改了hot 脚本文件(cocos2dx + lua). 所以,使用热更机制把修改后的lua文件push到热更目录( ...
- 32-bit Assembly on x86_64 Linux (Use Nasm and ld&gcc)
Assembly on x86_64 Linux Some instructions in Intel assembly set are invalid in x86_64 env. e.g. aaa ...