1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-10-17 20:09:35 +00:00

Merge branch 'experimental' into controllerfixup

# Conflicts:
#	Aquaria/Avatar.cpp
#	Aquaria/Continuity.cpp
#	Aquaria/DSQ.cpp
#	Aquaria/DSQ.h
#	Aquaria/Game.cpp
#	Aquaria/Game.h
#	Aquaria/Main.cpp
#	Aquaria/UserSettings.cpp
#	BBGE/Base.cpp
#	BBGE/Base.h
#	BBGE/Core.cpp
#	BBGE/Core.h
#	BBGE/DebugFont.cpp
#	BBGE/Shader.cpp
#	BBGE/SoundManager.h
This commit is contained in:
fgenesis 2017-01-13 12:19:23 +01:00
commit 0dc30e668d
67 changed files with 788 additions and 511 deletions

View file

@ -259,10 +259,6 @@ void AfterEffectManager::renderGrid()
if (activeShader)
activeShader->unbind();
float width2 = float(vw)/2;
float height2 = float(vh)/2;
if(firstShader != lastShader)
{
// From here on: secondary shader passes.

View file

@ -29,6 +29,7 @@ class Effect
{
public:
Effect();
virtual ~Effect(){};
virtual void go(){}
virtual void update(float dt, Vector ** drawGrid, int xDivs, int yDivs){}
bool done;

View file

@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifdef BBGE_BUILD_VFS
# include "ttvfs.h"
# ifndef VFS_IGNORE_CASE
# error Must define VFS_IGNORE_CASE, see VFSDefines.h
# error Must define VFS_IGNORE_CASE, see VFSDefines.h
# endif
ttvfs::Root vfs; // extern
#endif
@ -62,12 +62,12 @@ std::string removeSpaces(const std::string &input)
unsigned hash(const std::string &string)
{
unsigned hash = 5381;
unsigned hash = 5381;
for (int i = 0; i < string.size(); i++)
hash = ((hash << 5) + hash) + (unsigned char)string[i];
for (int i = 0; i < string.size(); i++)
hash = ((hash << 5) + hash) + (unsigned char)string[i];
return hash;
return hash;
}
@ -113,11 +113,6 @@ static unsigned char charIsUpper(unsigned char c)
return c == upperToLowerTable[c];
}
static unsigned char charIsLower(unsigned char c)
{
return c == lowerToUpperTable[c];
}
static unsigned char charToLower(unsigned char c)
{
return upperToLowerTable[c];
@ -190,8 +185,8 @@ void stringToLowerUserData(std::string &s)
const std::string userdata = core->getUserDataFolder();
const size_t len = userdata.length();
const bool match = (s.length() > len) &&
((s[len] == '/') || (s[len] == '\\')) &&
!strncmp(userdata.c_str(), s.c_str(), len);
((s[len] == '/') || (s[len] == '\\')) &&
!strncmp(userdata.c_str(), s.c_str(), len);
if (!match)
stringToLower(s);
else
@ -211,18 +206,18 @@ int nocasecmp(const std::string &s1, const std::string &s2)
//stop when either string's end has been reached
while ( *it1 && *it2 )
{
if(charToUpper(*it1) != charToUpper(*it2)) //letters differ?
// return -1 to indicate smaller than, 1 otherwise
return (charToUpper(*it1) < charToUpper(*it2)) ? -1 : 1;
//proceed to the next character in each string
++it1;
++it2;
if(charToUpper(*it1) != charToUpper(*it2)) //letters differ?
// return -1 to indicate smaller than, 1 otherwise
return (charToUpper(*it1) < charToUpper(*it2)) ? -1 : 1;
//proceed to the next character in each string
++it1;
++it2;
}
size_t size1=s1.size(), size2=s2.size();// cache lengths
//return -1,0 or 1 according to strings' lengths
if (size1==size2)
return 0;
return (size1<size2) ? -1 : 1;
if (size1==size2)
return 0;
return (size1<size2) ? -1 : 1;
}
#endif // #if !HAVE_STRCASECMP
@ -355,27 +350,26 @@ std::string stripEndlineForUnix(const std::string &in)
return out;
}
bool isTouchingLine(Vector lineStart, Vector lineEnd, Vector point, int radius, Vector *closestP)
{
Vector dir = lineEnd - lineStart;
Vector diff = point - lineStart;
Vector closest;
if (!dir.isZero()) {
Vector dir = lineEnd - lineStart;
Vector diff = point - lineStart;
Vector closest;
if (!dir.isZero()) {
float t = diff.dot2D(dir) / dir.dot2D(dir);
if (t < 0.0f)
t = 0.0f;
t = 0.0f;
if (t > 1.0f)
t = 1.0f;
t = 1.0f;
closest = lineStart + t * dir;
} else {
} else {
closest = lineStart;
}
Vector d = point - closest;
float distsqr = d.dot2D(d);
}
Vector d = point - closest;
float distsqr = d.dot2D(d);
if (closestP)
(*closestP) = closest;
return distsqr <= radius*radius;
return distsqr <= radius*radius;
}
Vector randVector(float mag)

View file

@ -350,7 +350,7 @@ Core::Core(const std::string &filesystem, const std::string& extraDataDir, int n
#if defined(BBGE_BUILD_UNIX)
const char *envr = getenv("HOME");
if (envr == NULL)
envr = "."; // oh well.
envr = "."; // oh well.
const std::string home(envr);
createDir(home); // just in case.
@ -769,7 +769,6 @@ bool Core::initGraphicsLibrary(int width, int height, bool fullscreen, bool vsyn
#endif
initIcon(gScreen);
// Create window
std::ostringstream os;
os << "setting vsync: " << vsync;
@ -979,22 +978,22 @@ void Core::applyState(const std::string &state)
#ifdef BBGE_BUILD_WINDOWS
void centerWindow(HWND hwnd)
{
int x, y;
HWND hwndDeskTop;
RECT rcWnd, rcDeskTop;
// Get a handle to the desktop window
hwndDeskTop = ::GetDesktopWindow();
// Get dimension of desktop in a rect
::GetWindowRect(hwndDeskTop, &rcDeskTop);
// Get dimension of main window in a rect
::GetWindowRect(hwnd, &rcWnd);
// Find center of desktop
int x, y;
HWND hwndDeskTop;
RECT rcWnd, rcDeskTop;
// Get a handle to the desktop window
hwndDeskTop = ::GetDesktopWindow();
// Get dimension of desktop in a rect
::GetWindowRect(hwndDeskTop, &rcDeskTop);
// Get dimension of main window in a rect
::GetWindowRect(hwnd, &rcWnd);
// Find center of desktop
x = (rcDeskTop.right - rcDeskTop.left)/2;
y = (rcDeskTop.bottom - rcDeskTop.top)/2;
x -= (rcWnd.right - rcWnd.left)/2;
x -= (rcWnd.right - rcWnd.left)/2;
y -= (rcWnd.bottom - rcWnd.top)/2;
// Set top and left to center main window on desktop
::SetWindowPos(hwnd, HWND_TOP, x, y, 0, 0, SWP_NOSIZE);
// Set top and left to center main window on desktop
::SetWindowPos(hwnd, HWND_TOP, x, y, 0, 0, SWP_NOSIZE);
}
#endif
@ -1002,7 +1001,7 @@ void centerWindow(HWND hwnd)
// No longer part of C/C++ standard
#ifndef M_PI
#define M_PI 3.14159265358979323846
#define M_PI 3.14159265358979323846
#endif
void Core::setPixelScale(int pixelScaleX, int pixelScaleY)
@ -1158,7 +1157,7 @@ std::string getScreenshotFilename(bool png)
std::ostringstream os;
os << prefix << screenshotNum << ext;
screenshotNum ++;
std::string str(os.str());
std::string str(os.str());
if (!core->exists(str)) // keep going until we hit an unused filename.
return str;
}
@ -1195,7 +1194,6 @@ void Core::run(float runTime)
float dt;
float counter = 0;
int frames = 0;
float real_dt = 0;
#if !defined(_DEBUG)
bool wasInactive = false;

View file

@ -164,8 +164,15 @@ void DebugFont::setAlign(Align align)
#include "../BBGE/Quad.h"
DebugButton::DebugButton(int buttonID, DebugButtonReceiver *receiver, int bgWidth, int fsize)
: RenderObject(), label(0), highlight(0), receiver(receiver), buttonID(buttonID)
, activeAlpha(0.5f), activeColor(1,1,1), inactiveAlpha(0.5f), inactiveColor(0,0,0)
: RenderObject()
, label(0)
, buttonID(buttonID)
, highlight(0)
, receiver(receiver)
, activeAlpha(0.5f)
, activeColor(1,1,1)
, inactiveAlpha(0.5f)
, inactiveColor(0,0,0)
{
if (bgWidth == 0)
bgWidth = 150;

View file

@ -82,6 +82,8 @@ void PostProcessingFX::render()
FXTypes type = (FXTypes)i;
switch(type)
{
case FXT_MAX:
break;
case FXT_RADIALBLUR:
float windowW = core->getWindowWidth();

View file

@ -26,7 +26,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
enum FXTypes
{
FTX_NONE =-1,
FXT_RADIALBLUR =0,
FXT_MAX
};

View file

@ -50,7 +50,7 @@ public:
private:
T *callee;
void (T::*callback)(void);
void (T::*callback)(void);
};
template <class T>
@ -67,7 +67,7 @@ public:
private:
T *callee;
void (T::*callback)(Event *e);
void (T::*callback)(Event *e);
};
#define EVENT(x,y) class x : public Event { public: void act(); }; x y;

View file

@ -185,7 +185,7 @@ protected:
struct ParticleInfluence
{
ParticleInfluence(Vector pos, float spd, float size, bool pull)
: pos(pos), spd(spd), size(size), pull(pull)
: pos(pos), size(size), spd(spd), pull(pull)
{}
ParticleInfluence() : size(0), spd(0), pull(false) {}
Vector pos;

View file

@ -142,7 +142,7 @@ void Precacher::precacheList(const std::string &list, void progressCallback())
t = t.substr(0,t.size()-1);
debugLog("precache["+t+"]");
#endif
stringToLower(t);
stringToLower(t);
precacheTex(t);
}
}

View file

@ -23,7 +23,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "RenderBase.h"
QuadTrail::QuadTrail(int maxPoints, float pointDist)
: RenderObject(), maxPoints(maxPoints), pointDist(pointDist), numPoints(0)
: RenderObject()
, numPoints(0)
, maxPoints(maxPoints)
, pointDist(pointDist)
{
quadTrailAlphaEffect = QTAE_NORMAL;
cull = false;

View file

@ -73,9 +73,9 @@ void Shader::staticInit()
// everything fine when we are here
_useShaders = true;
#endif
end:
end:
#endif
if (_useShaders)
debugLog("Shader support enabled.");
@ -187,7 +187,7 @@ void Shader::load(const std::string &file, const std::string &fragFile)
this->vertFile = file;
this->fragFile = fragFile;
char *vertCode = file.length() ? readFile(file) : NULL;
char *vertCode = file.length() ? readFile(file) : NULL;
char *fragCode = fragFile.length() ? readFile(fragFile) : NULL;
loadSrc(vertCode, fragCode);
@ -288,14 +288,14 @@ void Shader::_setUniform(Uniform *u)
{
switch(u->type)
{
case GL_FLOAT: glUniform1fvARB(u->location, 1, u->data.f); break;
case GL_FLOAT_VEC2_ARB: glUniform2fvARB(u->location, 1, u->data.f); break;
case GL_FLOAT_VEC3_ARB: glUniform3fvARB(u->location, 1, u->data.f); break;
case GL_FLOAT_VEC4_ARB: glUniform4fvARB(u->location, 1, u->data.f); break;
case GL_INT: glUniform1ivARB(u->location, 1, u->data.i); break;
case GL_INT_VEC2_ARB: glUniform2ivARB(u->location, 1, u->data.i); break;
case GL_INT_VEC3_ARB: glUniform3ivARB(u->location, 1, u->data.i); break;
case GL_INT_VEC4_ARB: glUniform4ivARB(u->location, 1, u->data.i); break;
case GL_FLOAT: glUniform1fvARB(u->location, 1, u->data.f.f); break;
case GL_FLOAT_VEC2_ARB: glUniform2fvARB(u->location, 1, u->data.f.f); break;
case GL_FLOAT_VEC3_ARB: glUniform3fvARB(u->location, 1, u->data.f.f); break;
case GL_FLOAT_VEC4_ARB: glUniform4fvARB(u->location, 1, u->data.f.f); break;
case GL_INT: glUniform1ivARB(u->location, 1, u->data.i.i); break;
case GL_INT_VEC2_ARB: glUniform2ivARB(u->location, 1, u->data.i.i); break;
case GL_INT_VEC3_ARB: glUniform3ivARB(u->location, 1, u->data.i.i); break;
case GL_INT_VEC4_ARB: glUniform4ivARB(u->location, 1, u->data.i.i); break;
}
u->dirty = false;
}
@ -391,10 +391,10 @@ void Shader::setInt(const char *name, int x, int y /* = 0 */, int z /* = 0 */, i
if(unsigned(idx) >= uniforms.size())
return;
Uniform& u = uniforms[idx];
u.data.i[0] = x;
u.data.i[1] = y;
u.data.i[2] = z;
u.data.i[3] = w;
u.data.i.i[0] = x;
u.data.i.i[1] = y;
u.data.i.i[2] = z;
u.data.i.i[3] = w;
u.dirty = true;
uniformsDirty = true;
#endif
@ -409,10 +409,10 @@ void Shader::setFloat(const char *name, float x, float y /* = 0 */, float z /* =
if(unsigned(idx) >= uniforms.size())
return;
Uniform& u = uniforms[idx];
u.data.f[0] = x;
u.data.f[1] = y;
u.data.f[2] = z;
u.data.f[3] = w;
u.data.f.f[0] = x;
u.data.f.f[1] = y;
u.data.f.f[2] = z;
u.data.f.f[3] = w;
u.dirty = true;
uniformsDirty = true;
#endif

View file

@ -62,14 +62,14 @@ private:
bool dirty; // need to flush if true
union
{
struct
struct si
{
int i[4];
};
struct
} i;
struct sf
{
float f[4];
};
} f;
} data;
char name[64];

View file

@ -377,6 +377,9 @@ void BoneCommand::run()
case AC_RESET_PASS:
b->setRenderPass(b->originalRenderPass);
break;
case AC_SEGS_START:
case AC_SEGS_STOP:
break;
}
}
@ -409,8 +412,8 @@ void AnimationLayer::playCurrentAnimation(int loop)
void AnimationLayer::animate(const std::string &a, int loop)
{
std::string animation = a;
stringToLower(animation);
std::string animation = a;
stringToLower(animation);
bool played = false;
for (int i = 0; i < s->animations.size(); i++)
@ -458,7 +461,7 @@ void AnimationLayer::enqueueAnimation(const std::string& anim, int loop)
float AnimationLayer::transitionAnimate(std::string anim, float time, int loop)
{
stringToLower(anim);
stringToLower(anim);
float totalTime =0;
if (createTransitionAnimation(anim, time))
{

View file

@ -108,7 +108,7 @@ public:
class BoneKeyframe
{
public:
BoneKeyframe() : idx(0), x(0), y(0), rot(0), doScale(0), sx(1), sy(1) {}
BoneKeyframe() : idx(0), x(0), y(0), rot(0), sx(1), sy(1), doScale(0) {}
int idx, x, y, rot;
float sx, sy;
bool doScale;

View file

@ -25,13 +25,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "ttvfs_stdio.h"
#ifdef BBGE_BUILD_FMOD_OPENAL_BRIDGE
#include "FmodOpenALBridge.h"
#include "FmodOpenALBridge.h"
#else
#include <fmod.h>
#include <fmod.hpp>
#ifdef BBGE_BUILD_WINDOWS
#include <fmod.h>
#include <fmod.hpp>
#ifdef BBGE_BUILD_WINDOWS
#pragma comment(lib, "fmodex_vc.lib")
#endif
#endif
#endif
@ -73,7 +73,7 @@ namespace SoundCore
struct FadeCh
{
public:
FadeCh() : v(1), s(1), c(0), d(-1), to(0) {}
FadeCh() : c(0), v(1), s(1), to(0), d(-1) {}
FMOD::Channel *c;
float v,s,to;
int d;
@ -112,17 +112,17 @@ using namespace SoundCore;
/*
TIPS:
TIPS:
1. use F_CALLBACK. Do NOT force cast your own function to fmod's callback type.
2. return FMOD_ERR_FILE_NOTFOUND in open as required.
3. return number of bytes read in read callback. Do not get the size and count
around the wrong way in fread for example, this would return 1 instead of the number of bytes read.
1. use F_CALLBACK. Do NOT force cast your own function to fmod's callback type.
2. return FMOD_ERR_FILE_NOTFOUND in open as required.
3. return number of bytes read in read callback. Do not get the size and count
around the wrong way in fread for example, this would return 1 instead of the number of bytes read.
QUESTIONS:
QUESTIONS:
1. Why does fmod seek to the end and read? Because it is looking for ID3V1 tags.
Use FMOD_IGNORETAGS in System::createSound / System::createStream if you don't like this behaviour.
1. Why does fmod seek to the end and read? Because it is looking for ID3V1 tags.
Use FMOD_IGNORETAGS in System::createSound / System::createStream if you don't like this behaviour.
*/
@ -279,54 +279,54 @@ SoundManager::SoundManager(const std::string &defaultDevice)
int channels = 128;
unsigned int version;
FMOD_SPEAKERMODE speakermode;
FMOD_CAPS caps;
unsigned int version;
FMOD_SPEAKERMODE speakermode;
FMOD_CAPS caps;
debugLog("system::create");
result = FMOD::System_Create(&SoundCore::system);
if (checkError()) goto get_out;
if (checkError()) goto get_out;
debugLog("getVersion");
result = SoundCore::system->getVersion(&version);
if (checkError()) goto get_out;
result = SoundCore::system->getVersion(&version);
if (checkError()) goto get_out;
if (version < FMOD_VERSION)
{
if (version < FMOD_VERSION)
{
char str[256];
sprintf(str, "Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
sprintf(str, "Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
debugLog(str);
goto get_out;
}
}
debugLog("driver caps");
result = SoundCore::system->getDriverCaps(0, &caps, 0, 0, &speakermode);
if (checkError()) goto get_out;
result = SoundCore::system->getDriverCaps(0, &caps, 0, 0, &speakermode);
if (checkError()) goto get_out;
debugLog("set speaker mode");
result = SoundCore::system->setSpeakerMode(speakermode); /* Set the user selected speaker mode. */
result = SoundCore::system->setSpeakerMode(speakermode); /* Set the user selected speaker mode. */
if (checkError()) goto get_out;
debugLog("check caps");
if (caps & FMOD_CAPS_HARDWARE_EMULATED) /* The user has the 'Acceleration' slider set to off! This is really bad for latency!. */
{ /* You might want to warn the user about this. */
if (caps & FMOD_CAPS_HARDWARE_EMULATED) /* The user has the 'Acceleration' slider set to off! This is really bad for latency!. */
{ /* You might want to warn the user about this. */
debugLog("acceleration slider is off");
result = SoundCore::system->setDSPBufferSize(1024, 10); /* At 48khz, the latency between issuing an fmod command and hearing it will now be about 213ms. */
if (checkError()) goto get_out;
}
result = SoundCore::system->setDSPBufferSize(1024, 10); /* At 48khz, the latency between issuing an fmod command and hearing it will now be about 213ms. */
if (checkError()) goto get_out;
}
debugLog("init");
result = SoundCore::system->init(channels, FMOD_INIT_NORMAL, 0); /* Replace with whatever channel count and flags you use! */
if (result == FMOD_ERR_OUTPUT_CREATEBUFFER) /* Ok, the speaker mode selected isn't supported by this soundcard. Switch it back to stereo... */
{
result = SoundCore::system->init(channels, FMOD_INIT_NORMAL, 0); /* Replace with whatever channel count and flags you use! */
if (result == FMOD_ERR_OUTPUT_CREATEBUFFER) /* Ok, the speaker mode selected isn't supported by this soundcard. Switch it back to stereo... */
{
debugLog("err_output_createbuffer, speaker mode");
result = SoundCore::system->setSpeakerMode(FMOD_SPEAKERMODE_STEREO);
if (checkError()) goto get_out;
if (checkError()) goto get_out;
debugLog("init 2");
result = SoundCore::system->init(channels, FMOD_INIT_NORMAL, 0); /* Replace with whatever channel count and flags you use! */
result = SoundCore::system->init(channels, FMOD_INIT_NORMAL, 0); /* Replace with whatever channel count and flags you use! */
if (checkError()) goto get_out;
}
}
#ifdef BBGE_BUILD_FMOD_OPENAL_BRIDGE
SoundCore::system->getNumChannels(&channels);
@ -336,7 +336,7 @@ SoundManager::SoundManager(const std::string &defaultDevice)
debugLog("set file system");
result = SoundCore::system->setFileSystem(myopen, myclose, myread, myseek, 2048);
if (checkError()) goto get_out;
if (checkError()) goto get_out;
debugLog("create channel group vox");
result = SoundCore::system->createChannelGroup("vox", &group_vox);
@ -411,6 +411,9 @@ void SoundManager::toggleEffectMusic(SoundEffectType effect, bool on)
dspFlange->remove();
}
break;
case SFX_NONE:
case SFX_MAX:
break;
}
}

View file

@ -83,9 +83,8 @@ enum SoundLoadType
struct PlaySfx
{
PlaySfx() : priority(0.5), vol(1), fade(SFT_NONE),
time(0), freq(1), loops(0),
maxdist(0), x(0), y(0), relative(true), positional(false) {}
PlaySfx() : vol(1), time(0), freq(1), loops(0), priority(0.5),
maxdist(0), fade(SFT_NONE), x(0), y(0), relative(true), positional(false) {}
std::string name;
float vol;

View file

@ -221,7 +221,7 @@ bool Texture::load(std::string file)
size_t pos = file.find_last_of('.');
if ((pos != std::string::npos) && (pos >= 0))
if (pos != std::string::npos)
{
// make sure this didn't catch the '.' in /home/username/.Aquaria/* --ryan.
const std::string userdata = core->getUserDataFolder();
@ -500,8 +500,8 @@ ImageTGA *Texture::TGAloadMem(void *mem, int size)
// files are stored as BGR instead of RGB (or use GL_BGR_EXT verses GL_RGB)
for(i = 0; i < stride; i += channels)
{
int temp = pLine[i];
pLine[i] = pLine[i + 2];
int temp = pLine[i];
pLine[i] = pLine[i + 2];
pLine[i + 2] = temp;
}
}
@ -653,8 +653,8 @@ ImageTGA *Texture::TGAloadMem(void *mem, int size)
// Fill in our tImageTGA structure to pass back
pImageData->channels = channels;
pImageData->sizeX = width;
pImageData->sizeY = height;
pImageData->sizeX = width;
pImageData->sizeY = height;
// Return the TGA data (remember, you must free this data after you are done)
return pImageData;