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 &#39;adobe flash player 已过期&#39;解决方法
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&#39;s 3D settings
开始时我装的是unity 5.0.0b1,不知道在哪找的这个版本. web player 装的什么版本也忘了. 最后卸载了web player,重新安装web player并另外安装一个unity4. ...
随机推荐
-
ASP.NET MVC 从零开始 - 请求处理
这篇文章是从我的 github 博客 lxconan.github.io 导入的. 这是这个系列的第三篇了.前两篇文章请参见: ASP.NET MVC 从零开始 - Create and Run AS ...
-
C++内存动态分配
https://www.percona.com/blog/2012/07/05/impact-of-memory-allocators-on-mysql-performance/ https://su ...
-
RecyclerView使用时遇到的问题
一.概述 二.常见问题: 1.如何为RecyclerView的Item设置点击事件? 1.1 问题描述 类似于下列方法 RecyclerView.setOnItemClickListener(OnCl ...
-
[CrunchBang]tint2默认设置
#--------------------------------------------- # TINT2 CONFIG FILE #-------------------------------- ...
-
Android Studio 的安装和配置篇(Windows篇)
上一篇介绍完了Android Studio,这一篇就专门来讲讲怎么安装配置的吧. 其实好多人都卡到安装配置这一步,想当初我也是,万恶的XX防火墙,导致下载Android Studio 的gradle异 ...
-
mongodb概念
一.mongodb与关系型数据库的一些概念上的改变 sql术语 mongodb术语 说明 database database 数据库 table collection 表/集合 row documen ...
-
C++虚函数表分析
在<<反C++>>文中提到的 VC6.0 上的编译器支持一个d1reportAllClassLayout的开关, 能够输出全部对象的内存布局信息, 我自己经常使用vs2005来 ...
-
实战荟萃-UI篇
一. 前言 平时在处理问题的时候,经常会遇到一些奇奇怪怪的问题,今天在这里将其记录下来.这里将会列举几个常用的UI问题进行讲解 二. 导航栏 iOS导航栏绝对是个巨坑.和很多朋友聊天都是自己实现了一套 ...
-
CRM导入组织报实例名称必须与计算机名称相同的问题
今天采用P2V拷贝了一台CRM数据库到虚机上,因为要加域必须得把计算机名改了,然后再重新导入组织的时候报错了:"实例名称必须与计算机名称相同",google了下没有匹配的问题答案, ...
-
【Java】Properties文件的解析
public abstract class ReadProperties { public ReadProperties() {} /** * 回调函数,由调用者处理 * @param key * @ ...