wololo
- Adding DJardin's port to N900
This commit is contained in:
+95
-18
@@ -245,7 +245,11 @@ void JMD2Model::CalculateNormal(ScePspFVector3 *normal, float *p1, float *p2, fl
|
||||
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
// normalize and specify the normal
|
||||
#if (!defined GL_ES_VERSION_2_0) && (!defined GL_VERSION_2_0)
|
||||
glNormal3f(result[0]/length, result[1]/length, result[2]/length);
|
||||
#else
|
||||
// FIXME
|
||||
#endif //(!defined GL_ES_VERSION_2_0) && (!defined GL_VERSION_2_0)
|
||||
|
||||
#else
|
||||
if (length == 0.0f)
|
||||
@@ -275,15 +279,45 @@ void JMD2Model::Render(int frameNum)
|
||||
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
|
||||
|
||||
// display the textured model with proper lighting normals
|
||||
glBegin(GL_TRIANGLES);
|
||||
#if (defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0)
|
||||
|
||||
#elif (defined GL_ES_VERSION_1_1) || (defined GL_VERSION_1_1)
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
#else
|
||||
glBegin(GL_TRIANGLES);
|
||||
#endif //(defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0)
|
||||
|
||||
for(i = 0; i < mModel->numTriangles; i++)
|
||||
{
|
||||
CalculateNormal(pointList[mModel->triIndex[i].meshIndex[0]].v,
|
||||
pointList[mModel->triIndex[i].meshIndex[2]].v,
|
||||
pointList[mModel->triIndex[i].meshIndex[1]].v);
|
||||
glTexCoord2f(mModel->st[mModel->triIndex[i].stIndex[0]].s,
|
||||
|
||||
#if (defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0)
|
||||
|
||||
#elif (defined GL_ES_VERSION_1_1) || (defined GL_VERSION_1_1)
|
||||
float vertex_data[]={
|
||||
pointList[mModel->triIndex[i].meshIndex[0]].x, pointList[mModel->triIndex[i].meshIndex[0]].y, pointList[mModel->triIndex[i].meshIndex[0]].z,
|
||||
pointList[mModel->triIndex[i].meshIndex[2]].x, pointList[mModel->triIndex[i].meshIndex[2]].y, pointList[mModel->triIndex[i].meshIndex[2]].z,
|
||||
pointList[mModel->triIndex[i].meshIndex[1]].x, pointList[mModel->triIndex[i].meshIndex[1]].y, pointList[mModel->triIndex[i].meshIndex[1]].z,
|
||||
};
|
||||
float texcoord_data[] = {
|
||||
mModel->st[mModel->triIndex[i].stIndex[0]].s,
|
||||
mModel->st[mModel->triIndex[i].stIndex[0]].t,
|
||||
mModel->st[mModel->triIndex[i].stIndex[2]].s,
|
||||
mModel->st[mModel->triIndex[i].stIndex[2]].t,
|
||||
mModel->st[mModel->triIndex[i].stIndex[1]].s,
|
||||
mModel->st[mModel->triIndex[i].stIndex[1]].t,
|
||||
};
|
||||
|
||||
glVertexPointer(3,GL_FLOAT,0,vertex_data);
|
||||
glTexCoordPointer(2,GL_FLOAT,0,texcoord_data);
|
||||
|
||||
#else
|
||||
glTexCoord2f(mModel->st[mModel->triIndex[i].stIndex[0]].s,
|
||||
mModel->st[mModel->triIndex[i].stIndex[0]].t);
|
||||
glVertex3fv(pointList[mModel->triIndex[i].meshIndex[0]].v);
|
||||
|
||||
@@ -294,8 +328,15 @@ void JMD2Model::Render(int frameNum)
|
||||
glTexCoord2f(mModel->st[mModel->triIndex[i].stIndex[1]].s,
|
||||
mModel->st[mModel->triIndex[i].stIndex[1]].t);
|
||||
glVertex3fv(pointList[mModel->triIndex[i].meshIndex[1]].v);
|
||||
}
|
||||
glEnd();
|
||||
#endif //#if (!defined GL_ES_VERSION_2_0) && (!defined GL_VERSION_2_0)
|
||||
}
|
||||
#if (defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0)
|
||||
|
||||
#elif (defined GL_ES_VERSION_1_1) || (defined GL_VERSION_1_1)
|
||||
glDrawArrays(GL_TRIANGLES,0,3); // seems suspicious to put that here, should probably be in the loop
|
||||
#else
|
||||
glEnd();
|
||||
#endif //(defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0)
|
||||
|
||||
|
||||
#else
|
||||
@@ -442,9 +483,16 @@ void JMD2Model::Render()
|
||||
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
|
||||
#if (defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0)
|
||||
// FIXME
|
||||
#elif (defined GL_ES_VERSION_1_1) || (defined GL_VERSION_1_1)
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
#else
|
||||
glBegin(GL_TRIANGLES);
|
||||
#endif //(defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0)
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
for (i = 0; i < mModel->numTriangles; i++)
|
||||
for (i = 0; i < mModel->numTriangles; i++)
|
||||
{
|
||||
// get first points of each frame
|
||||
x1 = pointList[mModel->triIndex[i].meshIndex[0]].x;
|
||||
@@ -489,19 +537,48 @@ void JMD2Model::Render()
|
||||
//CalculateNormal(vertex[0].v, vertex[2].v, vertex[1].v);
|
||||
|
||||
// render properly textured triangle
|
||||
glTexCoord2f(mModel->st[mModel->triIndex[i].stIndex[0]].s,
|
||||
mModel->st[mModel->triIndex[i].stIndex[0]].t);
|
||||
glVertex3fv(vertex[0].v);
|
||||
|
||||
glTexCoord2f(mModel->st[mModel->triIndex[i].stIndex[2]].s ,
|
||||
mModel->st[mModel->triIndex[i].stIndex[2]].t);
|
||||
glVertex3fv(vertex[2].v);
|
||||
#if (defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0)
|
||||
// FIXME
|
||||
#elif (defined GL_ES_VERSION_1_1) || (defined GL_VERSION_1_1)
|
||||
float vertex_data[]={
|
||||
vertex[0].x, vertex[0].y, vertex[0].z,
|
||||
vertex[2].x, vertex[2].y, vertex[2].z,
|
||||
vertex[1].x, vertex[1].y, vertex[1].z,
|
||||
};
|
||||
float texcoord_data[] = {
|
||||
mModel->st[mModel->triIndex[i].stIndex[0]].s,
|
||||
mModel->st[mModel->triIndex[i].stIndex[0]].t,
|
||||
mModel->st[mModel->triIndex[i].stIndex[2]].s,
|
||||
mModel->st[mModel->triIndex[i].stIndex[2]].t,
|
||||
mModel->st[mModel->triIndex[i].stIndex[1]].s,
|
||||
mModel->st[mModel->triIndex[i].stIndex[1]].t,
|
||||
};
|
||||
|
||||
glTexCoord2f(mModel->st[mModel->triIndex[i].stIndex[1]].s,
|
||||
mModel->st[mModel->triIndex[i].stIndex[1]].t);
|
||||
glVertex3fv(vertex[1].v);
|
||||
}
|
||||
glEnd();
|
||||
glVertexPointer(3,GL_FLOAT,0,vertex_data);
|
||||
glTexCoordPointer(2,GL_FLOAT,0,texcoord_data);
|
||||
#else
|
||||
glTexCoord2f(mModel->st[mModel->triIndex[i].stIndex[0]].s,
|
||||
mModel->st[mModel->triIndex[i].stIndex[0]].t);
|
||||
glVertex3fv(vertex[0].v);
|
||||
|
||||
glTexCoord2f(mModel->st[mModel->triIndex[i].stIndex[2]].s ,
|
||||
mModel->st[mModel->triIndex[i].stIndex[2]].t);
|
||||
glVertex3fv(vertex[2].v);
|
||||
|
||||
glTexCoord2f(mModel->st[mModel->triIndex[i].stIndex[1]].s,
|
||||
mModel->st[mModel->triIndex[i].stIndex[1]].t);
|
||||
glVertex3fv(vertex[1].v);
|
||||
#endif //(defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0)
|
||||
|
||||
}
|
||||
#if (defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0)
|
||||
// FIXME
|
||||
#elif (defined GL_ES_VERSION_1_1) || (defined GL_VERSION_1_1)
|
||||
glDrawArrays(GL_TRIANGLES,0,3); // seems suspicious to put that here, should probably be in the loop
|
||||
#else
|
||||
glEnd();
|
||||
#endif //(defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0)
|
||||
|
||||
#else
|
||||
|
||||
|
||||
@@ -0,0 +1,272 @@
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <QtOpenGL>
|
||||
#include <QTime>
|
||||
#include "../include/JGE.h"
|
||||
#include "../include/JTypes.h"
|
||||
#include "../include/JApp.h"
|
||||
#include "../include/JFileSystem.h"
|
||||
#include "../include/JRenderer.h"
|
||||
#include "../include/JGameLauncher.h"
|
||||
|
||||
#define ACTUAL_SCREEN_WIDTH (SCREEN_WIDTH)
|
||||
#define ACTUAL_SCREEN_HEIGHT (SCREEN_HEIGHT)
|
||||
#define ACTUAL_RATIO ((GLfloat)ACTUAL_SCREEN_WIDTH / (GLfloat)ACTUAL_SCREEN_HEIGHT)
|
||||
|
||||
class JGEQtRenderer : public QGLWidget
|
||||
{
|
||||
// Q_OBJECT // must include this if you use Qt signals/slots
|
||||
|
||||
public:
|
||||
JGEQtRenderer(QWidget *parent);
|
||||
|
||||
protected:
|
||||
|
||||
void initializeGL();
|
||||
|
||||
void resizeGL(int w, int h);
|
||||
|
||||
void paintGL();
|
||||
|
||||
void timerEvent( QTimerEvent* );
|
||||
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
|
||||
void keyReleaseEvent(QKeyEvent *event);
|
||||
};
|
||||
|
||||
uint64_t lastTickCount;
|
||||
JGE* g_engine = NULL;
|
||||
JApp* g_app = NULL;
|
||||
JGameLauncher* g_launcher = NULL;
|
||||
JGEQtRenderer *g_glwidget = NULL;
|
||||
|
||||
static const struct { LocalKeySym keysym; JButton keycode; } gDefaultBindings[] =
|
||||
{
|
||||
{ Qt::Key_Enter, JGE_BTN_MENU },
|
||||
{ Qt::Key_Backspace, JGE_BTN_CTRL },
|
||||
{ Qt::Key_Up, JGE_BTN_UP },
|
||||
{ Qt::Key_Down, JGE_BTN_DOWN },
|
||||
{ Qt::Key_Left, JGE_BTN_LEFT },
|
||||
{ Qt::Key_Right, JGE_BTN_RIGHT },
|
||||
{ Qt::Key_Space, JGE_BTN_OK },
|
||||
{ Qt::Key_Tab, JGE_BTN_CANCEL },
|
||||
{ Qt::Key_J, JGE_BTN_PRI },
|
||||
{ Qt::Key_K, JGE_BTN_SEC },
|
||||
{ Qt::Key_Q, JGE_BTN_PREV },
|
||||
{ Qt::Key_A, JGE_BTN_NEXT },
|
||||
// fullscreen management seems somehow broken in JGE, it works fine with Qt directly
|
||||
// { Qt::Key_F, JGE_BTN_FULLSCREEN },
|
||||
};
|
||||
|
||||
|
||||
void JGECreateDefaultBindings()
|
||||
{
|
||||
for (signed int i = sizeof(gDefaultBindings)/sizeof(gDefaultBindings[0]) - 1; i >= 0; --i)
|
||||
g_engine->BindKey(gDefaultBindings[i].keysym, gDefaultBindings[i].keycode);
|
||||
}
|
||||
|
||||
int JGEGetTime()
|
||||
{
|
||||
QTime theTime = QTime::currentTime();
|
||||
return theTime.second() * 1000 + theTime.msec();
|
||||
}
|
||||
|
||||
bool JGEToggleFullscreen()
|
||||
{
|
||||
if(g_glwidget->isFullScreen())
|
||||
{
|
||||
g_glwidget->showNormal();
|
||||
}
|
||||
else
|
||||
{
|
||||
g_glwidget->showFullScreen();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool InitGame(void)
|
||||
{
|
||||
g_engine = JGE::GetInstance();
|
||||
g_app = g_launcher->GetGameApp();
|
||||
g_app->Create();
|
||||
g_engine->SetApp(g_app);
|
||||
|
||||
JRenderer::GetInstance()->Enable2D();
|
||||
QTime theTime = QTime::currentTime();
|
||||
lastTickCount = theTime.second() * 1000 + theTime.msec();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void DestroyGame(void)
|
||||
{
|
||||
g_engine->SetApp(NULL);
|
||||
if (g_app)
|
||||
{
|
||||
g_app->Destroy();
|
||||
delete g_app;
|
||||
g_app = NULL;
|
||||
}
|
||||
|
||||
JGE::Destroy();
|
||||
|
||||
g_engine = NULL;
|
||||
}
|
||||
|
||||
|
||||
JGEQtRenderer::JGEQtRenderer(QWidget *parent)
|
||||
: QGLWidget(QGLFormat(QGL::SampleBuffers), parent)
|
||||
{
|
||||
startTimer( 5 );
|
||||
setWindowTitle(g_launcher->GetName());
|
||||
#ifdef Q_WS_MAEMO_5
|
||||
setAttribute(Qt::WA_Maemo5AutoOrientation);
|
||||
setAttribute(Qt::WA_Maemo5NonComposited);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void JGEQtRenderer::initializeGL()
|
||||
{
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Black Background (yes that's the way fuckers)
|
||||
#if (defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0)
|
||||
#if (defined GL_ES_VERSION_2_0)
|
||||
glClearDepthf(1.0f); // Depth Buffer Setup
|
||||
#else
|
||||
glClearDepth(1.0f); // Depth Buffer Setup
|
||||
#endif// (defined GL_ES_VERSION_2_0)
|
||||
|
||||
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing (Less Or Equal)
|
||||
glEnable(GL_DEPTH_TEST); // Enable Depth Testing
|
||||
|
||||
#else
|
||||
glClearDepth(1.0f); // Depth Buffer Setup
|
||||
|
||||
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing (Less Or Equal)
|
||||
glEnable(GL_DEPTH_TEST); // Enable Depth Testing
|
||||
glShadeModel(GL_SMOOTH); // Select Smooth Shading
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Set Perspective Calculations To Most Accurate
|
||||
|
||||
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); // Set Line Antialiasing
|
||||
glEnable(GL_LINE_SMOOTH); // Enable it!
|
||||
#endif
|
||||
|
||||
glEnable(GL_CULL_FACE); // do not calculate inside of poly's
|
||||
glFrontFace(GL_CCW); // counter clock-wise polygons are out
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
glEnable(GL_SCISSOR_TEST); // Enable Clipping
|
||||
}
|
||||
|
||||
int actualWidth;
|
||||
int actualHeight;
|
||||
|
||||
GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // Resize The GL Window
|
||||
{
|
||||
actualWidth = width;
|
||||
actualHeight = height;
|
||||
|
||||
if ((GLfloat)width / (GLfloat)height < ACTUAL_RATIO)
|
||||
glViewport(0, -((width/ACTUAL_RATIO)-height)/2, width, width / ACTUAL_RATIO); // Reset The Current Viewport
|
||||
else
|
||||
glViewport(-(height*ACTUAL_RATIO-width)/2, 0, height * ACTUAL_RATIO, height);
|
||||
glScissor(0, 0, width, height);
|
||||
}
|
||||
|
||||
void JGEQtRenderer::resizeGL(int width, int height)
|
||||
{
|
||||
ReSizeGLScene(width, height);
|
||||
}
|
||||
|
||||
void JGEQtRenderer::paintGL()
|
||||
{
|
||||
g_engine->Render();
|
||||
}
|
||||
|
||||
void JGEQtRenderer::timerEvent( QTimerEvent* )
|
||||
{
|
||||
QTime theTime = QTime::currentTime();
|
||||
static uint64_t tickCount;
|
||||
quint32 dt;
|
||||
tickCount = theTime.second() * 1000 + theTime.msec();
|
||||
dt = (tickCount - lastTickCount);
|
||||
lastTickCount = tickCount;
|
||||
|
||||
if(g_engine->IsDone()) close();
|
||||
|
||||
//gPrevControllerState = gControllerState;
|
||||
g_engine->SetDelta((float)dt / 1000.0f);
|
||||
g_engine->Update((float)dt / 1000.0f);
|
||||
|
||||
updateGL();
|
||||
}
|
||||
|
||||
|
||||
void JGEQtRenderer::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
if(event->key() == Qt::Key_F)
|
||||
{
|
||||
JGEToggleFullscreen();
|
||||
}
|
||||
g_engine->HoldKey_NoRepeat(event->key());
|
||||
event->accept();
|
||||
QWidget::keyPressEvent(event);
|
||||
return;
|
||||
}
|
||||
|
||||
void JGEQtRenderer::keyReleaseEvent(QKeyEvent *event)
|
||||
{
|
||||
g_engine->ReleaseKey(event->key());
|
||||
event->accept();
|
||||
QWidget::keyReleaseEvent(event);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
char* path = argv[0];
|
||||
while (*path) ++path;
|
||||
while ((*path != '/') && (path > argv[0])) --path;
|
||||
if ('/' == *path) *path = 0;
|
||||
if (strlen(argv[0]) != 0) QDir::current().cd(argv[0]);
|
||||
|
||||
QApplication a( argc, argv );
|
||||
|
||||
g_launcher = new JGameLauncher();
|
||||
|
||||
u32 flags = g_launcher->GetInitFlags();
|
||||
|
||||
if ((flags&JINIT_FLAG_ENABLE3D)!=0)
|
||||
JRenderer::Set3DFlag(true);
|
||||
|
||||
g_glwidget = new JGEQtRenderer(NULL);
|
||||
|
||||
g_glwidget->resize(ACTUAL_SCREEN_WIDTH, ACTUAL_SCREEN_HEIGHT);
|
||||
|
||||
g_glwidget->show();
|
||||
|
||||
if (!InitGame())
|
||||
{
|
||||
printf("Could not init the game\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
JGECreateDefaultBindings();
|
||||
|
||||
a.exec();
|
||||
|
||||
if (g_launcher)
|
||||
delete g_launcher;
|
||||
|
||||
if(g_glwidget)
|
||||
delete g_glwidget;
|
||||
|
||||
// Shutdown
|
||||
DestroyGame();
|
||||
return 0;
|
||||
}
|
||||
+1
-1
@@ -112,7 +112,7 @@ int SetupCallbacks(void)
|
||||
|
||||
#ifdef DEVHOOK
|
||||
//code by sakya, crazyc, samuraiX
|
||||
//http://forums.ps2dev.org/viewtopic.php?t=9591&sid=2056889f6b9531194cab9b2d487df844
|
||||
//http://forums.ps2dev.org/viewtopic.php?t=9591
|
||||
PspDebugRegBlock exception_regs;
|
||||
|
||||
extern int _ftext;
|
||||
|
||||
+1513
-137
File diff suppressed because it is too large
Load Diff
+82
-1
@@ -8,7 +8,6 @@
|
||||
//
|
||||
//-------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
#ifdef WITH_FMOD
|
||||
#include "../../Dependencies/include/fmod.h"
|
||||
#else
|
||||
@@ -21,6 +20,9 @@
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
JMusic::JMusic()
|
||||
#ifdef USE_PHONON
|
||||
: mOutput(0), mMediaObject(0)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
@@ -38,24 +40,47 @@ int JMusic::getPlayTime(){
|
||||
|
||||
JMusic::~JMusic()
|
||||
{
|
||||
#ifdef USE_PHONON
|
||||
if(mOutput)
|
||||
delete mOutput;
|
||||
if(mMediaObject)
|
||||
delete mMediaObject;
|
||||
#else
|
||||
#ifdef WITH_FMOD
|
||||
JSoundSystem::GetInstance()->StopMusic(this);
|
||||
if (mTrack) FSOUND_Sample_Free(mTrack);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef USE_PHONON
|
||||
void JMusic::seekAtTheBegining()
|
||||
{
|
||||
mMediaObject->seek(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
JSample::JSample()
|
||||
#ifdef USE_PHONON
|
||||
: mOutput(0), mMediaObject(0)
|
||||
#endif
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
JSample::~JSample()
|
||||
{
|
||||
#ifdef USE_PHONON
|
||||
if(mOutput)
|
||||
delete mOutput;
|
||||
if(mMediaObject)
|
||||
delete mMediaObject;
|
||||
#else
|
||||
#ifdef WITH_FMOD
|
||||
if (mSample) FSOUND_Sample_Free(mSample);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
unsigned long JSample::fileSize()
|
||||
@@ -96,7 +121,9 @@ JSoundSystem::JSoundSystem()
|
||||
{
|
||||
mVolume = 0;
|
||||
mSampleVolume = 0;
|
||||
#ifdef WITH_FMOD
|
||||
mChannel = FSOUND_FREE;
|
||||
#endif
|
||||
}
|
||||
|
||||
JSoundSystem::~JSoundSystem()
|
||||
@@ -121,6 +148,18 @@ void JSoundSystem::DestroySoundSystem()
|
||||
|
||||
JMusic *JSoundSystem::LoadMusic(const char *fileName)
|
||||
{
|
||||
#ifdef USE_PHONON
|
||||
JMusic* music = new JMusic();
|
||||
if (music)
|
||||
{
|
||||
music->mOutput = new Phonon::AudioOutput(Phonon::GameCategory, 0);
|
||||
music->mMediaObject = new Phonon::MediaObject(0);
|
||||
music->mMediaObject->setCurrentSource("Res/" + QString(fileName));
|
||||
Phonon::Path path = Phonon::createPath(music->mMediaObject, music->mOutput);
|
||||
Q_ASSERT(path.isValid());
|
||||
}
|
||||
return music;
|
||||
#else
|
||||
#ifndef WITH_FMOD
|
||||
return NULL;
|
||||
#else
|
||||
@@ -141,11 +180,24 @@ JMusic *JSoundSystem::LoadMusic(const char *fileName)
|
||||
}
|
||||
return music;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void JSoundSystem::PlayMusic(JMusic *music, bool looping)
|
||||
{
|
||||
#ifdef USE_PHONON
|
||||
if (music && music->mMediaObject && music->mOutput)
|
||||
{
|
||||
if(looping)
|
||||
{
|
||||
music->mMediaObject->connect(music->mMediaObject, SIGNAL(aboutToFinish()), music, SLOT(seekAtTheBegining()));
|
||||
}
|
||||
music->mOutput->setVolume((qreal)mVolume*0.01);
|
||||
music->mMediaObject->play();
|
||||
|
||||
}
|
||||
#else
|
||||
#ifdef WITH_FMOD
|
||||
if (music && music->mTrack)
|
||||
{
|
||||
@@ -158,14 +210,22 @@ void JSoundSystem::PlayMusic(JMusic *music, bool looping)
|
||||
FSOUND_SetLoopMode(mChannel, FSOUND_LOOP_OFF);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void JSoundSystem::StopMusic(JMusic *music)
|
||||
{
|
||||
#ifdef USE_PHONON
|
||||
if (music && music->mMediaObject && music->mOutput)
|
||||
{
|
||||
music->mMediaObject->stop();
|
||||
}
|
||||
#else
|
||||
#ifdef WITH_FMOD
|
||||
FSOUND_StopSound(mChannel);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -195,6 +255,18 @@ void JSoundSystem::SetSfxVolume(int volume){
|
||||
|
||||
JSample *JSoundSystem::LoadSample(const char *fileName)
|
||||
{
|
||||
#ifdef USE_PHONON
|
||||
JSample* sample = new JSample();
|
||||
if (sample)
|
||||
{
|
||||
sample->mOutput = new Phonon::AudioOutput(Phonon::GameCategory, 0);
|
||||
sample->mMediaObject = new Phonon::MediaObject(0);
|
||||
sample->mMediaObject->setCurrentSource("Res/" + QString(fileName));
|
||||
Phonon::Path path = Phonon::createPath(sample->mMediaObject, sample->mOutput);
|
||||
Q_ASSERT(path.isValid());
|
||||
}
|
||||
return sample;
|
||||
#else
|
||||
#ifndef WITH_FMOD
|
||||
return NULL;
|
||||
#else
|
||||
@@ -217,16 +289,25 @@ JSample *JSoundSystem::LoadSample(const char *fileName)
|
||||
}
|
||||
return sample;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void JSoundSystem::PlaySample(JSample *sample)
|
||||
{
|
||||
#ifdef USE_PHONON
|
||||
if (sample && sample->mMediaObject && sample->mOutput)
|
||||
{
|
||||
sample->mOutput->setVolume((qreal)mSampleVolume*0.01);
|
||||
sample->mMediaObject->play();
|
||||
}
|
||||
#else
|
||||
#ifdef WITH_FMOD
|
||||
if (sample && sample->mSample){
|
||||
int channel = FSOUND_PlaySound(FSOUND_FREE, sample->mSample);
|
||||
FSOUND_SetVolumeAbsolute(channel,mSampleVolume * 2.55);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user