* This update has Wagic compile and work under Darwin 64-bits.
  - Linux 64-bits is expected to compile and work from now on, but
    was not tested. As with before, Linux 64 bits can still run
    the 32 bits version.
  - Darwin version is not using Carbon but X emulation.
  - 64-bits versions have no sound because there is no 64-bits
    version of fmod.
  - Windows 64-bits probably does not compile. Windows 64-bits can
    still run the 32 bits version.
  - Darwin 32-bits probably does not work at the moment because the
    libfmod requires another name to work on Macs, but as 64-bits
    disables it it works.
  - Other unix flavors are expected to work as long as they have
    a working OpenGL library, X11, and *either* 64-bits *or* a
    working fmod. Thus in the practice Tru64, Irix and the like
    probably work, as should FreeBSD and other BSDs in 64 bits
    versions, but 32 bits versions will search for a non-existing
    fmod. All of this is pure conjecture and none was tested.
  - All 64-bits versions have no sound.
  - The mac version does not display the particles at the moment.
    This is not critical, but the cause is unknown yet. I would
    like to know if other 64 bits unices share the same bug or if
    it is mac-specific.
* Test is needed in particular to see whether the program still
  compiles and works in Linux and PSP. Windows is probably all
  right, but compiling PSP in windows may be broken by this
  update.
This commit is contained in:
jean.chalard
2010-02-02 08:27:10 +00:00
parent c4043b08a3
commit 18c18822c9
12 changed files with 177 additions and 130 deletions

View File

@@ -82,7 +82,7 @@ OBJS = $(GENERIC_OBJS) $(LINUX_OBJS)
TARGET_LIB = libjge.a TARGET_LIB = libjge.a
TARGET_HGE = libhgetools.a TARGET_HGE = libhgetools.a
INCDIR = $(shell freetype-config --cflags 2> /dev/null) -I/usr/X11/include INCDIR = $(shell freetype-config --cflags 2> /dev/null) -I/usr/X11/include
CXXFLAGS += -DLINUX CXXFLAGS += -DLINUX $(FMOD)
CXXFLAGS += $(INCDIR) CXXFLAGS += $(INCDIR)
LIBDIR = lib/linux LIBDIR = lib/linux
endif endif
@@ -95,7 +95,7 @@ ifeq ($(TARGET_ARCHITECTURE),psp)
include $(PSPSDK)/lib/build.mak include $(PSPSDK)/lib/build.mak
endif endif
all: $(DEFAULT_RULE) hge all: $(DEFAULT_RULE) Makefile.$(TARGET_ARCHITECTURE) hge
debug: $(DEFAULT_RULE) hge debug: $(DEFAULT_RULE) hge
@@ -117,5 +117,11 @@ $(TARGET_HGE): $(HGE_OBJS)
ar r $(TARGET_HGE) $(HGE_OBJS) ar r $(TARGET_HGE) $(HGE_OBJS)
clean: clean:
$(RM) -f $(OBJS) $(HGE_OBJS) $(RM) -f $(OBJS) $(HGE_OBJS) Makefile.$(TARGET_ARCHITECTURE)
endif endif
Makefile.linux:
g++ -o /dev/null src/testfeatures.c -L$(LIBDIR) -lfmod-3.75
@if [ "0" == "$?" ]; then echo 'FMOD=-DWITH_FMOD'; else echo 'FMOD=-DWITHOUT_FMOD'; fi > $@
-include Makefile.$(TARGET_ARCHITECTURE)

View File

@@ -51,9 +51,13 @@ public:
int getPlayTime(); int getPlayTime();
#if defined (WIN32) || defined (LINUX) #if defined (WIN32) || defined (LINUX)
FSOUND_SAMPLE *mTrack; // MP3 needed to be of "sample" type for FMOD, FMUSIC_MODULE is for MODs #ifdef WITH_FMOD
FSOUND_SAMPLE* mTrack; // MP3 needed to be of "sample" type for FMOD, FMUSIC_MODULE is for MODs
#else
void* mTrack;
#endif
#else #else
JMP3* mTrack; JMP3* mTrack;
#endif #endif
}; };
@@ -62,16 +66,20 @@ public:
//------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------
class JSample class JSample
{ {
public: public:
JSample(); JSample();
~JSample(); ~JSample();
int mVoice; int mVoice;
#if defined (WIN32) || defined (LINUX) #if defined (WIN32) || defined (LINUX)
FSOUND_SAMPLE *mSample; #ifdef WITH_FMOD
FSOUND_SAMPLE *mSample;
#else
void* mSample;
#endif
#else #else
WAVDATA *mSample; WAVDATA *mSample;
#endif #endif
}; };

View File

@@ -75,9 +75,9 @@
#include <windows.h> #include <windows.h>
#endif #endif
#ifdef LINUX #ifdef LINUX
typedef unsigned char byte; typedef uint8_t byte;
typedef unsigned long DWORD; typedef uint32_t DWORD;
typedef unsigned char BYTE; typedef uint8_t BYTE;
typedef bool BOOL; typedef bool BOOL;
#endif #endif
@@ -87,8 +87,6 @@
#endif #endif
#if defined (WIN32) || defined (LINUX) #if defined (WIN32) || defined (LINUX)
#include "../Dependencies/include/fmod.h"
typedef int8_t s8; typedef int8_t s8;
typedef int16_t s16; typedef int16_t s16;

View File

@@ -20,8 +20,6 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
#if defined (WIN32) // WIN32 specific code #if defined (WIN32) // WIN32 specific code
#include "../../Dependencies/include/png.h"
#include "../../Dependencies/include/fmod.h"
int JGE::GetTime(void) int JGE::GetTime(void)
{ {

View File

@@ -5,6 +5,7 @@
#include <X11/XKBlib.h> #include <X11/XKBlib.h>
#include <sys/time.h> #include <sys/time.h>
#include <queue> #include <queue>
#include <iostream>
#include "../../JGE/include/JGE.h" #include "../../JGE/include/JGE.h"
#include "../../JGE/include/JTypes.h" #include "../../JGE/include/JTypes.h"
@@ -49,7 +50,7 @@ Display* gXDisplay = NULL;
Window gXWindow = NULL; Window gXWindow = NULL;
GLXWindow glxWin = NULL; GLXWindow glxWin = NULL;
static queue< pair<KeyCode, u32> > gKeyBuffer; static queue< pair<KeySym, u32> > gKeyBuffer;
static u32 gControllerState = 0; static u32 gControllerState = 0;
static u32 gPrevControllerState = 0; static u32 gPrevControllerState = 0;
static u32 gHolds = 0; static u32 gHolds = 0;
@@ -80,7 +81,7 @@ static const struct { KeySym keysym; u32 pspCode; } gDefaultBindings[] =
{ XK_F3, PSP_CTRL_NOTE } { XK_F3, PSP_CTRL_NOTE }
}; };
static vector< pair<KeyCode, u32> > gKeyCodes; static vector< pair<KeySym, u32> > gKeyCodes;
GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // Resize The GL Window GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // Resize The GL Window
{ {
@@ -210,7 +211,7 @@ BOOL CreateGLWindow(char* title, int width, int height, int bits __attribute__((
} }
for (signed int i = sizeof(gDefaultBindings)/sizeof(gDefaultBindings[0]) - 1; i >= 0; --i) for (signed int i = sizeof(gDefaultBindings)/sizeof(gDefaultBindings[0]) - 1; i >= 0; --i)
gKeyCodes.push_back(make_pair(XKeysymToKeycode(gXDisplay, gDefaultBindings[i].keysym), gDefaultBindings[i].pspCode)); gKeyCodes.push_back(make_pair(gDefaultBindings[i].keysym, gDefaultBindings[i].pspCode));
// Get a suitable framebuffer config // Get a suitable framebuffer config
int numReturned; int numReturned;
@@ -437,26 +438,32 @@ int main(int argc, char* argv[])
switch (event.type) switch (event.type)
{ {
case KeyPress: case KeyPress:
if (XKeycodeToKeysym(gXDisplay, event.xkey.keycode, 1) == XK_F) {
fullscreen(); KeySym sym = XKeycodeToKeysym(gXDisplay, event.xkey.keycode, 1);
for (vector< pair<KeyCode, u32> >::iterator it = gKeyCodes.begin(); it != gKeyCodes.end(); ++it) if (XK_F == sym)
if (event.xkey.keycode == it->first) fullscreen();
{ for (vector< pair<KeySym, u32> >::iterator it = gKeyCodes.begin(); it != gKeyCodes.end(); ++it)
if (!(gHolds & it->second)) if (sym == it->first)
gKeyBuffer.push(*it); {
gControllerState |= it->second; if (!(gHolds & it->second))
gHolds |= it->second; gKeyBuffer.push(*it);
break; gControllerState |= it->second;
} gHolds |= it->second;
break;
}
}
break; break;
case KeyRelease: case KeyRelease:
for (vector< pair<KeyCode, u32> >::iterator it = gKeyCodes.begin(); it != gKeyCodes.end(); ++it) {
if (event.xkey.keycode == it->first) KeySym sym = XKeycodeToKeysym(gXDisplay, event.xkey.keycode, 1);
{ for (vector< pair<KeySym, u32> >::iterator it = gKeyCodes.begin(); it != gKeyCodes.end(); ++it)
gControllerState &= ~it->second; if (sym == it->first)
gHolds &= ~it->second; {
break; gControllerState &= ~it->second;
} gHolds &= ~it->second;
break;
}
}
break; break;
case ConfigureNotify: case ConfigureNotify:
ReSizeGLScene(event.xconfigure.width, event.xconfigure.height); ReSizeGLScene(event.xconfigure.width, event.xconfigure.height);

View File

@@ -17,7 +17,6 @@
#include "../../Dependencies/include/png.h" #include "../../Dependencies/include/png.h"
#include "../../Dependencies/include/fmod.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View File

@@ -8,8 +8,12 @@
// //
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
#include "../../Dependencies/include/png.h"
#ifdef WITH_FMOD
#include "../../Dependencies/include/fmod.h" #include "../../Dependencies/include/fmod.h"
#else
#define FSOUND_FREE 0
#endif
#include "../../include/JSoundSystem.h" #include "../../include/JSoundSystem.h"
#include "../../include/JFileSystem.h" #include "../../include/JFileSystem.h"
@@ -25,16 +29,19 @@ void JMusic::Update(){
} }
int JMusic::getPlayTime(){ int JMusic::getPlayTime(){
#ifdef WITH_FMOD
return FSOUND_GetCurrentPosition(JSoundSystem::GetInstance()->mChannel)/44.1; //todo more generic, here it's only 44kHz return FSOUND_GetCurrentPosition(JSoundSystem::GetInstance()->mChannel)/44.1; //todo more generic, here it's only 44kHz
#else
return 0;
#endif
} }
JMusic::~JMusic() JMusic::~JMusic()
{ {
JSoundSystem::GetInstance()->StopMusic(this); #ifdef WITH_FMOD
//JSoundSystem::GetInstance()->FreeMusic(this); JSoundSystem::GetInstance()->StopMusic(this);
if (mTrack) FSOUND_Sample_Free(mTrack);
if (mTrack) #endif
FSOUND_Sample_Free(mTrack);
} }
@@ -46,162 +53,172 @@ JSample::JSample()
JSample::~JSample() JSample::~JSample()
{ {
//JSoundSystem::GetInstance()->FreeSample(this); #ifdef WITH_FMOD
if (mSample) if (mSample) FSOUND_Sample_Free(mSample);
FSOUND_Sample_Free(mSample); #endif
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
JSoundSystem* JSoundSystem::mInstance = NULL; JSoundSystem* JSoundSystem::mInstance = NULL;
JSoundSystem* JSoundSystem::GetInstance() JSoundSystem* JSoundSystem::GetInstance()
{ {
if (mInstance == NULL) if (mInstance == NULL)
{ {
mInstance = new JSoundSystem(); mInstance = new JSoundSystem();
mInstance->InitSoundSystem(); mInstance->InitSoundSystem();
} }
return mInstance;
return mInstance;
} }
void JSoundSystem::Destroy() void JSoundSystem::Destroy()
{ {
if (mInstance) if (mInstance)
{ {
mInstance->DestroySoundSystem(); mInstance->DestroySoundSystem();
delete mInstance; delete mInstance;
mInstance = NULL; mInstance = NULL;
} }
} }
JSoundSystem::JSoundSystem() JSoundSystem::JSoundSystem()
{ {
mVolume = 0; mVolume = 0;
mSampleVolume = 0; mSampleVolume = 0;
mChannel = FSOUND_FREE; mChannel = FSOUND_FREE;
} }
JSoundSystem::~JSoundSystem() JSoundSystem::~JSoundSystem()
{ {
} }
void JSoundSystem::InitSoundSystem() void JSoundSystem::InitSoundSystem()
{ {
FSOUND_Init(44100, 32, 0); #ifdef WITH_FMOD
FSOUND_Init(44100, 32, 0);
#endif
} }
void JSoundSystem::DestroySoundSystem() void JSoundSystem::DestroySoundSystem()
{ {
FSOUND_Close(); #ifdef WITH_FMOD
FSOUND_Close();
#endif
} }
JMusic *JSoundSystem::LoadMusic(const char *fileName) JMusic *JSoundSystem::LoadMusic(const char *fileName)
{ {
JMusic* music = new JMusic(); #ifndef WITH_FMOD
if (music) return NULL;
#elif
JMusic* music = new JMusic();
if (music)
{
JFileSystem* fileSystem = JFileSystem::GetInstance();
if (fileSystem->OpenFile(fileName))
{ {
JFileSystem* fileSystem = JFileSystem::GetInstance(); int size = fileSystem->GetFileSize();
if (fileSystem->OpenFile(fileName)) char *buffer = new char[size];
{ fileSystem->ReadFile(buffer, size);
music->mTrack = FSOUND_Sample_Load(FSOUND_UNMANAGED, buffer, FSOUND_LOADMEMORY, 0, size);
int size = fileSystem->GetFileSize();
char *buffer = new char[size];
fileSystem->ReadFile(buffer, size);
music->mTrack = FSOUND_Sample_Load(FSOUND_UNMANAGED, buffer, FSOUND_LOADMEMORY, 0, size);
delete[] buffer; delete[] buffer;
fileSystem->CloseFile(); fileSystem->CloseFile();
}
} }
}
return music; return music;
#endif
} }
void JSoundSystem::PlayMusic(JMusic *music, bool looping) void JSoundSystem::PlayMusic(JMusic *music, bool looping)
{ {
#ifdef WITH_FMOD
if (music && music->mTrack) if (music && music->mTrack)
{ {
mChannel = FSOUND_PlaySound(mChannel, music->mTrack); mChannel = FSOUND_PlaySound(mChannel, music->mTrack);
SetMusicVolume(mVolume); SetMusicVolume(mVolume);
if (looping) if (looping)
FSOUND_SetLoopMode(mChannel, FSOUND_LOOP_NORMAL); FSOUND_SetLoopMode(mChannel, FSOUND_LOOP_NORMAL);
else else
FSOUND_SetLoopMode(mChannel, FSOUND_LOOP_OFF); FSOUND_SetLoopMode(mChannel, FSOUND_LOOP_OFF);
}
} #endif
} }
void JSoundSystem::StopMusic(JMusic *music) void JSoundSystem::StopMusic(JMusic *music)
{ {
FSOUND_StopSound(mChannel); #ifdef WITH_FMOD
FSOUND_StopSound(mChannel);
#endif
} }
void JSoundSystem::SetVolume(int volume) void JSoundSystem::SetVolume(int volume)
{ {
SetMusicVolume(volume); SetMusicVolume(volume);
SetSfxVolume(volume); SetSfxVolume(volume);
} }
void JSoundSystem::SetMusicVolume(int volume) void JSoundSystem::SetMusicVolume(int volume)
{ {
if (mChannel != FSOUND_FREE) FSOUND_SetVolumeAbsolute(mChannel,volume * 2.55); #ifdef WITH_FMOD
mVolume = volume; if (mChannel != FSOUND_FREE) FSOUND_SetVolumeAbsolute(mChannel,volume * 2.55);
#endif
mVolume = volume;
} }
void JSoundSystem::SetSfxVolume(int volume){ void JSoundSystem::SetSfxVolume(int volume){
//this sets the volume to all channels then reverts back the volume for music.. //this sets the volume to all channels then reverts back the volume for music..
//that's a bit dirty but it works //that's a bit dirty but it works
FSOUND_SetVolumeAbsolute(FSOUND_ALL,volume * 2.55); #ifdef WITH_FMOD
FSOUND_SetVolumeAbsolute(FSOUND_ALL, volume * 2.55);
#endif
mSampleVolume = volume; mSampleVolume = volume;
SetMusicVolume(mVolume); SetMusicVolume(mVolume);
} }
JSample *JSoundSystem::LoadSample(const char *fileName) JSample *JSoundSystem::LoadSample(const char *fileName)
{ {
JSample* sample = new JSample(); #ifndef WITH_FMOD
if (sample) return NULL;
#else
JSample* sample = new JSample();
if (sample)
{
JFileSystem* fileSystem = JFileSystem::GetInstance();
if (fileSystem->OpenFile(fileName))
{ {
JFileSystem* fileSystem = JFileSystem::GetInstance(); int size = fileSystem->GetFileSize();
if (fileSystem->OpenFile(fileName)) char *buffer = new char[size];
{ fileSystem->ReadFile(buffer, size);
int size = fileSystem->GetFileSize(); sample->mSample = FSOUND_Sample_Load(FSOUND_UNMANAGED, buffer, FSOUND_LOADMEMORY, 0, size);
char *buffer = new char[size];
fileSystem->ReadFile(buffer, size);
sample->mSample = FSOUND_Sample_Load(FSOUND_UNMANAGED, buffer, FSOUND_LOADMEMORY, 0, size);
delete[] buffer;
fileSystem->CloseFile();
}else
sample->mSample = NULL;
}
return sample; delete[] buffer;
fileSystem->CloseFile();
}else
sample->mSample = NULL;
}
return sample;
#endif
} }
void JSoundSystem::PlaySample(JSample *sample) void JSoundSystem::PlaySample(JSample *sample)
{ {
#ifdef WITH_FMOD
if (sample && sample->mSample){ if (sample && sample->mSample){
int channel = FSOUND_PlaySound(FSOUND_FREE, sample->mSample); int channel = FSOUND_PlaySound(FSOUND_FREE, sample->mSample);
FSOUND_SetVolumeAbsolute(channel,mSampleVolume * 2.55); FSOUND_SetVolumeAbsolute(channel,mSampleVolume * 2.55);
} }
#endif
} }

1
JGE/src/testfeatures.c Normal file
View File

@@ -0,0 +1 @@
int main() {}

View File

@@ -40,9 +40,9 @@ INCDIR = ../../JGE/include ../../JGE/include/psp ../../JGE/include/psp/freetype2
LIBDIR = ../../JGE/lib/psp LIBDIR = ../../JGE/lib/psp
else else
OBJS += objs/TestSuiteAI.o OBJS += objs/TestSuiteAI.o
INCDIR = -I ../../JGE/include -I ../../JGE/src INCDIR = -I../../JGE/include -I../../JGE/src -I/usr/X11/include
LIBDIR = -L ../../JGE/lib/linux -L ../../JGE LIBDIR = -L../../JGE/lib/linux -L../../JGE -L/usr/X11/lib
LIBS = -ljge -lfreetype -ljpeg -lgif -lpng -lz -lm -lstdc++ -lglut -lhgetools -lfmod-3.75 LIBS = -ljge -lfreetype -ljpeg -lgif -lpng -lz -lm -lstdc++ -lhgetools -lGL -lGLU -lX11 $(FMOD)
CFLAGS = $(INCDIR) -DLINUX CFLAGS = $(INCDIR) -DLINUX
ASFLAGS = $(CXXFLAGS) ASFLAGS = $(CXXFLAGS)
@@ -55,7 +55,7 @@ CFLAGS := -Wall -W -Werror -Wno-unused $(CFLAGS)
CXXFLAGS += $(CFLAGS) CXXFLAGS += $(CFLAGS)
# -fno-exceptions # -fno-exceptions
LDFLAGS = $(LIBS) LDFLAGS += $(LIBS)
@@ -74,7 +74,7 @@ else
$(TARGET): $(OBJS) ../../JGE/lib/linux/libjge.a $(TARGET): Makefile.$(TARGET_ARCHITECTURE) $(OBJS) ../../JGE/lib/linux/libjge.a
g++ -o $(TARGET) $(OBJS) $(LIBS) $(LIBDIR) g++ -o $(TARGET) $(OBJS) $(LIBS) $(LIBDIR)
linux: $(TARGET) linux: $(TARGET)
@@ -82,7 +82,7 @@ linux: $(TARGET)
debug: linux debug: linux
clean: clean:
$(RM) $(OBJS) $(RM) $(OBJS) Makefile.$(TARGET_ARCHITECTURE)
endif endif
@@ -95,4 +95,12 @@ $(DEPS): deps/%.d: src/%.cpp
.DEFAULT: .DEFAULT:
@echo $@ has been deleted : updating deps. @echo $@ has been deleted : updating deps.
Makefile.psp:
echo > Makefile.psp
Makefile.linux:
g++ -o /dev/null src/testfeatures.c $(LIBDIR) -lfmod-3.75
@if [ "0" == "$?" ]; then echo 'FMOD=-lfmod-3.75'; else echo 'FMOD='; fi > $@
-include $(DEPS) -include $(DEPS)
-include Makefile.$(TARGET_ARCHITECTURE)

View File

@@ -381,7 +381,7 @@ void GameStateMenu::Update(float dt)
//Debug //Debug
#ifdef _DEBUG #ifdef _DEBUG
char buf[4096]; char buf[4096];
sprintf(buf, "\n==\nTotal MTGCard: %i\nTotal CardPrimitives: %i\n==\n", mParent->collection->collection.size(), mParent->collection->primitives.size()); sprintf(buf, "\n==\nTotal MTGCard: %lu\nTotal CardPrimitives: %lu\n==\n", (long unsigned)mParent->collection->collection.size(), (long unsigned)mParent->collection->primitives.size());
OutputDebugString(buf); OutputDebugString(buf);
#endif #endif

View File

@@ -317,7 +317,11 @@ unsigned long WCachedSample::size(){
return 0; return 0;
#if defined WIN32 || defined LINUX #if defined WIN32 || defined LINUX
#if defined __LP64__
return 0;
#else
return FSOUND_Sample_GetLength(sample->mSample); return FSOUND_Sample_GetLength(sample->mSample);
#endif
#else #else
return sample->mSample->fileSize; return sample->mSample->fileSize;
#endif #endif
@@ -425,4 +429,4 @@ WTrackedQuad::WTrackedQuad(string _resname) {
} }
WTrackedQuad::~WTrackedQuad() { WTrackedQuad::~WTrackedQuad() {
if(quad) SAFE_DELETE(quad); if(quad) SAFE_DELETE(quad);
} }

View File

@@ -0,0 +1 @@
int main() {}