1 Star 0 Fork 2

qijinquan/gsplayer

forked from matthewgao/gsplayer 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
sdlbase.cpp 1.26 KB
一键复制 编辑 原始数据 按行查看 历史
gaoshen.gs 提交于 2020-07-17 19:02 . compatiable with new mac
#include "sdlbase.h"
#include <stdio.h>
#include "decoder.h"
void SDLBase::ListenEvent(MediaDecoder *decoder){
SDL_Event e;
while( !this->m_should_exit )
{
if (SDL_PollEvent( &e ) == 0){
// this_thread::sleep_for(chrono::milliseconds(200));
}
decoder->ShowFrame();
//User requests quit
if( e.type == SDL_QUIT )
{
this->m_should_exit = true;
}
if (e.window.event == SDL_WINDOWEVENT_RESIZED){
int new_width = e.window.data1;
int new_height = e.window.data2;
float aspectRatio = (float)new_width/(float)new_height;
float ASPECT_RATIO = (float)this->width/(float)this->height;
if(aspectRatio != ASPECT_RATIO) {
// if(aspectRatio > ASPECT_RATIO) {
new_height = (1.f / ASPECT_RATIO) * new_width;
// }
// else {
// new_width = ASPECT_RATIO * new_height;
// }
this->width = new_width;
this->height = new_height;
printf("Setting window size to %d, %d, aspect ratio: %f\n",
new_width, new_height, (float)new_width/(float)new_height);
}
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/qijinquan/gsplayer.git
git@gitee.com:qijinquan/gsplayer.git
qijinquan
gsplayer
gsplayer
master

搜索帮助