- added support for main menu background video
This commit is contained in:
parent
3187252936
commit
0d38e2eb5d
|
@ -21,6 +21,7 @@
|
||||||
#include "game_util.h"
|
#include "game_util.h"
|
||||||
#include "lang.h"
|
#include "lang.h"
|
||||||
#include "game_settings.h"
|
#include "game_settings.h"
|
||||||
|
#include "video_player.h"
|
||||||
#include "leak_dumper.h"
|
#include "leak_dumper.h"
|
||||||
|
|
||||||
using namespace Shared::Sound;
|
using namespace Shared::Sound;
|
||||||
|
@ -76,6 +77,9 @@ CoreData::CoreData() {
|
||||||
menuFontBig3D=NULL;
|
menuFontBig3D=NULL;
|
||||||
menuFontVeryBig3D=NULL;
|
menuFontVeryBig3D=NULL;
|
||||||
consoleFont3D=NULL;
|
consoleFont3D=NULL;
|
||||||
|
|
||||||
|
introVideoFilename="";
|
||||||
|
mainMenuVideoFilename="";
|
||||||
}
|
}
|
||||||
|
|
||||||
CoreData::~CoreData() {
|
CoreData::~CoreData() {
|
||||||
|
@ -397,6 +401,51 @@ void CoreData::load() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false &&
|
||||||
|
Shared::Graphics::VideoPlayer::hasBackEndVideoPlayer() == true) {
|
||||||
|
string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey);
|
||||||
|
|
||||||
|
introVideoFilename = "";
|
||||||
|
string introVideoPath = getGameCustomCoreDataPath(data_path, "") + "data/core/menu/videos/intro.*";
|
||||||
|
vector<string> introVideos;
|
||||||
|
findAll(introVideoPath, introVideos, false, false);
|
||||||
|
for(int i = 0; i < introVideos.size(); ++i) {
|
||||||
|
string video = getGameCustomCoreDataPath(data_path, "") + "data/core/menu/videos/" + introVideos[i];
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Checking if intro video [%s] exists\n",video.c_str());
|
||||||
|
|
||||||
|
if(fileExists(video)) {
|
||||||
|
introVideoFilename = video;
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("FOUND intro video [%s] will use this file\n",video.c_str());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mainMenuVideoFilename = "";
|
||||||
|
string mainVideoPath = getGameCustomCoreDataPath(data_path, "") + "data/core/menu/videos/main.*";
|
||||||
|
vector<string> mainVideos;
|
||||||
|
findAll(mainVideoPath, mainVideos, false, false);
|
||||||
|
for(int i = 0; i < mainVideos.size(); ++i) {
|
||||||
|
string video = getGameCustomCoreDataPath(data_path, "") + "data/core/menu/videos/" + mainVideos[i];
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Checking if intro video [%s] exists\n",video.c_str());
|
||||||
|
|
||||||
|
if(fileExists(video)) {
|
||||||
|
mainMenuVideoFilename = video;
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("FOUND intro video [%s] will use this file\n",video.c_str());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CoreData::hasIntroVideoFilename() const {
|
||||||
|
bool result = (introVideoFilename != "" && fileExists(introVideoFilename) == true);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CoreData::hasMainMenuVideoFilename() const {
|
||||||
|
bool result = (mainMenuVideoFilename != "" && fileExists(mainMenuVideoFilename) == true);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CoreData::loadFonts() {
|
void CoreData::loadFonts() {
|
||||||
|
|
|
@ -88,6 +88,9 @@ private:
|
||||||
Font3D *menuFontVeryBig3D;
|
Font3D *menuFontVeryBig3D;
|
||||||
Font3D *consoleFont3D;
|
Font3D *consoleFont3D;
|
||||||
|
|
||||||
|
string introVideoFilename;
|
||||||
|
string mainMenuVideoFilename;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
enum TextureSystemType {
|
enum TextureSystemType {
|
||||||
|
@ -174,6 +177,12 @@ public:
|
||||||
Font3D *getMenuFontVeryBig3D() const {return menuFontVeryBig3D;}
|
Font3D *getMenuFontVeryBig3D() const {return menuFontVeryBig3D;}
|
||||||
Font3D *getConsoleFont3D() const {return consoleFont3D;}
|
Font3D *getConsoleFont3D() const {return consoleFont3D;}
|
||||||
|
|
||||||
|
string getMainMenuVideoFilename() const { return mainMenuVideoFilename; }
|
||||||
|
bool hasMainMenuVideoFilename() const;
|
||||||
|
|
||||||
|
string getIntroVideoFilename() const { return introVideoFilename; }
|
||||||
|
bool hasIntroVideoFilename() const;
|
||||||
|
|
||||||
void saveGameSettingsToFile(std::string fileName, GameSettings *gameSettings,int advancedIndex=0);
|
void saveGameSettingsToFile(std::string fileName, GameSettings *gameSettings,int advancedIndex=0);
|
||||||
bool loadGameSettingsFromFile(std::string fileName, GameSettings *gameSettings);
|
bool loadGameSettingsFromFile(std::string fileName, GameSettings *gameSettings);
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,9 @@ BattleEnd::~BattleEnd() {
|
||||||
delete originState;
|
delete originState;
|
||||||
originState = NULL;
|
originState = NULL;
|
||||||
|
|
||||||
|
if(CoreData::getInstance().hasMainMenuVideoFilename() == false) {
|
||||||
SoundRenderer::getInstance().playMusic(CoreData::getInstance().getMenuMusic());
|
SoundRenderer::getInstance().playMusic(CoreData::getInstance().getMenuMusic());
|
||||||
|
}
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
|
|
@ -493,32 +493,19 @@ Intro::Intro(Program *program):
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
if(VideoPlayer::hasBackEndVideoPlayer() == true) {
|
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false &&
|
||||||
//string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey);
|
Shared::Graphics::VideoPlayer::hasBackEndVideoPlayer() == true &&
|
||||||
//string introVideoFile = getGameCustomCoreDataPath(data_path, "data/core/menu/videos/intro.avi");
|
CoreData::getInstance().hasIntroVideoFilename() == true) {
|
||||||
string introVideoFile = "";
|
string introVideoFile = CoreData::getInstance().getIntroVideoFilename();
|
||||||
string introVideoPath = getGameCustomCoreDataPath(data_path, "") + "data/core/menu/videos/intro.*";
|
|
||||||
vector<string> introVideos;
|
|
||||||
findAll(introVideoPath, introVideos, false, false);
|
|
||||||
for(int i = 0; i < introVideos.size(); ++i) {
|
|
||||||
string video = getGameCustomCoreDataPath(data_path, "") + "data/core/menu/videos/" + introVideos[i];
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Checking if intro video [%s] exists\n",video.c_str());
|
|
||||||
|
|
||||||
if(fileExists(video)) {
|
|
||||||
introVideoFile = video;
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("FOUND intro video [%s] will use this file\n",video.c_str());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(fileExists(introVideoFile)) {
|
if(fileExists(introVideoFile)) {
|
||||||
Context *c= GraphicsInterface::getInstance().getCurrentContext();
|
Context *c= GraphicsInterface::getInstance().getCurrentContext();
|
||||||
SDL_Surface *screen = static_cast<ContextGl*>(c)->getPlatformContextGlPtr()->getScreen();
|
SDL_Surface *screen = static_cast<ContextGl*>(c)->getPlatformContextGlPtr()->getScreen();
|
||||||
|
|
||||||
string vlcPluginsPath = Config::getInstance().getString("VideoPlayerPluginsPath","");
|
string vlcPluginsPath = Config::getInstance().getString("VideoPlayerPluginsPath","");
|
||||||
//printf("screen->w = %d screen->h = %d screen->format->BitsPerPixel = %d\n",screen->w,screen->h,screen->format->BitsPerPixel);
|
//printf("screen->w = %d screen->h = %d screen->format->BitsPerPixel = %d\n",screen->w,screen->h,screen->format->BitsPerPixel);
|
||||||
VideoPlayer player(introVideoFile.c_str(),
|
Shared::Graphics::VideoPlayer player(introVideoFile.c_str(),
|
||||||
screen,
|
screen,
|
||||||
|
-1,-1,
|
||||||
screen->w,
|
screen->w,
|
||||||
screen->h,
|
screen->h,
|
||||||
screen->format->BitsPerPixel,
|
screen->format->BitsPerPixel,
|
||||||
|
@ -548,7 +535,8 @@ Intro::~Intro() {
|
||||||
|
|
||||||
void Intro::update() {
|
void Intro::update() {
|
||||||
if(exitAfterIntroVideo == true) {
|
if(exitAfterIntroVideo == true) {
|
||||||
mouseUpLeft(0, 0);
|
//mouseUpLeft(0, 0);
|
||||||
|
cleanup();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
timer++;
|
timer++;
|
||||||
|
@ -854,7 +842,9 @@ void Intro::mouseUpLeft(int x, int y) {
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
if(CoreData::getInstance().hasMainMenuVideoFilename() == false) {
|
||||||
soundRenderer.playMusic(CoreData::getInstance().getMenuMusic());
|
soundRenderer.playMusic(CoreData::getInstance().getMenuMusic());
|
||||||
|
}
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "network_message.h"
|
#include "network_message.h"
|
||||||
#include "socket.h"
|
#include "socket.h"
|
||||||
#include "menu_state_root.h"
|
#include "menu_state_root.h"
|
||||||
|
#include "video_player.h"
|
||||||
|
|
||||||
#include "leak_dumper.h"
|
#include "leak_dumper.h"
|
||||||
|
|
||||||
|
@ -44,9 +45,7 @@ namespace Glest{ namespace Game{
|
||||||
// ===================== PUBLIC ========================
|
// ===================== PUBLIC ========================
|
||||||
MenuState * MainMenu::oldstate=NULL;
|
MenuState * MainMenu::oldstate=NULL;
|
||||||
|
|
||||||
MainMenu::MainMenu(Program *program):
|
MainMenu::MainMenu(Program *program) : ProgramState(program), menuBackgroundVideo(NULL) {
|
||||||
ProgramState(program)
|
|
||||||
{
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
mouseX=100;
|
mouseX=100;
|
||||||
|
@ -71,6 +70,11 @@ void MainMenu::reloadUI() {
|
||||||
MainMenu::~MainMenu() {
|
MainMenu::~MainMenu() {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
if(menuBackgroundVideo != NULL) {
|
||||||
|
menuBackgroundVideo->closePlayer();
|
||||||
|
delete menuBackgroundVideo;
|
||||||
|
menuBackgroundVideo = NULL;
|
||||||
|
}
|
||||||
delete state;
|
delete state;
|
||||||
state = NULL;
|
state = NULL;
|
||||||
delete oldstate;
|
delete oldstate;
|
||||||
|
@ -90,16 +94,33 @@ MainMenu::~MainMenu() {
|
||||||
|
|
||||||
void MainMenu::init() {
|
void MainMenu::init() {
|
||||||
Renderer::getInstance().initMenu(this);
|
Renderer::getInstance().initMenu(this);
|
||||||
|
|
||||||
|
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false &&
|
||||||
|
Shared::Graphics::VideoPlayer::hasBackEndVideoPlayer() == true) {
|
||||||
|
string introVideoFile = CoreData::getInstance().getMainMenuVideoFilename();
|
||||||
|
if(introVideoFile != "" && fileExists(introVideoFile)) {
|
||||||
|
Context *c= GraphicsInterface::getInstance().getCurrentContext();
|
||||||
|
SDL_Surface *screen = static_cast<ContextGl*>(c)->getPlatformContextGlPtr()->getScreen();
|
||||||
|
|
||||||
|
string vlcPluginsPath = Config::getInstance().getString("VideoPlayerPluginsPath","");
|
||||||
|
//printf("screen->w = %d screen->h = %d screen->format->BitsPerPixel = %d\n",screen->w,screen->h,screen->format->BitsPerPixel);
|
||||||
|
menuBackgroundVideo = new VideoPlayer(introVideoFile.c_str(),
|
||||||
|
screen,
|
||||||
|
0,0,
|
||||||
|
screen->w,
|
||||||
|
screen->h,
|
||||||
|
screen->format->BitsPerPixel,
|
||||||
|
vlcPluginsPath,
|
||||||
|
SystemFlags::VERBOSE_MODE_ENABLED);
|
||||||
|
menuBackgroundVideo->initPlayer();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//asynchronus render update
|
//asynchronus render update
|
||||||
void MainMenu::render() {
|
void MainMenu::render() {
|
||||||
|
|
||||||
//Config &config= Config::getInstance();
|
|
||||||
Renderer &renderer= Renderer::getInstance();
|
Renderer &renderer= Renderer::getInstance();
|
||||||
//CoreData &coreData= CoreData::getInstance();
|
|
||||||
|
|
||||||
//fps++;
|
|
||||||
canRender();
|
canRender();
|
||||||
incrementFps();
|
incrementFps();
|
||||||
|
|
||||||
|
@ -109,14 +130,22 @@ void MainMenu::render() {
|
||||||
|
|
||||||
//3d
|
//3d
|
||||||
renderer.reset3dMenu();
|
renderer.reset3dMenu();
|
||||||
|
|
||||||
renderer.clearZBuffer();
|
renderer.clearZBuffer();
|
||||||
|
|
||||||
|
if(menuBackgroundVideo == NULL) {
|
||||||
renderer.loadCameraMatrix(menuBackground.getCamera());
|
renderer.loadCameraMatrix(menuBackground.getCamera());
|
||||||
renderer.renderMenuBackground(&menuBackground);
|
renderer.renderMenuBackground(&menuBackground);
|
||||||
renderer.renderParticleManager(rsMenu);
|
renderer.renderParticleManager(rsMenu);
|
||||||
|
}
|
||||||
|
|
||||||
//2d
|
//2d
|
||||||
renderer.reset2d();
|
renderer.reset2d();
|
||||||
|
|
||||||
|
if(menuBackgroundVideo != NULL) {
|
||||||
|
if(menuBackgroundVideo->isPlaying() == true) {
|
||||||
|
menuBackgroundVideo->playFrame(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
state->render();
|
state->render();
|
||||||
|
|
||||||
|
@ -130,9 +159,13 @@ void MainMenu::render() {
|
||||||
|
|
||||||
//syncronus update
|
//syncronus update
|
||||||
void MainMenu::update(){
|
void MainMenu::update(){
|
||||||
|
if(menuBackgroundVideo != NULL) {
|
||||||
Renderer::getInstance().updateParticleManager(rsMenu);
|
Renderer::getInstance().updateParticleManager(rsMenu);
|
||||||
|
}
|
||||||
mouse2dAnim= (mouse2dAnim +1) % Renderer::maxMouse2dAnim;
|
mouse2dAnim= (mouse2dAnim +1) % Renderer::maxMouse2dAnim;
|
||||||
|
if(menuBackgroundVideo != NULL) {
|
||||||
menuBackground.update();
|
menuBackground.update();
|
||||||
|
}
|
||||||
state->update();
|
state->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,10 @@
|
||||||
#include "game_settings.h"
|
#include "game_settings.h"
|
||||||
#include "leak_dumper.h"
|
#include "leak_dumper.h"
|
||||||
|
|
||||||
|
namespace Shared { namespace Graphics {
|
||||||
|
class VideoPlayer;
|
||||||
|
}}
|
||||||
|
|
||||||
namespace Glest{ namespace Game{
|
namespace Glest{ namespace Game{
|
||||||
|
|
||||||
class MenuState;
|
class MenuState;
|
||||||
|
@ -47,6 +51,7 @@ private:
|
||||||
//shared
|
//shared
|
||||||
GameSettings gameSettings;
|
GameSettings gameSettings;
|
||||||
MenuBackground menuBackground;
|
MenuBackground menuBackground;
|
||||||
|
Shared::Graphics::VideoPlayer *menuBackgroundVideo;
|
||||||
|
|
||||||
MenuState *state;
|
MenuState *state;
|
||||||
|
|
||||||
|
|
|
@ -1158,7 +1158,9 @@ void MenuStateOptions::saveConfig(){
|
||||||
soundRenderer.setMusicVolume(CoreData::getInstance().getMenuMusic());
|
soundRenderer.setMusicVolume(CoreData::getInstance().getMenuMusic());
|
||||||
program->startSoundSystem();
|
program->startSoundSystem();
|
||||||
|
|
||||||
|
if(CoreData::getInstance().hasMainMenuVideoFilename() == false) {
|
||||||
soundRenderer.playMusic(CoreData::getInstance().getMenuMusic());
|
soundRenderer.playMusic(CoreData::getInstance().getMenuMusic());
|
||||||
|
}
|
||||||
|
|
||||||
Renderer::getInstance().loadConfig();
|
Renderer::getInstance().loadConfig();
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,31 +14,52 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class SDL_Surface;
|
class SDL_Surface;
|
||||||
|
class ctx;
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
namespace Shared{ namespace Graphics{
|
||||||
|
|
||||||
class VideoPlayer {
|
class VideoPlayer {
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
string filename;
|
string filename;
|
||||||
SDL_Surface *surface;
|
SDL_Surface *surface;
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
int colorBits;
|
int colorBits;
|
||||||
|
|
||||||
|
bool successLoadingLib;
|
||||||
string pluginsPath;
|
string pluginsPath;
|
||||||
bool verboseEnabled;
|
bool verboseEnabled;
|
||||||
|
|
||||||
bool stop;
|
bool stop;
|
||||||
|
bool finished;
|
||||||
|
|
||||||
|
ctx *ctxPtr;
|
||||||
|
|
||||||
|
void init();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VideoPlayer(string filename, SDL_Surface *surface, int width, int height,
|
VideoPlayer(string filename, SDL_Surface *surface, int x, int y,
|
||||||
int colorBits, string pluginsPath,bool verboseEnabled=false);
|
int width, int height, int colorBits,
|
||||||
|
string pluginsPath,bool verboseEnabled=false);
|
||||||
virtual ~VideoPlayer();
|
virtual ~VideoPlayer();
|
||||||
|
|
||||||
void PlayVideo();
|
void PlayVideo();
|
||||||
void StopVideo() { stop = true; }
|
void StopVideo() { stop = true; }
|
||||||
|
|
||||||
|
bool initPlayer();
|
||||||
|
void closePlayer();
|
||||||
|
|
||||||
|
bool playFrame(bool swapBuffers = true);
|
||||||
|
bool isPlaying() const;
|
||||||
|
|
||||||
static bool hasBackEndVideoPlayer();
|
static bool hasBackEndVideoPlayer();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}}
|
||||||
|
|
||||||
#endif /* VIDEO_PLAYER_H_ */
|
#endif /* VIDEO_PLAYER_H_ */
|
||||||
|
|
|
@ -66,17 +66,56 @@ std::string getRegKey(const std::string& location, const std::string& name){
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct ctx {
|
class ctx {
|
||||||
|
public:
|
||||||
|
ctx() {
|
||||||
|
empty = NULL;
|
||||||
|
textureId = 0; // Texture ID
|
||||||
|
surf = NULL;
|
||||||
|
mutex = NULL;
|
||||||
|
x= 0;
|
||||||
|
y = 0;
|
||||||
|
width = 0;
|
||||||
|
height = 0;
|
||||||
|
rawData = NULL;
|
||||||
|
isPlaying = 0;
|
||||||
|
needToQuit = false;
|
||||||
|
verboseEnabled = 0;
|
||||||
|
|
||||||
|
#ifdef HAS_LIBVLC
|
||||||
|
libvlc = NULL;
|
||||||
|
m = NULL;
|
||||||
|
mp = NULL;
|
||||||
|
vlc_argv.clear();
|
||||||
|
vlc_argv_str.clear();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_Surface *empty;
|
||||||
GLuint textureId; // Texture ID
|
GLuint textureId; // Texture ID
|
||||||
SDL_Surface *surf;
|
SDL_Surface *surf;
|
||||||
SDL_mutex *mutex;
|
SDL_mutex *mutex;
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
void *rawData;
|
void *rawData;
|
||||||
bool isPlaying;
|
bool isPlaying;
|
||||||
|
bool needToQuit;
|
||||||
bool verboseEnabled;
|
bool verboseEnabled;
|
||||||
|
|
||||||
|
#ifdef HAS_LIBVLC
|
||||||
|
libvlc_instance_t *libvlc;
|
||||||
|
libvlc_media_t *m;
|
||||||
|
libvlc_media_player_t *mp;
|
||||||
|
|
||||||
|
std::vector<const char *> vlc_argv;
|
||||||
|
std::vector<string> vlc_argv_str;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace Shared{ namespace Graphics{
|
||||||
|
|
||||||
// Load a texture
|
// Load a texture
|
||||||
static void loadTexture(struct ctx *ctx) {
|
static void loadTexture(struct ctx *ctx) {
|
||||||
if(ctx->verboseEnabled) printf("In [%s] Line: %d\n",__FUNCTION__,__LINE__);
|
if(ctx->verboseEnabled) printf("In [%s] Line: %d\n",__FUNCTION__,__LINE__);
|
||||||
|
@ -165,21 +204,45 @@ void trapErrorEvent(const libvlc_event_t *evt, void *data) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
VideoPlayer::VideoPlayer(string filename, SDL_Surface *surface,
|
VideoPlayer::VideoPlayer(string filename, SDL_Surface *surface,
|
||||||
int width, int height,int colorBits,string pluginsPath,
|
int x, int y,int width, int height,int colorBits,string pluginsPath,
|
||||||
bool verboseEnabled) {
|
bool verboseEnabled) : ctxPtr(NULL) {
|
||||||
this->filename = filename;
|
this->filename = filename;
|
||||||
this->surface = surface;
|
this->surface = surface;
|
||||||
|
this->x = x;
|
||||||
|
this->y = y;
|
||||||
this->width = width;
|
this->width = width;
|
||||||
this->height = height;
|
this->height = height;
|
||||||
this->colorBits = colorBits;
|
this->colorBits = colorBits;
|
||||||
this->pluginsPath = pluginsPath;
|
this->pluginsPath = pluginsPath;
|
||||||
this->verboseEnabled = verboseEnabled;
|
this->verboseEnabled = verboseEnabled;
|
||||||
|
|
||||||
this->stop = false;
|
this->stop = false;
|
||||||
|
this->finished = false;
|
||||||
|
this->successLoadingLib = false;
|
||||||
|
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VideoPlayer::init() {
|
||||||
|
//verboseEnabled = true;
|
||||||
|
ctxPtr = new ctx();
|
||||||
|
ctxPtr->x = x;
|
||||||
|
ctxPtr->y = y;
|
||||||
|
ctxPtr->width = width;
|
||||||
|
ctxPtr->height = height;
|
||||||
|
ctxPtr->rawData = (void *) malloc(width * height * 4);
|
||||||
|
ctxPtr->verboseEnabled = verboseEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoPlayer::~VideoPlayer() {
|
VideoPlayer::~VideoPlayer() {
|
||||||
|
if(ctxPtr != NULL) {
|
||||||
|
if(ctxPtr->rawData != NULL) {
|
||||||
|
free(ctxPtr->rawData);
|
||||||
|
ctxPtr->rawData = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete ctxPtr;
|
||||||
|
ctxPtr = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VideoPlayer::hasBackEndVideoPlayer() {
|
bool VideoPlayer::hasBackEndVideoPlayer() {
|
||||||
|
@ -188,33 +251,22 @@ bool VideoPlayer::hasBackEndVideoPlayer() {
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
void VideoPlayer::PlayVideo() {
|
|
||||||
//verboseEnabled = true;
|
|
||||||
struct ctx ctx;
|
|
||||||
ctx.width = width;
|
|
||||||
ctx.height = height;
|
|
||||||
ctx.rawData = (void *) malloc(width * height * 4);
|
|
||||||
ctx.verboseEnabled = verboseEnabled;
|
|
||||||
|
|
||||||
|
bool VideoPlayer::initPlayer() {
|
||||||
#ifdef HAS_LIBVLC
|
#ifdef HAS_LIBVLC
|
||||||
libvlc_instance_t *libvlc = NULL;
|
ctxPtr->libvlc = NULL;
|
||||||
libvlc_media_t *m = NULL;
|
ctxPtr->m = NULL;
|
||||||
libvlc_media_player_t *mp = NULL;
|
ctxPtr->mp = NULL;
|
||||||
|
ctxPtr->vlc_argv.clear();
|
||||||
|
ctxPtr->vlc_argv.push_back("--intf=dummy");
|
||||||
|
ctxPtr->vlc_argv.push_back("--no-media-library");
|
||||||
|
ctxPtr->vlc_argv.push_back("--ignore-config"); /* Don't use VLC's config */
|
||||||
|
ctxPtr->vlc_argv.push_back("--no-xlib"); /* tell VLC to not use Xlib */
|
||||||
|
ctxPtr->vlc_argv.push_back("--no-video-title-show");
|
||||||
|
|
||||||
// string pluginParam = "";
|
|
||||||
// if(pluginsPath != "") {
|
|
||||||
// pluginParam = "--plugin-path=" + pluginsPath;
|
|
||||||
// }
|
|
||||||
|
|
||||||
std::vector<const char *> vlc_argv;
|
|
||||||
vlc_argv.push_back("--intf=dummy");
|
|
||||||
vlc_argv.push_back("--no-media-library");
|
|
||||||
vlc_argv.push_back("--ignore-config"); /* Don't use VLC's config */
|
|
||||||
vlc_argv.push_back("--no-xlib"); /* tell VLC to not use Xlib */
|
|
||||||
vlc_argv.push_back("--no-video-title-show");
|
|
||||||
#if defined(LIBVLC_VERSION_PRE_2)
|
#if defined(LIBVLC_VERSION_PRE_2)
|
||||||
string fullPluginsParam = "--plugin-path=" + pluginsPath;
|
ctxPtr->vlc_argv_str.push_back("--plugin-path=" + pluginsPath);
|
||||||
vlc_argv.push_back(fullPluginsParam.c_str());
|
ctxPtr->vlc_argv.push_back(ctxPtr->vlc_argv_str[ctxPtr->vlc_argv_str.size()-1].c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(LIBVLC_VERSION_PRE_2) && defined(LIBVLC_VERSION_PRE_1_1_13)
|
#if defined(LIBVLC_VERSION_PRE_2) && defined(LIBVLC_VERSION_PRE_1_1_13)
|
||||||
|
@ -225,7 +277,7 @@ void VideoPlayer::PlayVideo() {
|
||||||
*/
|
*/
|
||||||
sprintf(clock, "%lld", (long long int)(intptr_t)lock);
|
sprintf(clock, "%lld", (long long int)(intptr_t)lock);
|
||||||
sprintf(cunlock, "%lld", (long long int)(intptr_t)unlock);
|
sprintf(cunlock, "%lld", (long long int)(intptr_t)unlock);
|
||||||
sprintf(cdata, "%lld", (long long int)(intptr_t)&ctx);
|
sprintf(cdata, "%lld", (long long int)(intptr_t)ctxPtr);
|
||||||
sprintf(cwidth, "%i", width);
|
sprintf(cwidth, "%i", width);
|
||||||
sprintf(cheight, "%i", height);
|
sprintf(cheight, "%i", height);
|
||||||
sprintf(cpitch, "%i", colorBits);
|
sprintf(cpitch, "%i", colorBits);
|
||||||
|
@ -233,28 +285,34 @@ void VideoPlayer::PlayVideo() {
|
||||||
vlc_argv.push_back("--vout");
|
vlc_argv.push_back("--vout");
|
||||||
vlc_argv.push_back("vmem");
|
vlc_argv.push_back("vmem");
|
||||||
vlc_argv.push_back("--vmem-width");
|
vlc_argv.push_back("--vmem-width");
|
||||||
vlc_argv.push_back(cwidth);
|
ctxPtr->vlc_argv_str.push_back(cwidth);
|
||||||
|
ctxPtr->vlc_argv.push_back(ctxPtr->vlc_argv_str[ctxPtr->vlc_argv_str.size()-1].c_str());
|
||||||
vlc_argv.push_back("--vmem-height");
|
vlc_argv.push_back("--vmem-height");
|
||||||
vlc_argv.push_back(cheight);
|
ctxPtr->vlc_argv_str.push_back(cheight);
|
||||||
|
ctxPtr->vlc_argv.push_back(ctxPtr->vlc_argv_str[ctxPtr->vlc_argv_str.size()-1].c_str());
|
||||||
vlc_argv.push_back("--vmem-pitch");
|
vlc_argv.push_back("--vmem-pitch");
|
||||||
vlc_argv.push_back(cpitch);
|
ctxPtr->vlc_argv_str.push_back(cpitch);
|
||||||
|
ctxPtr->vlc_argv.push_back(ctxPtr->vlc_argv_str[ctxPtr->vlc_argv_str.size()-1].c_str());
|
||||||
vlc_argv.push_back("--vmem-chroma");
|
vlc_argv.push_back("--vmem-chroma");
|
||||||
vlc_argv.push_back("RV16");
|
vlc_argv.push_back("RV16");
|
||||||
vlc_argv.push_back("--vmem-lock");
|
vlc_argv.push_back("--vmem-lock");
|
||||||
vlc_argv.push_back(clock);
|
ctxPtr->vlc_argv_str.push_back(clock);
|
||||||
|
ctxPtr->vlc_argv.push_back(ctxPtr->vlc_argv_str[ctxPtr->vlc_argv_str.size()-1].c_str());
|
||||||
vlc_argv.push_back("--vmem-unlock");
|
vlc_argv.push_back("--vmem-unlock");
|
||||||
vlc_argv.push_back(cunlock);
|
ctxPtr->vlc_argv_str.push_back(cunlock);
|
||||||
|
ctxPtr->vlc_argv.push_back(ctxPtr->vlc_argv_str[ctxPtr->vlc_argv_str.size()-1].c_str());
|
||||||
vlc_argv.push_back("--vmem-data");
|
vlc_argv.push_back("--vmem-data");
|
||||||
vlc_argv.push_back(cdata);
|
ctxPtr->vlc_argv_str.push_back(cdata);
|
||||||
|
ctxPtr->vlc_argv.push_back(ctxPtr->vlc_argv_str[ctxPtr->vlc_argv_str.size()-1].c_str());
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(verboseEnabled) vlc_argv.push_back("--verbose=2");
|
if(verboseEnabled) ctxPtr->vlc_argv.push_back("--verbose=2");
|
||||||
if(verboseEnabled) vlc_argv.push_back("--extraintf=logger"); //log anything
|
if(verboseEnabled) ctxPtr->vlc_argv.push_back("--extraintf=logger"); //log anything
|
||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
if(verboseEnabled) _putenv("VLC_VERBOSE=2");
|
if(verboseEnabled) _putenv("VLC_VERBOSE=2");
|
||||||
#endif
|
#endif
|
||||||
int vlc_argc = vlc_argv.size();
|
int vlc_argc = ctxPtr->vlc_argv.size();
|
||||||
|
|
||||||
// char const *vlc_argv[] =
|
// char const *vlc_argv[] =
|
||||||
// {
|
// {
|
||||||
|
@ -266,27 +324,21 @@ void VideoPlayer::PlayVideo() {
|
||||||
// int vlc_argc = sizeof(vlc_argv) / sizeof(*vlc_argv);
|
// int vlc_argc = sizeof(vlc_argv) / sizeof(*vlc_argv);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SDL_Surface *empty = NULL;
|
ctxPtr->empty = NULL;
|
||||||
SDL_Event event;
|
|
||||||
|
|
||||||
int done = 0, action = 0, pause = 0, n = 0;
|
|
||||||
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
// Init Texture
|
// Init Texture
|
||||||
glGenTextures(1, &ctx.textureId);
|
glGenTextures(1, &ctxPtr->textureId);
|
||||||
glBindTexture(GL_TEXTURE_2D, ctx.textureId);
|
glBindTexture(GL_TEXTURE_2D, ctxPtr->textureId);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
|
||||||
empty = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height,
|
ctxPtr->empty = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height,
|
||||||
colorBits, 0, 0, 0, 0);
|
colorBits, 0, 0, 0, 0);
|
||||||
ctx.surf = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height,
|
ctxPtr->surf = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height,
|
||||||
colorBits, 0x001f, 0x07e0, 0xf800, 0);
|
colorBits, 0x001f, 0x07e0, 0xf800, 0);
|
||||||
ctx.mutex = SDL_CreateMutex();
|
ctxPtr->mutex = SDL_CreateMutex();
|
||||||
|
|
||||||
bool successLoadingVLC = false;
|
|
||||||
#ifdef HAS_LIBVLC
|
#ifdef HAS_LIBVLC
|
||||||
/*
|
/*
|
||||||
* Initialize libVLC
|
* Initialize libVLC
|
||||||
|
@ -297,13 +349,13 @@ void VideoPlayer::PlayVideo() {
|
||||||
libvlc_exception_t ex;
|
libvlc_exception_t ex;
|
||||||
libvlc_exception_init(&ex);
|
libvlc_exception_init(&ex);
|
||||||
|
|
||||||
libvlc = libvlc_new(vlc_argc, &vlc_argv[0],&ex);
|
ctxPtr->libvlc = libvlc_new(ctxPtr->vlc_argc, &ctxPtr->vlc_argv[0],&ex);
|
||||||
catchError(&ex);
|
catchError(&ex);
|
||||||
#else
|
#else
|
||||||
libvlc = libvlc_new(vlc_argc, &vlc_argv[0]);
|
ctxPtr->libvlc = libvlc_new(vlc_argc, &ctxPtr->vlc_argv[0]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(verboseEnabled) printf("In [%s] Line: %d, libvlc [%p]\n",__FUNCTION__,__LINE__,libvlc);
|
if(verboseEnabled) printf("In [%s] Line: %d, libvlc [%p]\n",__FUNCTION__,__LINE__,ctxPtr->libvlc);
|
||||||
|
|
||||||
/* It is meaningless to try all this because we have to restart mg to pickup new env vars
|
/* It is meaningless to try all this because we have to restart mg to pickup new env vars
|
||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
|
@ -354,6 +406,252 @@ void VideoPlayer::PlayVideo() {
|
||||||
#endif
|
#endif
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
if(ctxPtr->libvlc != NULL) {
|
||||||
|
#if defined(LIBVLC_VERSION_PRE_2) && defined(LIBVLC_VERSION_PRE_1_1_13)
|
||||||
|
ctxPtr->m = libvlc_media_new(ctxPtr->libvlc, filename.c_str(), &ex);
|
||||||
|
if(verboseEnabled) printf("In [%s] Line: %d, m [%p]\n",__FUNCTION__,__LINE__,ctxPtr->m);
|
||||||
|
|
||||||
|
catchError(&ex);
|
||||||
|
ctxPtr->mp = libvlc_media_player_new_from_media(ctxPtr->m);
|
||||||
|
if(verboseEnabled) printf("In [%s] Line: %d, mp [%p]\n",__FUNCTION__,__LINE__,ctxPtr->mp);
|
||||||
|
#else
|
||||||
|
/* Create a new item */
|
||||||
|
ctxPtr->m = libvlc_media_new_path(ctxPtr->libvlc, filename.c_str());
|
||||||
|
if(verboseEnabled) printf("In [%s] Line: %d, m [%p]\n",__FUNCTION__,__LINE__,ctxPtr->m);
|
||||||
|
|
||||||
|
ctxPtr->mp = libvlc_media_player_new_from_media(ctxPtr->m);
|
||||||
|
if(verboseEnabled) printf("In [%s] Line: %d, mp [%p]\n",__FUNCTION__,__LINE__,ctxPtr->mp);
|
||||||
|
#endif
|
||||||
|
libvlc_media_release(ctxPtr->m);
|
||||||
|
|
||||||
|
#if !defined(LIBVLC_VERSION_PRE_2) && !defined(LIBVLC_VERSION_PRE_1_1_13)
|
||||||
|
libvlc_video_set_callbacks(ctxPtr->mp, lock, unlock, display, ctxPtr);
|
||||||
|
libvlc_video_set_format(ctxPtr->mp, "RV16", width, height, this->surface->pitch);
|
||||||
|
|
||||||
|
// Get an event manager for the media player.
|
||||||
|
//libvlc_event_manager_t *eventManager = libvlc_media_player_event_manager(mp, &ex);
|
||||||
|
libvlc_event_manager_t *eventManager = libvlc_media_player_event_manager(ctxPtr->mp);
|
||||||
|
if(eventManager) {
|
||||||
|
// libvlc_event_attach(eventManager, libvlc_MediaPlayerPlaying, (libvlc_callback_t)trapPlayingEvent, NULL, &ex);
|
||||||
|
// libvlc_event_attach(eventManager, libvlc_MediaPlayerEndReached, (libvlc_callback_t)trapEndReachedEvent, NULL, &ex);
|
||||||
|
// libvlc_event_attach(eventManager, libvlc_MediaPlayerBuffering, (libvlc_callback_t)trapBufferingEvent, NULL, &ex);
|
||||||
|
// libvlc_event_attach(eventManager, libvlc_MediaPlayerEncounteredError, (libvlc_callback_t)trapErrorEvent, NULL, &ex);
|
||||||
|
libvlc_event_attach(eventManager, libvlc_MediaPlayerPlaying, (libvlc_callback_t)trapPlayingEvent, ctxPtr);
|
||||||
|
libvlc_event_attach(eventManager, libvlc_MediaPlayerEndReached, (libvlc_callback_t)trapEndReachedEvent, ctxPtr);
|
||||||
|
libvlc_event_attach(eventManager, libvlc_MediaPlayerBuffering, (libvlc_callback_t)trapBufferingEvent, ctxPtr);
|
||||||
|
libvlc_event_attach(eventManager, libvlc_MediaPlayerEncounteredError, (libvlc_callback_t)trapErrorEvent, ctxPtr);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ctxPtr->isPlaying = true;
|
||||||
|
#if defined(LIBVLC_VERSION_PRE_2) && defined(LIBVLC_VERSION_PRE_1_1_13)
|
||||||
|
int play_result = libvlc_media_player_play(ctxPtr->mp,&ex);
|
||||||
|
#else
|
||||||
|
int play_result = libvlc_media_player_play(ctxPtr->mp);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//SDL_Delay(5);
|
||||||
|
if(verboseEnabled) printf("In [%s] Line: %d, play_result [%d]\n",__FUNCTION__,__LINE__,play_result);
|
||||||
|
|
||||||
|
successLoadingLib = (play_result == 0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return successLoadingLib;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VideoPlayer::closePlayer() {
|
||||||
|
#ifdef HAS_LIBVLC
|
||||||
|
if(ctxPtr->libvlc != NULL) {
|
||||||
|
//
|
||||||
|
// Stop stream and clean up libVLC
|
||||||
|
//
|
||||||
|
#if defined(LIBVLC_VERSION_PRE_2) && defined(LIBVLC_VERSION_PRE_1_1_13)
|
||||||
|
libvlc_media_player_stop(ctxPtr->mp,&ex);
|
||||||
|
catchError(&ex);
|
||||||
|
#else
|
||||||
|
libvlc_media_player_stop(ctxPtr->mp);
|
||||||
|
#endif
|
||||||
|
libvlc_media_player_release(ctxPtr->mp);
|
||||||
|
libvlc_release(ctxPtr->libvlc);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//
|
||||||
|
// Close window and clean up libSDL
|
||||||
|
//
|
||||||
|
if(ctxPtr->mutex != NULL) {
|
||||||
|
SDL_DestroyMutex(ctxPtr->mutex);
|
||||||
|
}
|
||||||
|
if(ctxPtr->surf != NULL) {
|
||||||
|
SDL_FreeSurface(ctxPtr->surf);
|
||||||
|
}
|
||||||
|
if(ctxPtr->empty != NULL) {
|
||||||
|
SDL_FreeSurface(ctxPtr->empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
glDeleteTextures(1, &ctxPtr->textureId);
|
||||||
|
|
||||||
|
if(ctxPtr->needToQuit == true) {
|
||||||
|
SDL_Event quit_event = {SDL_QUIT};
|
||||||
|
SDL_PushEvent(&quit_event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VideoPlayer::PlayVideo() {
|
||||||
|
/*
|
||||||
|
#ifdef HAS_LIBVLC
|
||||||
|
libvlc_instance_t *libvlc = NULL;
|
||||||
|
libvlc_media_t *m = NULL;
|
||||||
|
libvlc_media_player_t *mp = NULL;
|
||||||
|
|
||||||
|
// string pluginParam = "";
|
||||||
|
// if(pluginsPath != "") {
|
||||||
|
// pluginParam = "--plugin-path=" + pluginsPath;
|
||||||
|
// }
|
||||||
|
|
||||||
|
std::vector<const char *> vlc_argv;
|
||||||
|
vlc_argv.push_back("--intf=dummy");
|
||||||
|
vlc_argv.push_back("--no-media-library");
|
||||||
|
vlc_argv.push_back("--ignore-config"); // Don't use VLC's config
|
||||||
|
vlc_argv.push_back("--no-xlib"); // tell VLC to not use Xlib
|
||||||
|
vlc_argv.push_back("--no-video-title-show");
|
||||||
|
#if defined(LIBVLC_VERSION_PRE_2)
|
||||||
|
string fullPluginsParam = "--plugin-path=" + pluginsPath;
|
||||||
|
vlc_argv.push_back(fullPluginsParam.c_str());
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(LIBVLC_VERSION_PRE_2) && defined(LIBVLC_VERSION_PRE_1_1_13)
|
||||||
|
char clock[64], cunlock[64], cdata[64];
|
||||||
|
char cwidth[32], cheight[32], cpitch[32];
|
||||||
|
//
|
||||||
|
// Initialise libVLC
|
||||||
|
//
|
||||||
|
sprintf(clock, "%lld", (long long int)(intptr_t)lock);
|
||||||
|
sprintf(cunlock, "%lld", (long long int)(intptr_t)unlock);
|
||||||
|
sprintf(cdata, "%lld", (long long int)(intptr_t)ctxPtr);
|
||||||
|
sprintf(cwidth, "%i", width);
|
||||||
|
sprintf(cheight, "%i", height);
|
||||||
|
sprintf(cpitch, "%i", colorBits);
|
||||||
|
|
||||||
|
vlc_argv.push_back("--vout");
|
||||||
|
vlc_argv.push_back("vmem");
|
||||||
|
vlc_argv.push_back("--vmem-width");
|
||||||
|
vlc_argv.push_back(cwidth);
|
||||||
|
vlc_argv.push_back("--vmem-height");
|
||||||
|
vlc_argv.push_back(cheight);
|
||||||
|
vlc_argv.push_back("--vmem-pitch");
|
||||||
|
vlc_argv.push_back(cpitch);
|
||||||
|
vlc_argv.push_back("--vmem-chroma");
|
||||||
|
vlc_argv.push_back("RV16");
|
||||||
|
vlc_argv.push_back("--vmem-lock");
|
||||||
|
vlc_argv.push_back(clock);
|
||||||
|
vlc_argv.push_back("--vmem-unlock");
|
||||||
|
vlc_argv.push_back(cunlock);
|
||||||
|
vlc_argv.push_back("--vmem-data");
|
||||||
|
vlc_argv.push_back(cdata);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(verboseEnabled) vlc_argv.push_back("--verbose=2");
|
||||||
|
if(verboseEnabled) vlc_argv.push_back("--extraintf=logger"); //log anything
|
||||||
|
#if defined(WIN32)
|
||||||
|
if(verboseEnabled) _putenv("VLC_VERBOSE=2");
|
||||||
|
#endif
|
||||||
|
int vlc_argc = vlc_argv.size();
|
||||||
|
|
||||||
|
// char const *vlc_argv[] =
|
||||||
|
// {
|
||||||
|
// //"--no-audio", // skip any audio track
|
||||||
|
// "--no-xlib", // tell VLC to not use Xlib
|
||||||
|
// "--no-video-title-show",
|
||||||
|
// pluginParam.c_str(),
|
||||||
|
// };
|
||||||
|
// int vlc_argc = sizeof(vlc_argv) / sizeof(*vlc_argv);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
SDL_Surface *empty = NULL;
|
||||||
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
// Init Texture
|
||||||
|
glGenTextures(1, &ctxPtr->textureId);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, ctxPtr->textureId);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
|
||||||
|
empty = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height,
|
||||||
|
colorBits, 0, 0, 0, 0);
|
||||||
|
ctxPtr->surf = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height,
|
||||||
|
colorBits, 0x001f, 0x07e0, 0xf800, 0);
|
||||||
|
ctxPtr->mutex = SDL_CreateMutex();
|
||||||
|
|
||||||
|
#ifdef HAS_LIBVLC
|
||||||
|
//
|
||||||
|
// Initialize libVLC
|
||||||
|
//
|
||||||
|
if(verboseEnabled) printf("Trying [%s]\n",getenv("VLC_PLUGIN_PATH"));
|
||||||
|
|
||||||
|
#if defined(LIBVLC_VERSION_PRE_2) && defined(LIBVLC_VERSION_PRE_1_1_13)
|
||||||
|
libvlc_exception_t ex;
|
||||||
|
libvlc_exception_init(&ex);
|
||||||
|
|
||||||
|
libvlc = libvlc_new(vlc_argc, &vlc_argv[0],&ex);
|
||||||
|
catchError(&ex);
|
||||||
|
#else
|
||||||
|
libvlc = libvlc_new(vlc_argc, &vlc_argv[0]);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(verboseEnabled) printf("In [%s] Line: %d, libvlc [%p]\n",__FUNCTION__,__LINE__,libvlc);
|
||||||
|
|
||||||
|
// It is meaningless to try all this because we have to restart mg to pickup new env vars
|
||||||
|
#if defined(WIN32)
|
||||||
|
if(libvlc == NULL) {
|
||||||
|
// For windows check registry for install path
|
||||||
|
std::string strValue = getRegKey("Software\\VideoLAN\\VLC", "InstallDir");
|
||||||
|
if(strValue != "") {
|
||||||
|
if(strValue.length() >= 2) {
|
||||||
|
if(strValue[0] == '"') {
|
||||||
|
strValue = strValue.erase(0);
|
||||||
|
}
|
||||||
|
if(strValue[strValue.length()-1] == '"') {
|
||||||
|
strValue = strValue.erase(strValue.length()-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
strValue = "VLC_PLUGIN_PATH=" + strValue;
|
||||||
|
_putenv(strValue.c_str());
|
||||||
|
|
||||||
|
if(verboseEnabled) printf("Trying [%s]\n",getenv("VLC_PLUGIN_PATH"));
|
||||||
|
libvlc = libvlc_new(vlc_argc, &vlc_argv[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(libvlc == NULL) {
|
||||||
|
_putenv("VLC_PLUGIN_PATH=c:\\program files\\videolan\\vlc\\plugins");
|
||||||
|
|
||||||
|
if(verboseEnabled) printf("Trying [%s]\n",getenv("VLC_PLUGIN_PATH"));
|
||||||
|
libvlc = libvlc_new(vlc_argc, &vlc_argv[0]);
|
||||||
|
}
|
||||||
|
if(libvlc == NULL) {
|
||||||
|
_putenv("VLC_PLUGIN_PATH=\\program files\\videolan\\vlc\\plugins");
|
||||||
|
|
||||||
|
if(verboseEnabled) printf("Trying [%s]\n",getenv("VLC_PLUGIN_PATH"));
|
||||||
|
libvlc = libvlc_new(vlc_argc, &vlc_argv[0]);
|
||||||
|
}
|
||||||
|
if(libvlc == NULL) {
|
||||||
|
_putenv("VLC_PLUGIN_PATH=c:\\program files (x86)\\videolan\\vlc\\plugins");
|
||||||
|
|
||||||
|
if(verboseEnabled) printf("Trying [%s]\n",getenv("VLC_PLUGIN_PATH"));
|
||||||
|
libvlc = libvlc_new(vlc_argc, &vlc_argv[0]);
|
||||||
|
}
|
||||||
|
if(libvlc == NULL) {
|
||||||
|
_putenv("VLC_PLUGIN_PATH=\\program files (x86)\\videolan\\vlc\\plugins");
|
||||||
|
|
||||||
|
if(verboseEnabled) printf("Trying [%s]\n",getenv("VLC_PLUGIN_PATH"));
|
||||||
|
libvlc = libvlc_new(vlc_argc, &vlc_argv[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
//
|
||||||
|
|
||||||
if(libvlc != NULL) {
|
if(libvlc != NULL) {
|
||||||
#if defined(LIBVLC_VERSION_PRE_2) && defined(LIBVLC_VERSION_PRE_1_1_13)
|
#if defined(LIBVLC_VERSION_PRE_2) && defined(LIBVLC_VERSION_PRE_1_1_13)
|
||||||
m = libvlc_media_new(libvlc, filename.c_str(), &ex);
|
m = libvlc_media_new(libvlc, filename.c_str(), &ex);
|
||||||
|
@ -363,7 +661,7 @@ void VideoPlayer::PlayVideo() {
|
||||||
mp = libvlc_media_player_new_from_media(m);
|
mp = libvlc_media_player_new_from_media(m);
|
||||||
if(verboseEnabled) printf("In [%s] Line: %d, mp [%p]\n",__FUNCTION__,__LINE__,mp);
|
if(verboseEnabled) printf("In [%s] Line: %d, mp [%p]\n",__FUNCTION__,__LINE__,mp);
|
||||||
#else
|
#else
|
||||||
/* Create a new item */
|
// Create a new item
|
||||||
m = libvlc_media_new_path(libvlc, filename.c_str());
|
m = libvlc_media_new_path(libvlc, filename.c_str());
|
||||||
if(verboseEnabled) printf("In [%s] Line: %d, m [%p]\n",__FUNCTION__,__LINE__,m);
|
if(verboseEnabled) printf("In [%s] Line: %d, m [%p]\n",__FUNCTION__,__LINE__,m);
|
||||||
|
|
||||||
|
@ -373,7 +671,7 @@ void VideoPlayer::PlayVideo() {
|
||||||
libvlc_media_release(m);
|
libvlc_media_release(m);
|
||||||
|
|
||||||
#if !defined(LIBVLC_VERSION_PRE_2) && !defined(LIBVLC_VERSION_PRE_1_1_13)
|
#if !defined(LIBVLC_VERSION_PRE_2) && !defined(LIBVLC_VERSION_PRE_1_1_13)
|
||||||
libvlc_video_set_callbacks(mp, lock, unlock, display, &ctx);
|
libvlc_video_set_callbacks(mp, lock, unlock, display, ctxPtr);
|
||||||
libvlc_video_set_format(mp, "RV16", width, height, this->surface->pitch);
|
libvlc_video_set_format(mp, "RV16", width, height, this->surface->pitch);
|
||||||
|
|
||||||
// Get an event manager for the media player.
|
// Get an event manager for the media player.
|
||||||
|
@ -384,14 +682,14 @@ void VideoPlayer::PlayVideo() {
|
||||||
// libvlc_event_attach(eventManager, libvlc_MediaPlayerEndReached, (libvlc_callback_t)trapEndReachedEvent, NULL, &ex);
|
// libvlc_event_attach(eventManager, libvlc_MediaPlayerEndReached, (libvlc_callback_t)trapEndReachedEvent, NULL, &ex);
|
||||||
// libvlc_event_attach(eventManager, libvlc_MediaPlayerBuffering, (libvlc_callback_t)trapBufferingEvent, NULL, &ex);
|
// libvlc_event_attach(eventManager, libvlc_MediaPlayerBuffering, (libvlc_callback_t)trapBufferingEvent, NULL, &ex);
|
||||||
// libvlc_event_attach(eventManager, libvlc_MediaPlayerEncounteredError, (libvlc_callback_t)trapErrorEvent, NULL, &ex);
|
// libvlc_event_attach(eventManager, libvlc_MediaPlayerEncounteredError, (libvlc_callback_t)trapErrorEvent, NULL, &ex);
|
||||||
libvlc_event_attach(eventManager, libvlc_MediaPlayerPlaying, (libvlc_callback_t)trapPlayingEvent, &ctx);
|
libvlc_event_attach(eventManager, libvlc_MediaPlayerPlaying, (libvlc_callback_t)trapPlayingEvent, ctxPtr);
|
||||||
libvlc_event_attach(eventManager, libvlc_MediaPlayerEndReached, (libvlc_callback_t)trapEndReachedEvent, &ctx);
|
libvlc_event_attach(eventManager, libvlc_MediaPlayerEndReached, (libvlc_callback_t)trapEndReachedEvent, ctxPtr);
|
||||||
libvlc_event_attach(eventManager, libvlc_MediaPlayerBuffering, (libvlc_callback_t)trapBufferingEvent, &ctx);
|
libvlc_event_attach(eventManager, libvlc_MediaPlayerBuffering, (libvlc_callback_t)trapBufferingEvent, ctxPtr);
|
||||||
libvlc_event_attach(eventManager, libvlc_MediaPlayerEncounteredError, (libvlc_callback_t)trapErrorEvent, &ctx);
|
libvlc_event_attach(eventManager, libvlc_MediaPlayerEncounteredError, (libvlc_callback_t)trapErrorEvent, ctxPtr);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ctx.isPlaying = true;
|
ctxPtr->isPlaying = true;
|
||||||
#if defined(LIBVLC_VERSION_PRE_2) && defined(LIBVLC_VERSION_PRE_1_1_13)
|
#if defined(LIBVLC_VERSION_PRE_2) && defined(LIBVLC_VERSION_PRE_1_1_13)
|
||||||
int play_result = libvlc_media_player_play(mp,&ex);
|
int play_result = libvlc_media_player_play(mp,&ex);
|
||||||
#else
|
#else
|
||||||
|
@ -401,77 +699,24 @@ void VideoPlayer::PlayVideo() {
|
||||||
//SDL_Delay(5);
|
//SDL_Delay(5);
|
||||||
if(verboseEnabled) printf("In [%s] Line: %d, play_result [%d]\n",__FUNCTION__,__LINE__,play_result);
|
if(verboseEnabled) printf("In [%s] Line: %d, play_result [%d]\n",__FUNCTION__,__LINE__,play_result);
|
||||||
|
|
||||||
successLoadingVLC = (play_result == 0);
|
successLoadingLib = (play_result == 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
//
|
||||||
* Main loop
|
/ Main loop
|
||||||
*/
|
//
|
||||||
|
//int done = 0, action = 0, pause = 0, n = 0;
|
||||||
bool needToQuit = false;
|
bool needToQuit = false;
|
||||||
while(successLoadingVLC == true && ctx.isPlaying == true &&
|
while(isPlaying() == true) {
|
||||||
done == 0 && stop == false) {
|
needToQuit = playFrame();
|
||||||
action = 0;
|
|
||||||
|
|
||||||
/* Keys: enter (fullscreen), space (pause), escape (quit) */
|
|
||||||
while( SDL_PollEvent( &event ) ) {
|
|
||||||
switch(event.type) {
|
|
||||||
case SDL_QUIT:
|
|
||||||
done = 1;
|
|
||||||
needToQuit = true;
|
|
||||||
break;
|
|
||||||
case SDL_KEYDOWN:
|
|
||||||
action = event.key.keysym.sym;
|
|
||||||
break;
|
|
||||||
case SDL_MOUSEBUTTONDOWN:
|
|
||||||
done = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!done && stop == false) {
|
|
||||||
switch(action) {
|
|
||||||
case SDLK_ESCAPE:
|
|
||||||
done = 1;
|
|
||||||
break;
|
|
||||||
case SDLK_RETURN:
|
|
||||||
//options ^= SDL_FULLSCREEN;
|
|
||||||
//screen = SDL_SetVideoMode(WIDTH, HEIGHT, 0, options);
|
|
||||||
done = 1;
|
|
||||||
break;
|
|
||||||
case ' ':
|
|
||||||
//pause = !pause;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!pause) {
|
|
||||||
n++;
|
|
||||||
}
|
|
||||||
|
|
||||||
loadTexture(&ctx); // Loading the texture
|
|
||||||
|
|
||||||
// Square
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
glTexCoord2d(0, 1);
|
|
||||||
glVertex2f(-0.85, 0.85);
|
|
||||||
glTexCoord2d(1, 1);
|
|
||||||
glVertex2f(0.85, 0.85);
|
|
||||||
glTexCoord2d(1, 0);
|
|
||||||
glVertex2f(0.85, -0.85);
|
|
||||||
glTexCoord2d(0, 0);
|
|
||||||
glVertex2f(-0.85, -0.85);
|
|
||||||
glEnd();
|
|
||||||
|
|
||||||
SDL_GL_SwapBuffers();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAS_LIBVLC
|
#ifdef HAS_LIBVLC
|
||||||
if(libvlc != NULL) {
|
if(libvlc != NULL) {
|
||||||
/*
|
//
|
||||||
* Stop stream and clean up libVLC
|
/ Stop stream and clean up libVLC
|
||||||
*/
|
//
|
||||||
#if defined(LIBVLC_VERSION_PRE_2) && defined(LIBVLC_VERSION_PRE_1_1_13)
|
#if defined(LIBVLC_VERSION_PRE_2) && defined(LIBVLC_VERSION_PRE_1_1_13)
|
||||||
libvlc_media_player_stop(mp,&ex);
|
libvlc_media_player_stop(mp,&ex);
|
||||||
catchError(&ex);
|
catchError(&ex);
|
||||||
|
@ -483,18 +728,168 @@ void VideoPlayer::PlayVideo() {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
//
|
||||||
* Close window and clean up libSDL
|
/ Close window and clean up libSDL
|
||||||
*/
|
//
|
||||||
SDL_DestroyMutex(ctx.mutex);
|
SDL_DestroyMutex(ctxPtr->mutex);
|
||||||
SDL_FreeSurface(ctx.surf);
|
SDL_FreeSurface(ctxPtr->surf);
|
||||||
SDL_FreeSurface(empty);
|
SDL_FreeSurface(empty);
|
||||||
|
|
||||||
glDeleteTextures(1, &ctx.textureId);
|
glDeleteTextures(1, &ctxPtr->textureId);
|
||||||
free(ctx.rawData);
|
|
||||||
|
|
||||||
if(needToQuit == true) {
|
if(needToQuit == true) {
|
||||||
SDL_Event quit_event = {SDL_QUIT};
|
SDL_Event quit_event = {SDL_QUIT};
|
||||||
SDL_PushEvent(&quit_event);
|
SDL_PushEvent(&quit_event);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
initPlayer();
|
||||||
|
for(;isPlaying() == true;) {
|
||||||
|
playFrame();
|
||||||
}
|
}
|
||||||
|
closePlayer();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool VideoPlayer::isPlaying() const {
|
||||||
|
bool result = (successLoadingLib == true &&
|
||||||
|
ctxPtr != NULL && ctxPtr->isPlaying == true &&
|
||||||
|
finished == false && stop == false);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool VideoPlayer::playFrame(bool swapBuffers) {
|
||||||
|
//bool needToQuit = false;
|
||||||
|
int action = 0, pause = 0, n = 0;
|
||||||
|
if(successLoadingLib == true &&
|
||||||
|
ctxPtr != NULL && ctxPtr->isPlaying == true &&
|
||||||
|
finished == false && stop == false) {
|
||||||
|
action = 0;
|
||||||
|
|
||||||
|
SDL_Event event;
|
||||||
|
/* Keys: enter (fullscreen), space (pause), escape (quit) */
|
||||||
|
while( SDL_PollEvent( &event ) ) {
|
||||||
|
switch(event.type) {
|
||||||
|
case SDL_QUIT:
|
||||||
|
finished = true;
|
||||||
|
ctxPtr->needToQuit = true;
|
||||||
|
break;
|
||||||
|
case SDL_KEYDOWN:
|
||||||
|
action = event.key.keysym.sym;
|
||||||
|
break;
|
||||||
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
|
finished = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(finished == false && stop == false) {
|
||||||
|
switch(action) {
|
||||||
|
case SDLK_ESCAPE:
|
||||||
|
finished = true;
|
||||||
|
break;
|
||||||
|
case SDLK_RETURN:
|
||||||
|
//options ^= SDL_FULLSCREEN;
|
||||||
|
//screen = SDL_SetVideoMode(WIDTH, HEIGHT, 0, options);
|
||||||
|
finished = true;
|
||||||
|
break;
|
||||||
|
case ' ':
|
||||||
|
//pause = !pause;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(pause == 0) {
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
|
||||||
|
//assertGl();
|
||||||
|
|
||||||
|
glPushAttrib(GL_ENABLE_BIT);
|
||||||
|
|
||||||
|
//glDisable(GL_LIGHTING);
|
||||||
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
glEnable(GL_BLEND);
|
||||||
|
|
||||||
|
loadTexture(ctxPtr); // Loading the texture
|
||||||
|
// Square
|
||||||
|
// glBegin(GL_QUADS);
|
||||||
|
// glTexCoord2d(0, 1);
|
||||||
|
// glVertex2f(-0.85, 0.85);
|
||||||
|
// glTexCoord2d(1, 1);
|
||||||
|
// glVertex2f(0.85, 0.85);
|
||||||
|
// glTexCoord2d(1, 0);
|
||||||
|
// glVertex2f(0.85, -0.85);
|
||||||
|
// glTexCoord2d(0, 0);
|
||||||
|
// glVertex2f(-0.85, -0.85);
|
||||||
|
// glEnd();
|
||||||
|
|
||||||
|
// glBegin(GL_TRIANGLE_STRIP);
|
||||||
|
// glTexCoord2i(0, 1);
|
||||||
|
// glVertex2i(1, 1+600);
|
||||||
|
// glTexCoord2i(0, 0);
|
||||||
|
// glVertex2i(1, 1);
|
||||||
|
// glTexCoord2i(1, 1);
|
||||||
|
// glVertex2i(1+800, 1+600);
|
||||||
|
// glTexCoord2i(1, 0);
|
||||||
|
// glVertex2i(1+800, 600);
|
||||||
|
// glEnd();
|
||||||
|
|
||||||
|
// glBegin(GL_TRIANGLE_STRIP);
|
||||||
|
// glTexCoord2i(0, 1);
|
||||||
|
// glVertex2i(ctxPtr->x, ctxPtr->y + ctxPtr->height);
|
||||||
|
// glTexCoord2i(0, 0);
|
||||||
|
// glVertex2i(ctxPtr->x, ctxPtr->y);
|
||||||
|
// glTexCoord2i(1, 1);
|
||||||
|
// glVertex2i(ctxPtr->x + ctxPtr->width, ctxPtr->y + ctxPtr->height);
|
||||||
|
// glTexCoord2i(1, 0);
|
||||||
|
// glVertex2i(ctxPtr->x + ctxPtr->width, ctxPtr->y);
|
||||||
|
// glEnd();
|
||||||
|
|
||||||
|
if(ctxPtr->x == -1 || ctxPtr->y == -1) {
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
glTexCoord2d(0, 1);
|
||||||
|
glVertex2f(-0.85, 0.85);
|
||||||
|
glTexCoord2d(1, 1);
|
||||||
|
glVertex2f(0.85, 0.85);
|
||||||
|
glTexCoord2d(1, 0);
|
||||||
|
glVertex2f(0.85, -0.85);
|
||||||
|
glTexCoord2d(0, 0);
|
||||||
|
glVertex2f(-0.85, -0.85);
|
||||||
|
glEnd();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// glBegin(GL_QUADS);
|
||||||
|
// glTexCoord2d(0, 1);
|
||||||
|
// glVertex2f(ctxPtr->x, ctxPtr->y + ctxPtr->height);
|
||||||
|
// glTexCoord2d(1, 1);
|
||||||
|
// glVertex2f(ctxPtr->x + ctxPtr->width, ctxPtr->y + ctxPtr->height);
|
||||||
|
// glTexCoord2d(1, 0);
|
||||||
|
// glVertex2f(ctxPtr->x + ctxPtr->width, ctxPtr->y);
|
||||||
|
// glTexCoord2d(0, 0);
|
||||||
|
// glVertex2f(ctxPtr->x, ctxPtr->y);
|
||||||
|
// glEnd();
|
||||||
|
|
||||||
|
glBegin(GL_TRIANGLE_STRIP);
|
||||||
|
glTexCoord2i(0, 1);
|
||||||
|
glVertex2i(ctxPtr->x, ctxPtr->y + ctxPtr->height * 0.80);
|
||||||
|
glTexCoord2i(0, 0);
|
||||||
|
glVertex2i(ctxPtr->x, ctxPtr->y);
|
||||||
|
glTexCoord2i(1, 1);
|
||||||
|
glVertex2i(ctxPtr->x+ctxPtr->width * 0.60, ctxPtr->y+ctxPtr->height * 0.80);
|
||||||
|
glTexCoord2i(1, 0);
|
||||||
|
glVertex2i(ctxPtr->x+ctxPtr->width * 0.60, ctxPtr->y);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
glPopAttrib();
|
||||||
|
|
||||||
|
if(swapBuffers == true) {
|
||||||
|
SDL_GL_SwapBuffers();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ctxPtr->needToQuit;
|
||||||
|
}
|
||||||
|
|
||||||
|
}}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user