* 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_HGE = libhgetools.a
INCDIR = $(shell freetype-config --cflags 2> /dev/null) -I/usr/X11/include
CXXFLAGS += -DLINUX
CXXFLAGS += -DLINUX $(FMOD)
CXXFLAGS += $(INCDIR)
LIBDIR = lib/linux
endif
@@ -95,7 +95,7 @@ ifeq ($(TARGET_ARCHITECTURE),psp)
include $(PSPSDK)/lib/build.mak
endif
all: $(DEFAULT_RULE) hge
all: $(DEFAULT_RULE) Makefile.$(TARGET_ARCHITECTURE) hge
debug: $(DEFAULT_RULE) hge
@@ -117,5 +117,11 @@ $(TARGET_HGE): $(HGE_OBJS)
ar r $(TARGET_HGE) $(HGE_OBJS)
clean:
$(RM) -f $(OBJS) $(HGE_OBJS)
$(RM) -f $(OBJS) $(HGE_OBJS) Makefile.$(TARGET_ARCHITECTURE)
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,7 +51,11 @@ public:
int getPlayTime();
#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
JMP3* mTrack;
#endif
@@ -62,14 +66,18 @@ public:
//------------------------------------------------------------------------------------------------
class JSample
{
public:
public:
JSample();
~JSample();
int mVoice;
#if defined (WIN32) || defined (LINUX)
#ifdef WITH_FMOD
FSOUND_SAMPLE *mSample;
#else
void* mSample;
#endif
#else
WAVDATA *mSample;
#endif

View File

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

View File

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

View File

@@ -5,6 +5,7 @@
#include <X11/XKBlib.h>
#include <sys/time.h>
#include <queue>
#include <iostream>
#include "../../JGE/include/JGE.h"
#include "../../JGE/include/JTypes.h"
@@ -49,7 +50,7 @@ Display* gXDisplay = NULL;
Window gXWindow = NULL;
GLXWindow glxWin = NULL;
static queue< pair<KeyCode, u32> > gKeyBuffer;
static queue< pair<KeySym, u32> > gKeyBuffer;
static u32 gControllerState = 0;
static u32 gPrevControllerState = 0;
static u32 gHolds = 0;
@@ -80,7 +81,7 @@ static const struct { KeySym keysym; u32 pspCode; } gDefaultBindings[] =
{ 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
{
@@ -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)
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
int numReturned;
@@ -437,10 +438,12 @@ int main(int argc, char* argv[])
switch (event.type)
{
case KeyPress:
if (XKeycodeToKeysym(gXDisplay, event.xkey.keycode, 1) == XK_F)
{
KeySym sym = XKeycodeToKeysym(gXDisplay, event.xkey.keycode, 1);
if (XK_F == sym)
fullscreen();
for (vector< pair<KeyCode, u32> >::iterator it = gKeyCodes.begin(); it != gKeyCodes.end(); ++it)
if (event.xkey.keycode == it->first)
for (vector< pair<KeySym, u32> >::iterator it = gKeyCodes.begin(); it != gKeyCodes.end(); ++it)
if (sym == it->first)
{
if (!(gHolds & it->second))
gKeyBuffer.push(*it);
@@ -448,15 +451,19 @@ int main(int argc, char* argv[])
gHolds |= it->second;
break;
}
}
break;
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)
if (sym == it->first)
{
gControllerState &= ~it->second;
gHolds &= ~it->second;
break;
}
}
break;
case ConfigureNotify:
ReSizeGLScene(event.xconfigure.width, event.xconfigure.height);

View File

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

View File

@@ -8,8 +8,12 @@
//
//-------------------------------------------------------------------------------------
#include "../../Dependencies/include/png.h"
#ifdef WITH_FMOD
#include "../../Dependencies/include/fmod.h"
#else
#define FSOUND_FREE 0
#endif
#include "../../include/JSoundSystem.h"
#include "../../include/JFileSystem.h"
@@ -25,16 +29,19 @@ void JMusic::Update(){
}
int JMusic::getPlayTime(){
#ifdef WITH_FMOD
return FSOUND_GetCurrentPosition(JSoundSystem::GetInstance()->mChannel)/44.1; //todo more generic, here it's only 44kHz
#else
return 0;
#endif
}
JMusic::~JMusic()
{
#ifdef WITH_FMOD
JSoundSystem::GetInstance()->StopMusic(this);
//JSoundSystem::GetInstance()->FreeMusic(this);
if (mTrack)
FSOUND_Sample_Free(mTrack);
if (mTrack) FSOUND_Sample_Free(mTrack);
#endif
}
@@ -46,16 +53,15 @@ JSample::JSample()
JSample::~JSample()
{
//JSoundSystem::GetInstance()->FreeSample(this);
if (mSample)
FSOUND_Sample_Free(mSample);
#ifdef WITH_FMOD
if (mSample) FSOUND_Sample_Free(mSample);
#endif
}
//////////////////////////////////////////////////////////////////////////
JSoundSystem* JSoundSystem::mInstance = NULL;
JSoundSystem* JSoundSystem::GetInstance()
{
if (mInstance == NULL)
@@ -63,7 +69,6 @@ JSoundSystem* JSoundSystem::GetInstance()
mInstance = new JSoundSystem();
mInstance->InitSoundSystem();
}
return mInstance;
}
@@ -86,35 +91,37 @@ JSoundSystem::JSoundSystem()
mChannel = FSOUND_FREE;
}
JSoundSystem::~JSoundSystem()
{
}
void JSoundSystem::InitSoundSystem()
{
#ifdef WITH_FMOD
FSOUND_Init(44100, 32, 0);
#endif
}
void JSoundSystem::DestroySoundSystem()
{
#ifdef WITH_FMOD
FSOUND_Close();
#endif
}
JMusic *JSoundSystem::LoadMusic(const char *fileName)
{
#ifndef WITH_FMOD
return NULL;
#elif
JMusic* music = new JMusic();
if (music)
{
JFileSystem* fileSystem = JFileSystem::GetInstance();
if (fileSystem->OpenFile(fileName))
{
int size = fileSystem->GetFileSize();
char *buffer = new char[size];
fileSystem->ReadFile(buffer, size);
@@ -123,16 +130,15 @@ JMusic *JSoundSystem::LoadMusic(const char *fileName)
delete[] buffer;
fileSystem->CloseFile();
}
}
return music;
#endif
}
void JSoundSystem::PlayMusic(JMusic *music, bool looping)
{
#ifdef WITH_FMOD
if (music && music->mTrack)
{
mChannel = FSOUND_PlaySound(mChannel, music->mTrack);
@@ -142,14 +148,16 @@ void JSoundSystem::PlayMusic(JMusic *music, bool looping)
FSOUND_SetLoopMode(mChannel, FSOUND_LOOP_NORMAL);
else
FSOUND_SetLoopMode(mChannel, FSOUND_LOOP_OFF);
}
#endif
}
void JSoundSystem::StopMusic(JMusic *music)
{
#ifdef WITH_FMOD
FSOUND_StopSound(mChannel);
#endif
}
@@ -161,20 +169,27 @@ void JSoundSystem::SetVolume(int volume)
void JSoundSystem::SetMusicVolume(int volume)
{
#ifdef WITH_FMOD
if (mChannel != FSOUND_FREE) FSOUND_SetVolumeAbsolute(mChannel,volume * 2.55);
#endif
mVolume = volume;
}
void JSoundSystem::SetSfxVolume(int volume){
//this sets the volume to all channels then reverts back the volume for music..
//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;
SetMusicVolume(mVolume);
}
JSample *JSoundSystem::LoadSample(const char *fileName)
{
#ifndef WITH_FMOD
return NULL;
#else
JSample* sample = new JSample();
if (sample)
{
@@ -192,16 +207,18 @@ JSample *JSoundSystem::LoadSample(const char *fileName)
sample->mSample = NULL;
}
return sample;
#endif
}
void JSoundSystem::PlaySample(JSample *sample)
{
#ifdef WITH_FMOD
if (sample && sample->mSample){
int channel = FSOUND_PlaySound(FSOUND_FREE, sample->mSample);
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
else
OBJS += objs/TestSuiteAI.o
INCDIR = -I ../../JGE/include -I ../../JGE/src
LIBDIR = -L ../../JGE/lib/linux -L ../../JGE
LIBS = -ljge -lfreetype -ljpeg -lgif -lpng -lz -lm -lstdc++ -lglut -lhgetools -lfmod-3.75
INCDIR = -I../../JGE/include -I../../JGE/src -I/usr/X11/include
LIBDIR = -L../../JGE/lib/linux -L../../JGE -L/usr/X11/lib
LIBS = -ljge -lfreetype -ljpeg -lgif -lpng -lz -lm -lstdc++ -lhgetools -lGL -lGLU -lX11 $(FMOD)
CFLAGS = $(INCDIR) -DLINUX
ASFLAGS = $(CXXFLAGS)
@@ -55,7 +55,7 @@ CFLAGS := -Wall -W -Werror -Wno-unused $(CFLAGS)
CXXFLAGS += $(CFLAGS)
# -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)
linux: $(TARGET)
@@ -82,7 +82,7 @@ linux: $(TARGET)
debug: linux
clean:
$(RM) $(OBJS)
$(RM) $(OBJS) Makefile.$(TARGET_ARCHITECTURE)
endif
@@ -95,4 +95,12 @@ $(DEPS): deps/%.d: src/%.cpp
.DEFAULT:
@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 Makefile.$(TARGET_ARCHITECTURE)

View File

@@ -381,7 +381,7 @@ void GameStateMenu::Update(float dt)
//Debug
#ifdef _DEBUG
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);
#endif

View File

@@ -317,7 +317,11 @@ unsigned long WCachedSample::size(){
return 0;
#if defined WIN32 || defined LINUX
#if defined __LP64__
return 0;
#else
return FSOUND_Sample_GetLength(sample->mSample);
#endif
#else
return sample->mSample->fileSize;
#endif

View File

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