mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-07-03 06:24:32 +00:00
Merge branch 'master' of https://github.com/dimag0g/Aquaria
This commit is contained in:
commit
c6968454e6
1068 changed files with 155492 additions and 90661 deletions
|
@ -13,53 +13,11 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "ActionMapper.h"
|
||||
#include "Core.h"
|
||||
|
||||
//bool ActionMapper::isActing(const std::string &action)
|
||||
//{
|
||||
// ButtonList::iterator i = actionMap[action].begin();
|
||||
// for (; i != actionMap[action].end(); i++)
|
||||
// {
|
||||
// if (keyDownMap[(*i)])
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
// //return keyDownMap[actionMap[action]];
|
||||
//}
|
||||
|
||||
//bool ActionMapper::isActing(int actionID)
|
||||
//{
|
||||
// std::string action = "A";
|
||||
// action[0] = char(actionID);
|
||||
// ButtonList::iterator i = actionMap[action].begin();
|
||||
// for (; i != actionMap[action].end(); i++)
|
||||
// {
|
||||
// if (keyDownMap[(*i)])
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
// //return keyDownMap[actionMap[action]];
|
||||
//}
|
||||
|
||||
//void ActionMapper::addAction (const std::string &action, int k)
|
||||
//{
|
||||
// actionMap[action].push_back(k);
|
||||
// keyDownMap[k] = core->getKeyState(k);
|
||||
//}
|
||||
//
|
||||
//void ActionMapper::addAction (int actionID, int k)
|
||||
//{
|
||||
// std::string action = "A";
|
||||
// action[0] = char(actionID);
|
||||
// actionMap[action].push_back(k);
|
||||
// keyDownMap[k] = core->getKeyState(k);
|
||||
//}
|
||||
|
||||
ActionMapper::ActionMapper()
|
||||
{
|
||||
|
@ -104,11 +62,7 @@ void ActionMapper::addAction (int actionID, int k)
|
|||
|
||||
if (ad)
|
||||
{
|
||||
/*
|
||||
std::ostringstream os;
|
||||
os << "Action ID [" << actionID << "] already exists!";
|
||||
debugLog(os.str());
|
||||
*/
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -166,55 +120,7 @@ void ActionMapper::clearCreatedEvents()
|
|||
createdEvents.clear();
|
||||
}
|
||||
|
||||
/*
|
||||
void ActionMapper::addMouseButtonAction (const std::string &action, int b)
|
||||
{
|
||||
actionMap[action].push_back (0-b);
|
||||
keyDownMap[0-b] = mouse_b & b;
|
||||
}
|
||||
|
||||
void ActionMapper::addJoystickButtonAction (const std::string &action, int b)
|
||||
{
|
||||
if (num_joysticks)
|
||||
{
|
||||
actionMap[action].push_back (b+9000);
|
||||
keyDownMap[b+9000] = joy[0].button[b].b;
|
||||
}
|
||||
}
|
||||
|
||||
int ActionMapper::getDPad(int dir)
|
||||
{
|
||||
// for (int = 0; i < joy[0].num_sticks; i++)
|
||||
//int s = 4;
|
||||
int s = 0;
|
||||
switch (dir)
|
||||
{
|
||||
case 0:
|
||||
return (joy[0].stick[s].axis[0].d1);
|
||||
break;
|
||||
case 1:
|
||||
return (joy[0].stick[s].axis[0].d2);
|
||||
break;
|
||||
case 2:
|
||||
return (joy[0].stick[s].axis[1].d1);
|
||||
break;
|
||||
case 3:
|
||||
return (joy[0].stick[s].axis[1].d2);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void ActionMapper::addJoystickDPadAction (const std::string &action, int dir)
|
||||
{
|
||||
if (num_joysticks)
|
||||
{
|
||||
actionMap[action].push_back (dir+8000);
|
||||
keyDownMap[dir+8000] = getDPad(dir);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
void ActionMapper::enableInput()
|
||||
{
|
||||
|
@ -235,7 +141,7 @@ void ActionMapper::removeAction(int actionID)
|
|||
for (; i != ad->buttonList.end(); i++)
|
||||
{
|
||||
int k = (*i);
|
||||
cleared = true; // it's a hack, but it works
|
||||
cleared = true; // it's a hack, but it works
|
||||
keyDownMap.erase(k);
|
||||
}
|
||||
for (ActionDataSet::iterator i = actionData.begin(); i != actionData.end();)
|
||||
|
@ -248,19 +154,7 @@ void ActionMapper::removeAction(int actionID)
|
|||
}
|
||||
}
|
||||
|
||||
//int ActionMapper::getKeyForAction (std::string action)
|
||||
//{
|
||||
// ButtonList b = actionMap[action];
|
||||
// if (!b.empty())
|
||||
// {
|
||||
// return b[0];
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// debugLog ("no action: " +action);
|
||||
// return -1;
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
bool ActionMapper::pollAction(int actionID)
|
||||
{
|
||||
|
@ -272,7 +166,7 @@ bool ActionMapper::pollAction(int actionID)
|
|||
ButtonList *blist = &ad->buttonList;
|
||||
ButtonList::iterator j;
|
||||
j = blist->begin();
|
||||
|
||||
|
||||
for (; j != blist->end(); j++)
|
||||
{
|
||||
if (getKeyState((*j)))
|
||||
|
@ -316,11 +210,11 @@ bool ActionMapper::getKeyState(int k)
|
|||
else if (k == MOUSE_BUTTON_MIDDLE)
|
||||
{
|
||||
keyState = (core->mouse.buttons.middle == DOWN);
|
||||
}
|
||||
}
|
||||
else if (k >= JOY1_BUTTON_0 && k <= JOY1_BUTTON_16)
|
||||
{
|
||||
int v = k - JOY1_BUTTON_0;
|
||||
|
||||
|
||||
if (core->joystickEnabled)
|
||||
keyState = core->joystick.buttons[v];
|
||||
}
|
||||
|
@ -369,13 +263,10 @@ bool ActionMapper::getKeyState(int k)
|
|||
}
|
||||
|
||||
void ActionMapper::onUpdate (float dt)
|
||||
{
|
||||
{
|
||||
if (inUpdate) return;
|
||||
inUpdate = true;
|
||||
/*
|
||||
if (num_joysticks)
|
||||
poll_joystick();
|
||||
*/
|
||||
|
||||
if (cleared) cleared = false;
|
||||
ActionDataSet::iterator i;
|
||||
KeyDownMap oldKeyDownMap = keyDownMap;
|
||||
|
@ -392,7 +283,7 @@ void ActionMapper::onUpdate (float dt)
|
|||
keyState = getKeyState(k);
|
||||
|
||||
if (keyState != oldKeyDownMap[k])
|
||||
{
|
||||
{
|
||||
keyDownMap[k] = keyState;
|
||||
if (inputEnabled)
|
||||
{
|
||||
|
@ -417,7 +308,7 @@ void ActionMapper::onUpdate (float dt)
|
|||
|
||||
out:
|
||||
inUpdate = false;
|
||||
// keyDownMap[k] = ;
|
||||
|
||||
}
|
||||
|
||||
void ActionMapper::clearActions()
|
||||
|
|
|
@ -44,45 +44,37 @@ struct ActionData
|
|||
class ActionMapper
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
// funcs
|
||||
ActionMapper();
|
||||
virtual ~ActionMapper();
|
||||
//void addAction (const std::string &action, int k);
|
||||
|
||||
void addAction(Event *event, int k, int state=-1);
|
||||
void addAction(int actionID, int k);
|
||||
/*
|
||||
void addMouseButtonAction (const std::string &action, int b);
|
||||
void addJoystickButtonAction (const std::string &action, int b);
|
||||
void addJoystickDPadAction (const std::string &action, int dir);
|
||||
int getDPad(int dir);
|
||||
*/
|
||||
|
||||
void removeAction(int actionID);
|
||||
void removeAllActions();
|
||||
|
||||
bool isActing(int actionID);
|
||||
virtual void action(int actionID, int state){}
|
||||
|
||||
|
||||
|
||||
void clearActions();
|
||||
|
||||
bool isInputEnabled() { return inputEnabled; }
|
||||
|
||||
|
||||
// vars
|
||||
|
||||
|
||||
typedef std::list<ActionData> ActionDataSet;
|
||||
ActionDataSet actionData;
|
||||
|
||||
typedef std::map <int, int> KeyDownMap;
|
||||
KeyDownMap keyDownMap;
|
||||
|
||||
|
||||
bool cleared;
|
||||
|
||||
|
||||
|
||||
//typedef std::map <std::string, int> StringIntMap;
|
||||
//StringIntMap stateCheckMap;
|
||||
|
||||
enum {
|
||||
MOUSE_BUTTON_LEFT = 999,
|
||||
MOUSE_BUTTON_RIGHT = 1000,
|
||||
|
@ -106,7 +98,7 @@ public:
|
|||
JOY1_BUTTON_15 = 2015,
|
||||
JOY1_BUTTON_16 = 2016,
|
||||
|
||||
//JOY1_BUTTON_X360_START=2011,
|
||||
|
||||
X360_BTN_START = 3016,
|
||||
X360_BTN_BACK = 3017,
|
||||
|
||||
|
@ -122,13 +114,13 @@ public:
|
|||
|
||||
enum { DPAD_LEFT = 0, DPAD_RIGHT, DPAD_UP, DPAD_DOWN };
|
||||
|
||||
//int getKeyForAction(std::string action);
|
||||
|
||||
|
||||
virtual void enableInput();
|
||||
virtual void disableInput();
|
||||
/*void loadActionSet(const std::string &fn);*/
|
||||
//nasty hack
|
||||
//void forceUpdate(float dt);
|
||||
|
||||
|
||||
|
||||
Event *addCreatedEvent(Event *event);
|
||||
void clearCreatedEvents();
|
||||
|
||||
|
@ -149,4 +141,3 @@ protected:
|
|||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -38,68 +38,7 @@ ActionInput *ActionSet::getActionInputByName(const std::string &name)
|
|||
return 0;
|
||||
}
|
||||
|
||||
//void ActionSet::loadAction(const std::string &name, int inputCode, InputSetType set)
|
||||
//{
|
||||
// ActionInput *a = getActionInputByName(name);
|
||||
// if (!a)
|
||||
// {
|
||||
// ActionInput newa;
|
||||
// newa.name = name;
|
||||
// inputSet.push_back(newa);
|
||||
// a = getActionInputByName(name);
|
||||
//
|
||||
// if (!a) return;
|
||||
// }
|
||||
//
|
||||
// switch(set)
|
||||
// {
|
||||
// case INPUTSET_KEY:
|
||||
// a->keyCodes.push_back(inputCode);
|
||||
// break;
|
||||
// case INPUTSET_JOY:
|
||||
// a->joyCodes.push_back(inputCode);
|
||||
// break;
|
||||
// case INPUTSET_MOUSE:
|
||||
// a->mouseCodes.push_back(inputCode);
|
||||
// break;
|
||||
// case INPUTSET_GENERAL:
|
||||
// default:
|
||||
// a->inputCodes.push_back(inputCode);
|
||||
// break;
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//void ActionSet::loadAction(const std::string &name, const std::vector<int> &inputCodes, InputSetType set)
|
||||
//{
|
||||
//
|
||||
// ActionInput *a = getActionInputByName(name);
|
||||
// if (!a)
|
||||
// {
|
||||
// ActionInput newa;
|
||||
// newa.name = name;
|
||||
// inputSet.push_back(newa);
|
||||
// a = getActionInputByName(name);
|
||||
//
|
||||
// if (!a) return;
|
||||
// }
|
||||
//
|
||||
// switch(set)
|
||||
// {
|
||||
// case INPUTSET_KEY:
|
||||
// a->keyCodes = inputCodes;
|
||||
// break;
|
||||
// case INPUTSET_JOY:
|
||||
// a->joyCodes = inputCodes;
|
||||
// break;
|
||||
// case INPUTSET_MOUSE:
|
||||
// a->mouseCodes = inputCodes;
|
||||
// break;
|
||||
// case INPUTSET_GENERAL:
|
||||
// default:
|
||||
// a->inputCodes = inputCodes;
|
||||
// break;
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
void ActionSet::importAction(ActionMapper *mapper, const std::string &name, int actionID)
|
||||
{
|
||||
|
@ -168,7 +107,7 @@ ActionInput *ActionSet::addActionInput(const std::string &name)
|
|||
std::string ActionSet::insertInputIntoString(const std::string &string)
|
||||
{
|
||||
std::string str = string;
|
||||
|
||||
|
||||
int start = str.find('{');
|
||||
int end = str.find('}');
|
||||
if (start == std::string::npos || end == std::string::npos)
|
||||
|
@ -177,18 +116,18 @@ std::string ActionSet::insertInputIntoString(const std::string &string)
|
|||
stringToLower(code);
|
||||
std::string part1 = str.substr(0, start);
|
||||
std::string part3 = str.substr(end+1, str.size());
|
||||
|
||||
//{ToggleHelp:k0}
|
||||
|
||||
|
||||
int thing = code.find(':');
|
||||
std::string input = code.substr(0, thing);
|
||||
std::string button = code.substr(thing+1, code.size());
|
||||
|
||||
|
||||
char buttonType;
|
||||
int buttonNum;
|
||||
|
||||
|
||||
std::istringstream is(button);
|
||||
is >> buttonType >> buttonNum;
|
||||
|
||||
|
||||
ActionInput *actionInput=0;
|
||||
actionInput = getActionInputByName(input);
|
||||
if (!actionInput)
|
||||
|
@ -209,7 +148,7 @@ std::string ActionSet::insertInputIntoString(const std::string &string)
|
|||
inputCode = actionInput->mse[buttonNum];
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
std::string part2 = getInputCodeToUserString(inputCode);
|
||||
return part1 + part2 + part3;
|
||||
}
|
||||
|
|
|
@ -39,13 +39,12 @@ public:
|
|||
|
||||
ActionInput *addActionInput(const std::string &name);
|
||||
|
||||
//void loadAction(const std::string &name, int inputCode, InputSetType set);
|
||||
//void loadAction(const std::string &name, const std::vector<int> &inputCodes, InputSetType set=INPUTSET_GENERAL);
|
||||
|
||||
|
||||
ActionInput *getActionInputByName(const std::string &name);
|
||||
|
||||
ActionInputSet inputSet;
|
||||
|
||||
|
||||
std::string insertInputIntoString(const std::string &string);
|
||||
};
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ along with this program; if not, write to the Free Software
|
|||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "AfterEffect.h"
|
||||
//#include "math.h"
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
|
@ -76,7 +76,7 @@ AfterEffectManager::~AfterEffectManager()
|
|||
for (i = 0; i < xDivs; i++)
|
||||
{
|
||||
delete[] drawGrid[i];
|
||||
}
|
||||
}
|
||||
delete[] drawGrid;
|
||||
}
|
||||
deleteEffects();
|
||||
|
@ -128,7 +128,7 @@ void AfterEffectManager::clear()
|
|||
|
||||
void AfterEffectManager::update(float dt)
|
||||
{
|
||||
if (core->particlesPaused) return;
|
||||
if (core->particlesPaused) return;
|
||||
|
||||
resetGrid();
|
||||
|
||||
|
@ -138,7 +138,7 @@ void AfterEffectManager::update(float dt)
|
|||
active = false;
|
||||
|
||||
for (int i = 0; i < effects.size(); i++)
|
||||
{
|
||||
{
|
||||
Effect *e = effects[i];
|
||||
if (e)
|
||||
{
|
||||
|
@ -177,7 +177,6 @@ void AfterEffectManager::render()
|
|||
{
|
||||
assert(core->frameBuffer.isInited());
|
||||
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
glPushMatrix();
|
||||
|
||||
glDisable (GL_ALPHA_TEST);
|
||||
|
@ -189,14 +188,12 @@ void AfterEffectManager::render()
|
|||
|
||||
glColor4f(1,1,1,1);
|
||||
renderGrid();
|
||||
//renderGridPoints();
|
||||
|
||||
glPopMatrix();
|
||||
#endif
|
||||
}
|
||||
|
||||
void AfterEffectManager::renderGrid()
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
|
||||
int firstShader = -1;
|
||||
int lastShader = -1;
|
||||
|
@ -237,29 +234,29 @@ void AfterEffectManager::renderGrid()
|
|||
backupBuffer.startCapture();
|
||||
}
|
||||
|
||||
//float div = xDivs;
|
||||
|
||||
for (int i = 0; i < (xDivs-1); i++)
|
||||
{
|
||||
for (int j = 0; j < (yDivs-1); j++)
|
||||
{
|
||||
glBegin(GL_QUADS);
|
||||
//glColor3f(i/div, i/div, i/div);
|
||||
{
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
glTexCoord2f(i/(float)(xDivs-1)*percentX, 1*percentY-(j)/(float)(yDivs-1)*percentY);
|
||||
//glMultiTexCoord2fARB(GL_TEXTURE0_ARB,i/(float)(xDivs-1)*percentX, 1*percentY-(j)/(float)(yDivs-1)*percentY);
|
||||
//glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0,0);
|
||||
|
||||
|
||||
glVertex2f(offx + vw*drawGrid[i][j].x, offy + vh*drawGrid[i][j].y);
|
||||
glTexCoord2f(i/(float)(xDivs-1)*percentX, 1*percentY-(j+1)/(float)(yDivs-1)*percentY);
|
||||
//glMultiTexCoord2fARB(GL_TEXTURE0_ARB,i/(float)(xDivs-1)*percentX, 1*percentY-(j+1)/(float)(yDivs-1)*percentY);
|
||||
//glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0,(float)(screenHeight/(yDivs-1))/16);
|
||||
|
||||
|
||||
glVertex2f(offx + vw*drawGrid[i][j+1].x, offy + vh*drawGrid[i][j+1].y);
|
||||
glTexCoord2f((i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j+1)/(float)(yDivs-1)*percentY);
|
||||
//glMultiTexCoord2fARB(GL_TEXTURE0_ARB,(i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j+1)/(float)(yDivs-1)*percentY);
|
||||
//glMultiTexCoord2fARB(GL_TEXTURE1_ARB,(float)(screenWidth/(xDivs-1))/16,(float)(screenHeight/(yDivs-1))/16);
|
||||
glTexCoord2f((i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j+1)/(float)(yDivs-1)*percentY);
|
||||
|
||||
|
||||
glVertex2f(offx + vw*drawGrid[i+1][j+1].x, offy + vh*drawGrid[i+1][j+1].y);
|
||||
glTexCoord2f((i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j)/(float)(yDivs-1)*percentY);
|
||||
//glMultiTexCoord2fARB(GL_TEXTURE0_ARB,(i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j)/(float)(yDivs-1)*percentY);
|
||||
//glMultiTexCoord2fARB(GL_TEXTURE1_ARB,(float)(screenWidth/(xDivs-1))/16,0);
|
||||
glVertex2f(offx + vw*drawGrid[i+1][j].x, offy + vh*drawGrid[i+1][j].y);
|
||||
glTexCoord2f((i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j)/(float)(yDivs-1)*percentY);
|
||||
|
||||
|
||||
glVertex2f(offx + vw*drawGrid[i+1][j].x, offy + vh*drawGrid[i+1][j].y);
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
|
@ -267,10 +264,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.
|
||||
|
@ -296,7 +289,7 @@ void AfterEffectManager::renderGrid()
|
|||
|
||||
activeShader->bind();
|
||||
activeShader->setInt("tex", 0);
|
||||
|
||||
|
||||
// note that offx, offy are negative here!
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2d(0.0f, 0.0f);
|
||||
|
@ -308,7 +301,7 @@ void AfterEffectManager::renderGrid()
|
|||
glTexCoord2d(0.0f, percentY);
|
||||
glVertex3f(offx, offy, 0.0f);
|
||||
glEnd();
|
||||
|
||||
|
||||
activeShader->unbind();
|
||||
}
|
||||
}
|
||||
|
@ -322,8 +315,8 @@ void AfterEffectManager::renderGrid()
|
|||
for (int i = 0; i < (xDivs-1); i++)
|
||||
{
|
||||
for (int j = 0; j < (yDivs-1); j++)
|
||||
{
|
||||
glBegin(GL_POINTS);
|
||||
{
|
||||
glBegin(GL_POINTS);
|
||||
//glColor3f(i/div, i/div, i/div);
|
||||
glTexCoord2f(i/(float)(xDivs-1)*percentX, 1*percentY-(j)/(float)(yDivs-1)*percentY);
|
||||
//glMultiTexCoord2fARB(GL_TEXTURE0_ARB,i/(float)(xDivs-1)*percentX, 1*percentY-(j)/(float)(yDivs-1)*percentY);
|
||||
|
@ -333,17 +326,17 @@ void AfterEffectManager::renderGrid()
|
|||
//glMultiTexCoord2fARB(GL_TEXTURE0_ARB,i/(float)(xDivs-1)*percentX, 1*percentY-(j+1)/(float)(yDivs-1)*percentY);
|
||||
//glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0,(float)(screenHeight/(yDivs-1))/16);
|
||||
glVertex2f(800*drawGrid[i][j+1].x, 600*drawGrid[i][j+1].y);
|
||||
glTexCoord2f((i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j+1)/(float)(yDivs-1)*percentY);
|
||||
//glMultiTexCoord2fARB(GL_TEXTURE0_ARB,(i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j+1)/(float)(yDivs-1)*percentY);
|
||||
//glMultiTexCoord2fARB(GL_TEXTURE1_ARB,(float)(screenWidth/(xDivs-1))/16,(float)(screenHeight/(yDivs-1))/16);
|
||||
glTexCoord2f((i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j+1)/(float)(yDivs-1)*percentY);
|
||||
//glMultiTexCoord2fARB(GL_TEXTURE0_ARB,(i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j+1)/(float)(yDivs-1)*percentY);
|
||||
//glMultiTexCoord2fARB(GL_TEXTURE1_ARB,(float)(screenWidth/(xDivs-1))/16,(float)(screenHeight/(yDivs-1))/16);
|
||||
glVertex2f(800*drawGrid[i+1][j+1].x, 600*drawGrid[i+1][j+1].y);
|
||||
glTexCoord2f((i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j)/(float)(yDivs-1)*percentY);
|
||||
//glMultiTexCoord2fARB(GL_TEXTURE0_ARB,(i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j)/(float)(yDivs-1)*percentY);
|
||||
//glMultiTexCoord2fARB(GL_TEXTURE1_ARB,(float)(screenWidth/(xDivs-1))/16,0);
|
||||
glVertex2f(800*drawGrid[i+1][j].x, 600*drawGrid[i+1][j].y);
|
||||
glTexCoord2f((i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j)/(float)(yDivs-1)*percentY);
|
||||
//glMultiTexCoord2fARB(GL_TEXTURE0_ARB,(i+1)/(float)(xDivs-1)*percentX, 1*percentY-(j)/(float)(yDivs-1)*percentY);
|
||||
//glMultiTexCoord2fARB(GL_TEXTURE1_ARB,(float)(screenWidth/(xDivs-1))/16,0);
|
||||
glVertex2f(800*drawGrid[i+1][j].x, 600*drawGrid[i+1][j].y);
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
//glDisable(GL_TEXTURE_2D);
|
||||
|
@ -352,15 +345,13 @@ void AfterEffectManager::renderGrid()
|
|||
|
||||
//bwShader.unbind();
|
||||
//glActiveTextureARB(GL_TEXTURE0_ARB);
|
||||
//glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
//glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
//if (bRenderGridPoints)
|
||||
// renderGridPoints();
|
||||
#endif
|
||||
}
|
||||
|
||||
void AfterEffectManager::renderGridPoints()
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
glColor4f(0.0f,0.0f,0.0f,1.0f);
|
||||
for (int i = 0; i < (xDivs); i++)
|
||||
{
|
||||
|
@ -374,7 +365,6 @@ void AfterEffectManager::renderGridPoints()
|
|||
glEnd();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void AfterEffectManager::unloadDevice()
|
||||
|
@ -438,31 +428,15 @@ void AfterEffectManager::addEffect(Effect *e)
|
|||
effects.push_back(e);
|
||||
}
|
||||
numEffects++;
|
||||
//float lowest = 9999;
|
||||
Vector base(0,0,0);
|
||||
//Vector *newPos = &base;
|
||||
//Vector *v;
|
||||
e->position.x /= screenWidth;
|
||||
//e->position.x *= xDivs;
|
||||
e->position.y /= screenHeight;
|
||||
//e->position.y *= yDivs;
|
||||
|
||||
/*
|
||||
for (int x = 1; x < xDivs-1; x++)
|
||||
{
|
||||
for (int y = 1; y < yDivs-1; y++)
|
||||
{
|
||||
v = &drawGrid[x][y];
|
||||
float dist = (v->x - e->position.x)*(v->x - e->position.x)+(v->y - e->position.y)*(v->y - e->position.y);
|
||||
if (dist < lowest)
|
||||
{
|
||||
lowest = dist;
|
||||
newPos = &drawGrid[x][y];
|
||||
}
|
||||
}
|
||||
}
|
||||
e->position = Vector(newPos->x, newPos->y, newPos->z);
|
||||
*/
|
||||
Vector base(0,0,0);
|
||||
|
||||
|
||||
e->position.x /= screenWidth;
|
||||
|
||||
e->position.y /= screenHeight;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -471,18 +445,13 @@ void ShockEffect::update(float dt, Vector ** drawGrid, int xDivs, int yDivs)
|
|||
{
|
||||
dt *= timeMultiplier;
|
||||
Effect::update(dt, drawGrid, xDivs, yDivs);
|
||||
//GLdouble sx, sy,sz;
|
||||
/*
|
||||
gluProject(position.x,position.y,position.z,
|
||||
nCameraPointer->modelMatrix,nCameraPointer->projMatrix,nCameraPointer->viewport,
|
||||
&sx,&sy,&sz); // Find out where the light is on the screen.
|
||||
centerPoint.Set(sx/(float)nCameraPointer->viewport[2],1-sy/(float)nCameraPointer->viewport[3],sz);
|
||||
|
||||
*/
|
||||
|
||||
|
||||
centerPoint = position;
|
||||
centerPoint -= ((core->screenCenter-originalCenter)*core->globalScale.x)/core->width;
|
||||
//centerPoint = position/xDivs;
|
||||
//centerPoint = drawGrid[xDivs/2][yDivs/2];
|
||||
|
||||
|
||||
float xDist,yDist,tDist;
|
||||
|
||||
|
||||
|
@ -490,8 +459,7 @@ void ShockEffect::update(float dt, Vector ** drawGrid, int xDivs, int yDivs)
|
|||
currentDistance+=dt*frequency;
|
||||
|
||||
|
||||
//float distFromCamp =(core->cameraPos - position).getLength2D();//v3dDist(nCameraPointer->pos, position);
|
||||
//if (distFromCamp < 4)
|
||||
|
||||
float distFromCamp = 4;
|
||||
|
||||
float adjWaveLength = waveLength/distFromCamp;
|
||||
|
@ -504,33 +472,21 @@ void ShockEffect::update(float dt, Vector ** drawGrid, int xDivs, int yDivs)
|
|||
{
|
||||
for (int j = 1; j < (yDivs-1); j++)
|
||||
{
|
||||
/*
|
||||
Vector p = getNearestPointOnLine(centerPoint, centerPoint + Vector(-200, -200), Vector(drawGrid[i][j].x*core->width, drawGrid[i][j].y*core->height));
|
||||
|
||||
p.x /= core->width;
|
||||
p.y /= core->height;
|
||||
*/
|
||||
|
||||
|
||||
|
||||
xDist = (centerPoint.x - drawGrid[i][j].x)/.75;
|
||||
yDist = centerPoint.y - drawGrid[i][j].y;
|
||||
|
||||
/*
|
||||
xDist = (p.x - drawGrid[i][j].x)/.75;
|
||||
yDist = p.y - drawGrid[i][j].y;
|
||||
*/
|
||||
|
||||
//xDist = 1;
|
||||
//yDist = 2;
|
||||
|
||||
|
||||
tDist = sqrtf(xDist*xDist+yDist*yDist);
|
||||
|
||||
//drawGrid[i][j].x += (rand()%100)/10000.0f;
|
||||
//drawGrid[i][j].y += (rand()%100)/10000.0f;
|
||||
|
||||
|
||||
if (tDist < currentDistance*adjWaveLength)
|
||||
{
|
||||
//drawGrid[i][j].x += rand()%50;
|
||||
//drawGrid[i][j].y += rand()%50;
|
||||
|
||||
|
||||
drawGrid[i][j].x += adjAmplitude*sinf(-tDist/adjWaveLength+currentDistance)*.75f;
|
||||
drawGrid[i][j].y += adjAmplitude*cosf(-tDist/adjWaveLength+currentDistance);
|
||||
}
|
||||
|
@ -546,20 +502,9 @@ RippleEffect::RippleEffect() : Effect()
|
|||
|
||||
void RippleEffect::update(float dt, Vector ** drawGrid, int xDivs, int yDivs)
|
||||
{
|
||||
/*
|
||||
// whole screen roll
|
||||
time += dt;
|
||||
float amp = 0.01;
|
||||
for (int i = 0; i < (xDivs-1); i++)
|
||||
{
|
||||
for (int j = 0; j < (yDivs-1); j++)
|
||||
{
|
||||
float offset = +i/float(xDivs) +j/float(xDivs);
|
||||
//drawGrid[i][j].x += sinf(time+offset)*amp;
|
||||
drawGrid[i][j].y += cosf((time+offset)*2.5f)*amp;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
time += dt*0.5f;
|
||||
float amp = 0.002;
|
||||
for (int i = 0; i < (xDivs-1); i++)
|
||||
|
@ -567,7 +512,7 @@ void RippleEffect::update(float dt, Vector ** drawGrid, int xDivs, int yDivs)
|
|||
for (int j = 0; j < (yDivs-1); j++)
|
||||
{
|
||||
float offset = i/float(xDivs) + (core->screenCenter.x/float(core->width)/2) +j/float(xDivs) + (core->screenCenter.y/float(core->height)/2);
|
||||
//drawGrid[i][j].x += sinf(time+offset)*amp;
|
||||
|
||||
drawGrid[i][j].x += sinf((time+offset)*7.5f)*(amp*0.5f);
|
||||
drawGrid[i][j].y += cosf((time+offset)*7.5f)*amp;
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ class Effect
|
|||
{
|
||||
public:
|
||||
Effect();
|
||||
virtual ~Effect(){};
|
||||
virtual void go(){}
|
||||
virtual void update(float dt, Vector ** drawGrid, int xDivs, int yDivs){}
|
||||
bool done;
|
||||
|
@ -51,7 +52,7 @@ public:
|
|||
this->timeMultiplier = timeMultiplier;
|
||||
}
|
||||
float timeMultiplier;
|
||||
//void go();
|
||||
|
||||
void update(float dt, Vector ** drawGrid, int xDivs, int yDivs);
|
||||
|
||||
float waveLength;
|
||||
|
|
|
@ -1,79 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "AnimatedSprite.h"
|
||||
|
||||
AnimData::AnimData()
|
||||
{
|
||||
frameStart = frameEnd = 0;
|
||||
time = 0;
|
||||
loop = 0;
|
||||
pingPong = false;
|
||||
datafile = 0;
|
||||
}
|
||||
|
||||
AnimatedSprite::AnimatedSprite() : Quad()
|
||||
{
|
||||
//debugLog("AnimatedSprite::AnimatedSprite()");
|
||||
frame = 0;
|
||||
animator.setUpdatee(&frame);
|
||||
animationTime.setUpdatee (&animator.timePeriod);
|
||||
//debugLog("End AnimatedSprite::AnimatedSprite()");
|
||||
}
|
||||
|
||||
void AnimatedSprite::animate (AnimData &animData)
|
||||
{
|
||||
onAnimData(animData);
|
||||
animate (animData.name, animData.frameStart, animData.frameEnd, animData.time, animData.loop, animData.pingPong);
|
||||
}
|
||||
|
||||
void AnimatedSprite::onAnimData(AnimData &animData)
|
||||
{
|
||||
}
|
||||
|
||||
void AnimatedSprite::animate (const std::string &name, int from, int to, float time, int loopType, bool pingPong, float initialDelay)
|
||||
{
|
||||
if (from == to && to == 0)
|
||||
{
|
||||
debugLog ("null animation");
|
||||
animator.stop();
|
||||
return;
|
||||
}
|
||||
currentAnim = name;
|
||||
frame = from;
|
||||
animator.interpolateTo (to, time, loopType);
|
||||
animator.pingPong = pingPong;
|
||||
animator.initialDelay = initialDelay;
|
||||
}
|
||||
|
||||
void AnimatedSprite::onUpdate (float dt)
|
||||
{
|
||||
Quad::onUpdate (dt);
|
||||
animator.update (dt);
|
||||
animationTime.update (dt);
|
||||
if (!animator.interpolating && currentAnim != "")
|
||||
{
|
||||
animComplete(currentAnim);
|
||||
lastAnim = currentAnim;
|
||||
currentAnim = "";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef __animated_sprite__
|
||||
#define __animated_sprite__
|
||||
|
||||
#include "Quad.h"
|
||||
#include "Interpolator.h"
|
||||
|
||||
class AnimData
|
||||
{
|
||||
public:
|
||||
AnimData();
|
||||
std::string name;
|
||||
int frameStart, frameEnd, datafile;
|
||||
float time;
|
||||
int loop;
|
||||
bool pingPong;
|
||||
};
|
||||
|
||||
|
||||
class AnimatedSprite : public Quad
|
||||
{
|
||||
public:
|
||||
AnimatedSprite();
|
||||
|
||||
Interpolator animator, animationTime;
|
||||
float frame;
|
||||
std::string currentAnim, lastAnim;
|
||||
|
||||
virtual void animComplete(std::string name) {}
|
||||
|
||||
void animate (const std::string &name, int from, int to, float time, int loopType, bool pingPong = false, float initialDelay = 0.0f);
|
||||
void animate (AnimData &animData);
|
||||
|
||||
bool isAnimating()
|
||||
{
|
||||
return animator.interpolating;
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
virtual void onAnimData(AnimData &animData);
|
||||
virtual void onUpdate (float dt);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
563
BBGE/Base.cpp
563
BBGE/Base.cpp
|
@ -47,7 +47,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
|
||||
|
@ -68,6 +68,13 @@ Vector getDirVector(Direction dir)
|
|||
case DIR_RIGHT:
|
||||
return Vector(1, 0);
|
||||
break;
|
||||
case DIR_UPLEFT:
|
||||
case DIR_UPRIGHT:
|
||||
case DIR_DOWNLEFT:
|
||||
case DIR_DOWNRIGHT:
|
||||
case DIR_MAX:
|
||||
case DIR_NONE:
|
||||
break;
|
||||
}
|
||||
return Vector(0,0);
|
||||
}
|
||||
|
@ -88,6 +95,13 @@ Direction getOppositeDir(Direction dir)
|
|||
case DIR_RIGHT:
|
||||
return DIR_LEFT;
|
||||
break;
|
||||
case DIR_UPLEFT:
|
||||
case DIR_UPRIGHT:
|
||||
case DIR_DOWNLEFT:
|
||||
case DIR_DOWNRIGHT:
|
||||
case DIR_MAX:
|
||||
case DIR_NONE:
|
||||
break;
|
||||
}
|
||||
|
||||
return DIR_NONE;
|
||||
|
@ -109,6 +123,13 @@ Direction getNextDirClockwise(Direction dir)
|
|||
case DIR_RIGHT:
|
||||
return DIR_DOWN;
|
||||
break;
|
||||
case DIR_UPLEFT:
|
||||
case DIR_UPRIGHT:
|
||||
case DIR_DOWNLEFT:
|
||||
case DIR_DOWNRIGHT:
|
||||
case DIR_MAX:
|
||||
case DIR_NONE:
|
||||
break;
|
||||
}
|
||||
return DIR_NONE;
|
||||
}
|
||||
|
@ -153,15 +174,14 @@ 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;
|
||||
}
|
||||
|
||||
/* hash * 33 + c */
|
||||
|
||||
|
||||
static unsigned char lowerToUpperTable[256];
|
||||
|
@ -198,11 +218,6 @@ struct TransatableStaticInit
|
|||
static TransatableStaticInit _transtable_static_init;
|
||||
|
||||
static unsigned char charIsUpper(unsigned char c)
|
||||
{
|
||||
return c == upperToLowerTable[c];
|
||||
}
|
||||
|
||||
static unsigned char charIsLower(unsigned char c)
|
||||
{
|
||||
return c == lowerToUpperTable[c];
|
||||
}
|
||||
|
@ -284,8 +299,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
|
||||
|
@ -305,18 +320,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
|
||||
|
||||
|
@ -352,8 +367,7 @@ bool exists(const std::string &f, bool makeFatal, bool skipVFS)
|
|||
|
||||
void drawCircle(float radius, int stepSize)
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
//glDisable(GL_CULL_FACE);
|
||||
|
||||
|
||||
glBegin(GL_POLYGON);
|
||||
{
|
||||
|
@ -364,8 +378,7 @@ void drawCircle(float radius, int stepSize)
|
|||
}
|
||||
glEnd();
|
||||
|
||||
//glEnable(GL_CULL_FACE);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void exit_error(const std::string &message)
|
||||
|
@ -386,9 +399,7 @@ std::string parseCommand(const std::string &line, const std::string &command)
|
|||
|
||||
void glColor3_256(int r, int g, int b)
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
glColor4f(float(r)/256.0f, float(g)/256.0f, float(b)/256.0f, 1.0f);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool chance(int perc)
|
||||
|
@ -405,68 +416,7 @@ bool chancef(float p)
|
|||
return ((rand()%100) <= p*100);
|
||||
}
|
||||
|
||||
/*
|
||||
PHYSFS_file *openRead(const std::string &f)
|
||||
{
|
||||
|
||||
PHYSFS_file *file = PHYSFS_openRead(f.c_str());
|
||||
if (!file)
|
||||
{
|
||||
errorLog ("Could not open [" + f + "]");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
|
||||
void pfread(void *buffer, PHYSFS_uint32 size, PHYSFS_uint32 objs, PHYSFS_file *handle)
|
||||
{
|
||||
PHYSFS_read(handle, buffer, size, objs);
|
||||
}
|
||||
|
||||
void pfseek(PHYSFS_file *handle,PHYSFS_uint64 byte,int origin)
|
||||
{
|
||||
if (origin == SEEK_CUR)
|
||||
{
|
||||
byte += PHYSFS_tell(handle);
|
||||
}
|
||||
PHYSFS_seek(handle,byte);
|
||||
}
|
||||
|
||||
void pfclose(PHYSFS_file *handle)
|
||||
{
|
||||
PHYSFS_close(handle);
|
||||
}
|
||||
|
||||
std::string pLoadStream(const std::string &filename)
|
||||
{
|
||||
PHYSFS_file *f = openRead(filename.c_str());
|
||||
int len = PHYSFS_fileLength(f);
|
||||
std::string s;
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
char p;
|
||||
PHYSFS_read(f, &p, sizeof(char), 1);
|
||||
s += p;
|
||||
}
|
||||
//std::istringstream is(s);
|
||||
|
||||
PHYSFS_close(f);
|
||||
return s;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void pSaveStream(const std::string &filename, std::ostringstream &os)
|
||||
{
|
||||
PHYSFS_file *f = PHYSFS_openWrite(filename.c_str());
|
||||
//int size = os.str().size();
|
||||
//PHYSFS_write(f, (void*)size, sizeof(int), 1);
|
||||
PHYSFS_write(f, (void*)os.str().c_str(), sizeof(char)*os.str().size(), 1);
|
||||
PHYSFS_close(f);
|
||||
}
|
||||
*/
|
||||
|
||||
void errorLog(const std::string &s)
|
||||
{
|
||||
|
@ -562,29 +512,7 @@ tinyxml2::XMLDocument *readXML(const std::string& fn, tinyxml2::XMLError *perr /
|
|||
return doc;
|
||||
}
|
||||
|
||||
/*
|
||||
void pForEachFile(std::string path, std::string type, void callback(const std::string &filename, int param), int param)
|
||||
{
|
||||
char **rc = PHYSFS_enumerateFiles(path.c_str());
|
||||
char **i;
|
||||
|
||||
for (i = rc; *i != NULL; i++)
|
||||
{
|
||||
std::string s(*i);
|
||||
int p=0;
|
||||
if ((p=s.find('.'))!=std::string::npos)
|
||||
{
|
||||
std::string ext = s.susbtr(p, s.getLength2D());
|
||||
if (ext == type)
|
||||
{
|
||||
callback(fielnameafhghaha
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PHYSFS_freeList(rc);
|
||||
}
|
||||
*/
|
||||
|
||||
void doSingleFile(const std::string &path, const std::string &type, std::string filename, void callback(const std::string &filename, int param), int param)
|
||||
{
|
||||
|
@ -593,9 +521,9 @@ void doSingleFile(const std::string &path, const std::string &type, std::string
|
|||
std::string search = filename;
|
||||
stringToLower(search);
|
||||
std::string filetype = filename.substr(search.size()-4, search.size());
|
||||
//stringToUpper(filetype);
|
||||
//debugLog("comparing: " + filetype + " and: " + type);
|
||||
//if (filetype==type)
|
||||
|
||||
|
||||
|
||||
debugLog("checking:" + search + " for type:" + type);
|
||||
if (search.find(type)!=std::string::npos)
|
||||
{
|
||||
|
@ -626,22 +554,22 @@ std::string stripEndlineForUnix(const std::string &in)
|
|||
|
||||
struct vfscallback_s
|
||||
{
|
||||
std::string *path;
|
||||
const char *ext;
|
||||
intptr_t param;
|
||||
void (*callback)(const std::string &filename, intptr_t param);
|
||||
std::string *path;
|
||||
const char *ext;
|
||||
intptr_t param;
|
||||
void (*callback)(const std::string &filename, intptr_t param);
|
||||
};
|
||||
|
||||
void forEachFile_vfscallback(VFILE *vf, void *user)
|
||||
{
|
||||
vfscallback_s *d = (vfscallback_s*)user;
|
||||
if(d->ext)
|
||||
{
|
||||
const char *e = strrchr(vf->name(), '.');
|
||||
if(e && nocasecmp(d->ext, e))
|
||||
return;
|
||||
}
|
||||
d->callback(*(d->path) + vf->name(), d->param);
|
||||
vfscallback_s *d = (vfscallback_s*)user;
|
||||
if(d->ext)
|
||||
{
|
||||
const char *e = strrchr(vf->name(), '.');
|
||||
if(e && nocasecmp(d->ext, e))
|
||||
return;
|
||||
}
|
||||
d->callback(*(d->path) + vf->name(), d->param);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -677,45 +605,45 @@ void forEachFile(std::string path, std::string type, void callback(const std::st
|
|||
dir = opendir(path.c_str());
|
||||
if (dir)
|
||||
{
|
||||
dirent *file=0;
|
||||
dirent *file=0;
|
||||
while ( (file=readdir(dir)) != NULL )
|
||||
{
|
||||
if (file->d_name && strlen(file->d_name) > 4)
|
||||
{
|
||||
debugLog(file->d_name);
|
||||
char *extension=strrchr(file->d_name,'.');
|
||||
if (extension)
|
||||
{
|
||||
debugLog(extension);
|
||||
if (extension!=NULL)
|
||||
{
|
||||
if (strcasecmp(extension,type.c_str())==0)
|
||||
{
|
||||
callback(path + std::string(file->d_name), param);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (strlen(file->d_name) > 4)
|
||||
{
|
||||
debugLog(file->d_name);
|
||||
char *extension=strrchr(file->d_name,'.');
|
||||
if (extension)
|
||||
{
|
||||
debugLog(extension);
|
||||
if (extension!=NULL)
|
||||
{
|
||||
if (strcasecmp(extension,type.c_str())==0)
|
||||
{
|
||||
callback(path + std::string(file->d_name), param);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir(dir);
|
||||
}
|
||||
else
|
||||
{
|
||||
debugLog("FAILED TO OPEN DIR");
|
||||
debugLog("FAILED TO OPEN DIR");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef BBGE_BUILD_WINDOWS
|
||||
BOOL fFinished;
|
||||
HANDLE hList;
|
||||
TCHAR szDir[MAX_PATH+1];
|
||||
WIN32_FIND_DATA FileData;
|
||||
BOOL fFinished;
|
||||
HANDLE hList;
|
||||
TCHAR szDir[MAX_PATH+1];
|
||||
WIN32_FIND_DATA FileData;
|
||||
|
||||
int end = path.size()-1;
|
||||
if (path[end] != '/')
|
||||
path[end] += '/';
|
||||
|
||||
// Get the proper directory path
|
||||
// Get the proper directory path
|
||||
// \\ %s\\*
|
||||
|
||||
|
||||
|
@ -726,36 +654,34 @@ void forEachFile(std::string path, std::string type, void callback(const std::st
|
|||
}
|
||||
|
||||
|
||||
//std::string add = "%s*" + type;
|
||||
|
||||
//sprintf(szDir, "%s*", path.c_str());
|
||||
sprintf(szDir, "%s\\*", path.c_str());
|
||||
|
||||
stringToUpper(type);
|
||||
|
||||
// Get the first file
|
||||
hList = FindFirstFile(szDir, &FileData);
|
||||
if (hList == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
//printf("No files found\n\n");
|
||||
// Get the first file
|
||||
hList = FindFirstFile(szDir, &FileData);
|
||||
if (hList == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
|
||||
debugLog("No files of type " + type + " found in path " + path);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Traverse through the directory structure
|
||||
fFinished = FALSE;
|
||||
while (!fFinished)
|
||||
{
|
||||
// Check the object is a directory or not
|
||||
//printf("%*s%s\n", indent, "", FileData.cFileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Traverse through the directory structure
|
||||
fFinished = FALSE;
|
||||
while (!fFinished)
|
||||
{
|
||||
// Check the object is a directory or not
|
||||
//printf("%*s%s\n", indent, "", FileData.cFileName);
|
||||
std::string filename = FileData.cFileName;
|
||||
//debugLog("found: " + filename);
|
||||
|
||||
if (filename.size()>4)
|
||||
{
|
||||
|
||||
std::string filetype = filename.substr(filename.size()-4, filename.size());
|
||||
stringToUpper(filetype);
|
||||
//debugLog("comparing: " + filetype + " and: " + type);
|
||||
|
||||
if (filetype==type)
|
||||
{
|
||||
callback(path+filename, param);
|
||||
|
@ -763,20 +689,15 @@ void forEachFile(std::string path, std::string type, void callback(const std::st
|
|||
}
|
||||
|
||||
|
||||
if (!FindNextFile(hList, &FileData))
|
||||
{
|
||||
/*
|
||||
if (GetLastError() == ERROR_NO_MORE_FILES)
|
||||
{
|
||||
fFinished = TRUE;
|
||||
}
|
||||
*/
|
||||
fFinished = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!FindNextFile(hList, &FileData))
|
||||
{
|
||||
|
||||
FindClose(hList);
|
||||
fFinished = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FindClose(hList);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -785,51 +706,46 @@ std::vector<std::string> getFileList(std::string path, std::string type, int par
|
|||
std::vector<std::string> list;
|
||||
|
||||
#ifdef BBGE_BUILD_WINDOWS
|
||||
BOOL fFinished;
|
||||
HANDLE hList;
|
||||
TCHAR szDir[MAX_PATH+1];
|
||||
WIN32_FIND_DATA FileData;
|
||||
BOOL fFinished;
|
||||
HANDLE hList;
|
||||
TCHAR szDir[MAX_PATH+1];
|
||||
WIN32_FIND_DATA FileData;
|
||||
|
||||
// Get the proper directory path
|
||||
sprintf(szDir, "%s\\*", path.c_str());
|
||||
// Get the proper directory path
|
||||
sprintf(szDir, "%s\\*", path.c_str());
|
||||
|
||||
|
||||
// Get the first file
|
||||
hList = FindFirstFile(szDir, &FileData);
|
||||
if (hList == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
printf("No files found\n\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Traverse through the directory structure
|
||||
fFinished = FALSE;
|
||||
while (!fFinished)
|
||||
{
|
||||
// Check the object is a directory or not
|
||||
//printf("%*s%s\n", indent, "", FileData.cFileName);
|
||||
// Get the first file
|
||||
hList = FindFirstFile(szDir, &FileData);
|
||||
if (hList == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
printf("No files found\n\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Traverse through the directory structure
|
||||
fFinished = FALSE;
|
||||
while (!fFinished)
|
||||
{
|
||||
// Check the object is a directory or not
|
||||
//printf("%*s%s\n", indent, "", FileData.cFileName);
|
||||
std::string filename = FileData.cFileName;
|
||||
if (filename.size()>4 && filename.substr(filename.size()-4, filename.size())==type)
|
||||
{
|
||||
//callback(path+filename, param);
|
||||
|
||||
list.push_back (filename);
|
||||
}
|
||||
|
||||
|
||||
if (!FindNextFile(hList, &FileData))
|
||||
{
|
||||
/*
|
||||
if (GetLastError() == ERROR_NO_MORE_FILES)
|
||||
{
|
||||
fFinished = TRUE;
|
||||
}
|
||||
*/
|
||||
fFinished = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!FindNextFile(hList, &FileData))
|
||||
{
|
||||
|
||||
FindClose(hList);
|
||||
fFinished = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FindClose(hList);
|
||||
#endif
|
||||
|
||||
return list;
|
||||
|
@ -842,7 +758,7 @@ void cocoaMessageBox(const std::string &title, const std::string &msg);
|
|||
void messageBox(const std::string& title, const std::string &msg)
|
||||
{
|
||||
#ifdef BBGE_BUILD_WINDOWS
|
||||
MessageBox (0,msg.c_str(),title.c_str(),MB_OK);
|
||||
MessageBox (0,msg.c_str(),title.c_str(),MB_OK);
|
||||
#elif SDL_VERSION_ATLEAST(2,0,0)
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, title.c_str(),
|
||||
msg.c_str(), NULL);
|
||||
|
@ -884,39 +800,28 @@ Vector getNearestPointOnLine(Vector a, Vector b, Vector c)
|
|||
return nearest;
|
||||
}
|
||||
|
||||
/*
|
||||
bool isTouchingLine(Vector lineStart, Vector lineEnd, Vector point, int radius)
|
||||
{
|
||||
Vector p = getNearestPointOnLine(lineStart, lineEnd, point);
|
||||
Vector diff = p - point;
|
||||
std::ostringstream os;
|
||||
os << "s(" << lineStart.x << ", " << lineStart.y << ") e(";
|
||||
os << lineEnd.x << ", " << lineEnd.y << ") - p(" << point.x << ", " << point.y << ")";
|
||||
debugLog(os.str());
|
||||
return (diff.getSquaredLength2D() < sqr(radius));
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -931,14 +836,12 @@ GLuint generateEmptyTexture(int quality) // Create An Empty Texture
|
|||
|
||||
memset(data, 0, size); // Clear Storage Memory
|
||||
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
glGenTextures(1, &txtnumber); // Create 1 Texture
|
||||
glBindTexture(GL_TEXTURE_2D, txtnumber); // Bind The Texture
|
||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, quality, quality, 0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, data); // Build Texture Using Information In data
|
||||
#endif
|
||||
|
||||
delete [] data; // Release data
|
||||
|
||||
|
@ -997,56 +900,56 @@ int packFile(const std::string &sourcef, const std::string &destf, int level)
|
|||
if (!source || !dest)
|
||||
return 0;
|
||||
|
||||
int ret, flush;
|
||||
unsigned have;
|
||||
z_stream strm;
|
||||
unsigned char in[CHUNK];
|
||||
unsigned char out[CHUNK];
|
||||
int ret, flush;
|
||||
unsigned have;
|
||||
z_stream strm;
|
||||
unsigned char in[CHUNK];
|
||||
unsigned char out[CHUNK];
|
||||
|
||||
/* allocate deflate state */
|
||||
strm.zalloc = Z_NULL;
|
||||
strm.zfree = Z_NULL;
|
||||
strm.opaque = Z_NULL;
|
||||
ret = deflateInit(&strm, level);
|
||||
if (ret != Z_OK)
|
||||
return ret;
|
||||
/* allocate deflate state */
|
||||
strm.zalloc = Z_NULL;
|
||||
strm.zfree = Z_NULL;
|
||||
strm.opaque = Z_NULL;
|
||||
ret = deflateInit(&strm, level);
|
||||
if (ret != Z_OK)
|
||||
return ret;
|
||||
|
||||
/* compress until end of file */
|
||||
do {
|
||||
strm.avail_in = fread(in, 1, CHUNK, source);
|
||||
if (ferror(source)) {
|
||||
(void)deflateEnd(&strm);
|
||||
return Z_ERRNO;
|
||||
}
|
||||
flush = feof(source) ? Z_FINISH : Z_NO_FLUSH;
|
||||
strm.next_in = in;
|
||||
/* compress until end of file */
|
||||
do {
|
||||
strm.avail_in = fread(in, 1, CHUNK, source);
|
||||
if (ferror(source)) {
|
||||
(void)deflateEnd(&strm);
|
||||
return Z_ERRNO;
|
||||
}
|
||||
flush = feof(source) ? Z_FINISH : Z_NO_FLUSH;
|
||||
strm.next_in = in;
|
||||
|
||||
/* run deflate() on input until output buffer not full, finish
|
||||
compression if all of source has been read in */
|
||||
do {
|
||||
strm.avail_out = CHUNK;
|
||||
strm.next_out = out;
|
||||
ret = deflate(&strm, flush); /* no bad return value */
|
||||
assert(ret != Z_STREAM_ERROR); /* state not clobbered */
|
||||
have = CHUNK - strm.avail_out;
|
||||
if (fwrite(out, 1, have, dest) != have || ferror(dest)) {
|
||||
(void)deflateEnd(&strm);
|
||||
return Z_ERRNO;
|
||||
}
|
||||
} while (strm.avail_out == 0);
|
||||
assert(strm.avail_in == 0); /* all input will be used */
|
||||
/* run deflate() on input until output buffer not full, finish
|
||||
compression if all of source has been read in */
|
||||
do {
|
||||
strm.avail_out = CHUNK;
|
||||
strm.next_out = out;
|
||||
ret = deflate(&strm, flush); /* no bad return value */
|
||||
assert(ret != Z_STREAM_ERROR); /* state not clobbered */
|
||||
have = CHUNK - strm.avail_out;
|
||||
if (fwrite(out, 1, have, dest) != have || ferror(dest)) {
|
||||
(void)deflateEnd(&strm);
|
||||
return Z_ERRNO;
|
||||
}
|
||||
} while (strm.avail_out == 0);
|
||||
assert(strm.avail_in == 0); /* all input will be used */
|
||||
|
||||
/* done when last data in file processed */
|
||||
} while (flush != Z_FINISH);
|
||||
assert(ret == Z_STREAM_END); /* stream will be complete */
|
||||
/* done when last data in file processed */
|
||||
} while (flush != Z_FINISH);
|
||||
assert(ret == Z_STREAM_END); /* stream will be complete */
|
||||
|
||||
/* clean up and return */
|
||||
(void)deflateEnd(&strm);
|
||||
/* clean up and return */
|
||||
(void)deflateEnd(&strm);
|
||||
|
||||
fclose(source);
|
||||
fclose(dest);
|
||||
|
||||
return Z_OK;
|
||||
return Z_OK;
|
||||
}
|
||||
|
||||
/* Decompress from file source to file dest until stream ends or EOF.
|
||||
|
@ -1063,64 +966,64 @@ int unpackFile(const std::string &sourcef, const std::string &destf)
|
|||
if (!source || !dest)
|
||||
return 0;
|
||||
|
||||
int ret;
|
||||
unsigned have;
|
||||
z_stream strm;
|
||||
unsigned char in[CHUNK];
|
||||
unsigned char out[CHUNK];
|
||||
int ret;
|
||||
unsigned have;
|
||||
z_stream strm;
|
||||
unsigned char in[CHUNK];
|
||||
unsigned char out[CHUNK];
|
||||
|
||||
/* allocate inflate state */
|
||||
strm.zalloc = Z_NULL;
|
||||
strm.zfree = Z_NULL;
|
||||
strm.opaque = Z_NULL;
|
||||
strm.avail_in = 0;
|
||||
strm.next_in = Z_NULL;
|
||||
ret = inflateInit(&strm);
|
||||
if (ret != Z_OK)
|
||||
return ret;
|
||||
/* allocate inflate state */
|
||||
strm.zalloc = Z_NULL;
|
||||
strm.zfree = Z_NULL;
|
||||
strm.opaque = Z_NULL;
|
||||
strm.avail_in = 0;
|
||||
strm.next_in = Z_NULL;
|
||||
ret = inflateInit(&strm);
|
||||
if (ret != Z_OK)
|
||||
return ret;
|
||||
|
||||
/* decompress until deflate stream ends or end of file */
|
||||
do {
|
||||
strm.avail_in = fread(in, 1, CHUNK, source);
|
||||
if (ferror(source)) {
|
||||
(void)inflateEnd(&strm);
|
||||
return Z_ERRNO;
|
||||
}
|
||||
if (strm.avail_in == 0)
|
||||
break;
|
||||
strm.next_in = in;
|
||||
/* decompress until deflate stream ends or end of file */
|
||||
do {
|
||||
strm.avail_in = fread(in, 1, CHUNK, source);
|
||||
if (ferror(source)) {
|
||||
(void)inflateEnd(&strm);
|
||||
return Z_ERRNO;
|
||||
}
|
||||
if (strm.avail_in == 0)
|
||||
break;
|
||||
strm.next_in = in;
|
||||
|
||||
/* run inflate() on input until output buffer not full */
|
||||
do {
|
||||
strm.avail_out = CHUNK;
|
||||
strm.next_out = out;
|
||||
ret = inflate(&strm, Z_NO_FLUSH);
|
||||
assert(ret != Z_STREAM_ERROR); /* state not clobbered */
|
||||
switch (ret) {
|
||||
case Z_NEED_DICT:
|
||||
ret = Z_DATA_ERROR; /* and fall through */
|
||||
case Z_DATA_ERROR:
|
||||
case Z_MEM_ERROR:
|
||||
(void)inflateEnd(&strm);
|
||||
return ret;
|
||||
}
|
||||
have = CHUNK - strm.avail_out;
|
||||
if (fwrite(out, 1, have, dest) != have || ferror(dest)) {
|
||||
(void)inflateEnd(&strm);
|
||||
return Z_ERRNO;
|
||||
}
|
||||
} while (strm.avail_out == 0);
|
||||
/* run inflate() on input until output buffer not full */
|
||||
do {
|
||||
strm.avail_out = CHUNK;
|
||||
strm.next_out = out;
|
||||
ret = inflate(&strm, Z_NO_FLUSH);
|
||||
assert(ret != Z_STREAM_ERROR); /* state not clobbered */
|
||||
switch (ret) {
|
||||
case Z_NEED_DICT:
|
||||
ret = Z_DATA_ERROR; /* and fall through */
|
||||
case Z_DATA_ERROR:
|
||||
case Z_MEM_ERROR:
|
||||
(void)inflateEnd(&strm);
|
||||
return ret;
|
||||
}
|
||||
have = CHUNK - strm.avail_out;
|
||||
if (fwrite(out, 1, have, dest) != have || ferror(dest)) {
|
||||
(void)inflateEnd(&strm);
|
||||
return Z_ERRNO;
|
||||
}
|
||||
} while (strm.avail_out == 0);
|
||||
|
||||
/* done when inflate() says it's done */
|
||||
} while (ret != Z_STREAM_END);
|
||||
/* done when inflate() says it's done */
|
||||
} while (ret != Z_STREAM_END);
|
||||
|
||||
/* clean up and return */
|
||||
(void)inflateEnd(&strm);
|
||||
/* clean up and return */
|
||||
(void)inflateEnd(&strm);
|
||||
|
||||
fclose(source);
|
||||
fclose(dest);
|
||||
|
||||
return ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR;
|
||||
return ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
73
BBGE/Base.h
73
BBGE/Base.h
|
@ -29,77 +29,35 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#undef min
|
||||
#undef max
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define strtof (float)strtod
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
#ifdef _MSC_VER
|
||||
#define strtof (float)strtod
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "BBGECompileConfig.h"
|
||||
|
||||
#ifdef BBGE_BUILD_WINDOWS
|
||||
|
||||
//#include "iprof/prof.h"
|
||||
//#define BBGE_PROF(x) Prof(x)
|
||||
|
||||
|
||||
#define BBGE_PROF(x)
|
||||
|
||||
/*
|
||||
//#ifdef BBGE_BUILD_DIRECTX
|
||||
#define DIRECTINPUT_VERSION 0x0800
|
||||
#include <dinput.h>
|
||||
//#endif
|
||||
*/
|
||||
|
||||
|
||||
#else
|
||||
#define BBGE_PROF(x)
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef BBGE_BUILD_GLFW
|
||||
#include <glfw.h>
|
||||
#include "glext.h"
|
||||
//#include "glext.h"
|
||||
#elif BBGE_BUILD_DIRECTX
|
||||
|
||||
#if defined(BBGE_BUILD_X360) && !defined(BBGE_BUILD_WINDOWS)
|
||||
|
||||
#include <xtl.h>
|
||||
#include <ppcintrinsics.h>
|
||||
|
||||
#endif // _XBOX
|
||||
|
||||
#if defined(BBGE_BUILD_X360) && defined(BBGE_BUILD_WINDOWS)
|
||||
// Using the win32\ path prefix on the D3D include files makes sure that the Xbox 360
|
||||
// version of D3D is used, not the DirectX SDK version.
|
||||
#include <win32\vs2005\d3d9.h>
|
||||
#include <win32\vs2005\d3dx9.h>
|
||||
#pragma warning(disable:4100)
|
||||
|
||||
#include "XTLOnPC.h"
|
||||
|
||||
#endif // _PC
|
||||
|
||||
#if defined(BBGE_BUILD_X360)
|
||||
#include <xgraphics.h>
|
||||
#include <xboxmath.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <assert.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef BBGE_BUILD_SDL
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(BBGE_BUILD_OPENGL)
|
||||
#define GL_GLEXT_LEGACY 1
|
||||
#include "gl.h"
|
||||
#include "glext.h"
|
||||
#endif
|
||||
|
||||
#define compile_assert(pred) switch(0){case 0:case (pred):;}
|
||||
|
||||
|
@ -136,7 +94,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include <queue>
|
||||
#include <map>
|
||||
#include <stack>
|
||||
//#include <typeinfo.h>
|
||||
|
||||
|
||||
#include "Rect.h"
|
||||
|
||||
|
@ -233,23 +191,9 @@ Direction getOppositeDir(Direction dir);
|
|||
Direction getNextDirClockwise(Direction dir);
|
||||
Vector colorRGB(int r, int g, int b);
|
||||
|
||||
#ifdef BBGE_BUILD_DIRECTX
|
||||
typedef unsigned int GLuint;
|
||||
#endif
|
||||
GLuint generateEmptyTexture(int res);
|
||||
|
||||
//void pForEachFile(std::string path, std::string type, void callback(const std::string &filename, int param), int param);
|
||||
|
||||
/*
|
||||
void pfread(void *buffer, PHYSFS_uint32 size, PHYSFS_uint32 objs, PHYSFS_file *handle);
|
||||
void pfseek(PHYSFS_file *handle,PHYSFS_uint64 byte,int origin);
|
||||
void pfclose(PHYSFS_file *handle);
|
||||
|
||||
|
||||
PHYSFS_file *openRead(const std::string &f);
|
||||
std::string pLoadStream(const std::string &filename);
|
||||
void pSaveStream(const std::string &filename, std::ostringstream &os);
|
||||
*/
|
||||
|
||||
void drawCircle(float radius, int steps=1);
|
||||
bool isVectorInRect(const Vector &vec, const Vector &coord1, const Vector &coord2);
|
||||
|
@ -287,8 +231,7 @@ enum LerpType
|
|||
|
||||
float lerp(const float &v1, const float &v2, float dt, int lerpType);
|
||||
|
||||
//int packFile(const std::string &sourcef, const std::string &destf, int level);
|
||||
//int unpackFile(const std::string &sourcef, const std::string &destf);
|
||||
|
||||
|
||||
void openURL(const std::string &url);
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
#include "BitmapFont.h"
|
||||
#include "Core.h"
|
||||
//#include "DSQ.h"
|
||||
|
||||
|
||||
using namespace glfont;
|
||||
|
||||
|
@ -56,14 +56,12 @@ void BmpFont::load(const std::string &file, float scale, bool loadTexture)
|
|||
|
||||
this->scale = scale;
|
||||
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
GLuint id=0;
|
||||
glGenTextures(1, &id);
|
||||
|
||||
if (!font.Create(file.c_str(), id, loadTexture))
|
||||
return;
|
||||
|
||||
#endif
|
||||
|
||||
loaded = true;
|
||||
}
|
||||
|
@ -81,13 +79,13 @@ BitmapText::BitmapText(BmpFont *bmpFont)
|
|||
align = ALIGN_CENTER;
|
||||
textWidth = 600;
|
||||
this->fontDrawSize = 24;
|
||||
//color = Vector(0.5,0.5,1);
|
||||
|
||||
cull = false;
|
||||
//setTexture(font);
|
||||
|
||||
|
||||
alignWidth = 0;
|
||||
|
||||
//fontTextureTest = core->addTexture("font");
|
||||
|
||||
}
|
||||
|
||||
void BitmapText::autoKern()
|
||||
|
@ -164,8 +162,8 @@ void BitmapText::formatText()
|
|||
alignWidth = 0;
|
||||
maxW = 0;
|
||||
for (int i = 0; i < text.size(); i++)
|
||||
{
|
||||
//currentWidth += spacingMap[text[i]]*fontDrawSize;
|
||||
{
|
||||
|
||||
float sz = bmpFont->font.GetCharWidth(text[i])*bmpFont->scale;
|
||||
currentWidth += sz;
|
||||
|
||||
|
@ -218,24 +216,7 @@ void BitmapText::updateWordColoring()
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
for (int i = 0; i < lines.size(); i++)
|
||||
{
|
||||
int c = 0;
|
||||
for (int t = 0; t < dsq->continuity.wordColoring.size(); t++)
|
||||
{
|
||||
WordColoring *w = &dsq->continuity.wordColoring[t];
|
||||
if ((c = lines[i].find(w->word)) != std::string::npos)
|
||||
{
|
||||
for (int j = c; j < c + w->word.size(); j++)
|
||||
{
|
||||
colorIndices[i][j] = w->color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
//lines.push_back(text);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -316,15 +297,9 @@ void BitmapText::onRender()
|
|||
float top_color[3] = {bmpFont->fontTopColor.x*color.x, bmpFont->fontTopColor.y*color.y, bmpFont->fontTopColor.z*color.z};
|
||||
float bottom_color[3] = {bmpFont->fontBtmColor.x*color.x, bmpFont->fontBtmColor.y*color.y, bmpFont->fontBtmColor.z*color.z};
|
||||
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
/*
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
*/
|
||||
//glDisable(GL_CULL_FACE);
|
||||
|
||||
//glScalef(1, -1, 0);
|
||||
|
||||
|
||||
bmpFont->font.Begin();
|
||||
|
||||
|
@ -353,11 +328,7 @@ void BitmapText::onRender()
|
|||
x = -sz.first*0.5f*bmpFont->scale;
|
||||
}
|
||||
float la = 1.0f-(scrollDelay/scrollSpeed);
|
||||
/*
|
||||
std::ostringstream os;
|
||||
os << "la: " << la;
|
||||
debugLog(os.str());
|
||||
*/
|
||||
|
||||
|
||||
bmpFont->font.DrawString(theLine, bmpFont->scale, x, y, top_color, bottom_color, alpha.x, la);
|
||||
y += adj;
|
||||
|
@ -378,11 +349,10 @@ void BitmapText::onRender()
|
|||
y += adj;
|
||||
}
|
||||
}
|
||||
|
||||
//glEnable(GL_CULL_FACE);
|
||||
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
void BitmapText::unloadDevice()
|
||||
|
@ -454,33 +424,4 @@ float BitmapText::getStringWidth(const std::string& text)
|
|||
return maxsize * bmpFont->scale;
|
||||
}
|
||||
|
||||
/*
|
||||
BitmapText::BitmapText() : RenderObject()
|
||||
{
|
||||
cull = false;
|
||||
followCamera = 1;
|
||||
scrollSpeed = 0.1f;
|
||||
}
|
||||
|
||||
void BitmapText::scrollText(const std::string &text, float scrollSpeed)
|
||||
{
|
||||
setText(text);
|
||||
this->scrollSpeed = scrollSpeed;
|
||||
}
|
||||
|
||||
void BitmapText::setText(const std::string &text)
|
||||
{
|
||||
this->text = text;
|
||||
}
|
||||
|
||||
std::string BitmapText::getText()
|
||||
{
|
||||
return text;
|
||||
}
|
||||
|
||||
void BitmapText::onRender()
|
||||
{
|
||||
CTextDrawer::GetSingleton().SetColor(color.x, color.y, color.z, alpha.getValue());
|
||||
dsq->print(position.x, 600 - (position.y + 16*2), text);
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#ifndef BITMAPFONT_H
|
||||
#define BITMAPFONT_H
|
||||
|
||||
//#include "DrawText.h"
|
||||
|
||||
#include "RenderObject.h"
|
||||
#include "BaseText.h"
|
||||
|
||||
|
|
|
@ -1,139 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "BloomEffect.h"
|
||||
#include "Core.h"
|
||||
|
||||
BloomEffect::BloomEffect() : RenderObject()
|
||||
{
|
||||
active = false;
|
||||
followCamera = 1;
|
||||
cull = 0;
|
||||
stretch = 0;
|
||||
startLayer = endLayer = -1;
|
||||
|
||||
texID = 0;
|
||||
format = GL_LUMINANCE;
|
||||
|
||||
useFrameBuffer = true;
|
||||
}
|
||||
|
||||
void BloomEffect::init(int quality, int startLayer, int endLayer)
|
||||
{
|
||||
this->startLayer = startLayer;
|
||||
this->endLayer = endLayer;
|
||||
this->quality = quality;
|
||||
|
||||
if (useFrameBuffer)
|
||||
{
|
||||
if (frameBuffer.init(quality, quality))
|
||||
active = true;
|
||||
else
|
||||
{
|
||||
active = false;
|
||||
useFrameBuffer = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
texID = generateEmptyTexture(quality);
|
||||
}
|
||||
}
|
||||
|
||||
void BloomEffect::unloadDevice()
|
||||
{
|
||||
if (frameBuffer.isInited())
|
||||
frameBuffer.unloadDevice();
|
||||
}
|
||||
|
||||
void BloomEffect::reloadDevice()
|
||||
{
|
||||
if (frameBuffer.isInited())
|
||||
frameBuffer.reloadDevice();
|
||||
}
|
||||
|
||||
void BloomEffect::render()
|
||||
{
|
||||
if (active && frameBuffer.isInited())
|
||||
{
|
||||
// get
|
||||
glViewport(0,0,quality,quality);
|
||||
|
||||
frameBuffer.startCapture();
|
||||
|
||||
glClearColor(0,0,0,1);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
core->render(startLayer, endLayer, false);
|
||||
|
||||
if (useFrameBuffer)
|
||||
{
|
||||
frameBuffer.endCapture();
|
||||
}
|
||||
else
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D,texID);
|
||||
glCopyTexImage2D(GL_TEXTURE_2D, 0, format, 0, 0, quality, quality, 0);
|
||||
}
|
||||
|
||||
core->setClearColor(core->getClearColor());
|
||||
glViewport(0, 0, core->width, core->height);
|
||||
|
||||
|
||||
// render
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
if (useFrameBuffer)
|
||||
frameBuffer.bindTexture();
|
||||
else
|
||||
glBindTexture(GL_TEXTURE_2D,texID);
|
||||
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
|
||||
//glScalef(scale.x, scale.y, 0);
|
||||
|
||||
float spost = 0.0;
|
||||
|
||||
|
||||
int x=0,y=0;
|
||||
x = -core->getVirtualOffX()*2;
|
||||
y = -core->getVirtualOffY()*2;
|
||||
applyBlendType();
|
||||
glColor4f(color.x, color.y, color.z, alpha.x*alphaMod);
|
||||
glBegin(GL_QUADS); // Begin Drawing Quads
|
||||
|
||||
glTexCoord2f(0,1); // Texture Coordinate ( 0, 1 )
|
||||
glVertex2f(x-stretch,y-stretch); // First Vertex ( 0, 0 )
|
||||
glTexCoord2f(0,0); // Texture Coordinate ( 0, 0 )
|
||||
glVertex2f(x-stretch,core->height+stretch); // Second Vertex ( 0, 480 )
|
||||
|
||||
glTexCoord2f(1,0); // Texture Coordinate ( 1, 0 )
|
||||
glVertex2f(core->width+stretch,core->height+stretch); // Third Vertex ( 640, 480 )
|
||||
|
||||
glTexCoord2f(1,1); // Texture Coordinate ( 1, 1 )
|
||||
glVertex2f(core->width+stretch,y-stretch); // Fourth Vertex ( 640, 0 )
|
||||
glEnd();
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
RenderObject::lastTextureApplied = 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef BLOOMEFFECT_H
|
||||
#define BLOOMEFFECT_H
|
||||
|
||||
#include "RenderObject.h"
|
||||
#include "FrameBuffer.h"
|
||||
|
||||
class BloomEffect : public RenderObject
|
||||
{
|
||||
public:
|
||||
BloomEffect();
|
||||
void init(int quality, int startLayer, int endLayer);
|
||||
FrameBuffer frameBuffer;
|
||||
void unloadDevice();
|
||||
void reloadDevice();
|
||||
void render();
|
||||
|
||||
GLuint format;
|
||||
int texID;
|
||||
|
||||
protected:
|
||||
int startLayer, endLayer;
|
||||
int quality;
|
||||
bool active;
|
||||
int stretch; // slightly adjust edges outward
|
||||
bool useFrameBuffer;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
//#ifdef BBGE_BUILD_MSVC8X
|
||||
|
||||
extern "C"
|
||||
{
|
||||
int errno;
|
||||
}
|
||||
|
||||
//#endif
|
|
@ -1,443 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "Collision.h"
|
||||
|
||||
CollisionShape::CollisionShape()
|
||||
{
|
||||
xw = yw = 0;
|
||||
setType(CIRCLE);
|
||||
active = true;
|
||||
project = true;
|
||||
radius = 32;
|
||||
corners.resize(4);
|
||||
layer = 0;
|
||||
}
|
||||
|
||||
void CollisionShape::setType(Type type)
|
||||
{
|
||||
this->type = type;
|
||||
}
|
||||
|
||||
CollisionShape::Type CollisionShape::getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
/*
|
||||
bool CollisionShape::compareMask(CollisionShape &c)
|
||||
{
|
||||
for (CollisionLayerMask::iterator i = c.colliderMask.begin(); i != c.colliderMask.end(); i++)
|
||||
{
|
||||
for (CollisionLayerMask::iterator j = c.collideeMask.begin(); j != c.collideeMask.end(); j++)
|
||||
{
|
||||
if ((*i)) && (*j))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
bool CollisionShape::compareLayer(CollisionShape &c)
|
||||
{
|
||||
return (this->layer <= c.layer);
|
||||
}
|
||||
|
||||
void CollisionShape::updatePosition(const Vector &position)
|
||||
{
|
||||
this->position = position + offsetPosition;
|
||||
/*
|
||||
switch (getType())
|
||||
{
|
||||
case AABB:
|
||||
{
|
||||
corners[0] = position + Vector( - xw, - yw);
|
||||
corners[1] = position + Vector(xw, - yw);
|
||||
corners[2] = position + Vector(xw, yw);
|
||||
corners[3] = position + Vector(-xw ,yw);
|
||||
}
|
||||
break;
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
CollisionResult CollisionShape::findOverlap(CollisionShape &collisionShape)
|
||||
{
|
||||
CollisionResult c;
|
||||
|
||||
|
||||
switch (getType())
|
||||
{
|
||||
case CIRCLE:
|
||||
{
|
||||
switch(collisionShape.getType())
|
||||
{
|
||||
case CIRCLE:
|
||||
c = collideCircleWithCircle(collisionShape);
|
||||
break;
|
||||
case AABB:
|
||||
{
|
||||
|
||||
float txw = collisionShape.xw;
|
||||
float tyw = collisionShape.yw;
|
||||
|
||||
Vector d = position - collisionShape.position;//tile->obj delta
|
||||
int px = (txw + radius) - fabsf(d.x);//penetration depth in x
|
||||
|
||||
if(0 < px)
|
||||
{
|
||||
int py = (tyw + radius) - fabsf(d.y);//pen depth in y
|
||||
|
||||
if(0 < py)
|
||||
{
|
||||
//object may be colliding with tile
|
||||
|
||||
//determine grid/voronoi region of circle center
|
||||
float oH = 0;
|
||||
float oV = 0;
|
||||
if(d.x < -txw)
|
||||
{
|
||||
//circle is on left side of tile
|
||||
oH = -1;
|
||||
}
|
||||
else if(txw < d.x)
|
||||
{
|
||||
//circle is on right side of tile
|
||||
oH = 1;
|
||||
}
|
||||
|
||||
if(d.y < -tyw)
|
||||
{
|
||||
//circle is on top side of tile
|
||||
oV = -1;
|
||||
}
|
||||
else if(tyw < d.y)
|
||||
{
|
||||
//circle is on bottom side of tile
|
||||
oV = 1;
|
||||
}
|
||||
|
||||
c = collideCircleWithAABB(collisionShape, px, py, oH, oV);
|
||||
//ResolveCircleTile(px,py,oH,oV,this,c);
|
||||
|
||||
}
|
||||
}
|
||||
//return collideCircleWithAABB(collisionShape);
|
||||
}
|
||||
break;
|
||||
case TOP_HALF_CIRCLE:
|
||||
c = collideCircleWithTopHalfCircle(collisionShape);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
CollisionResult CollisionShape::collideCircleWithCircle(CollisionShape &collisionShape)
|
||||
{
|
||||
CollisionResult c;
|
||||
Vector dist = position - collisionShape.position;// - position;
|
||||
float fastLen = dist.getSquaredLength2D();
|
||||
float totalDist = (radius + collisionShape.radius);
|
||||
if (fastLen < (totalDist*totalDist))
|
||||
{
|
||||
/*
|
||||
std::ostringstream os;
|
||||
os << "len " << len << " totalDist " << totalDist;
|
||||
msg(os.str());
|
||||
*/
|
||||
float len = dist.getLength2D();
|
||||
c.collided = true;
|
||||
dist.setLength2D(totalDist - len);
|
||||
//dist |= totalDist;
|
||||
c.overlap = dist;
|
||||
}
|
||||
else
|
||||
{
|
||||
c.collided = false;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
float CollisionShape::getY1()
|
||||
{
|
||||
return position.y - yw;
|
||||
}
|
||||
|
||||
float CollisionShape::getY2()
|
||||
{
|
||||
return position.y + yw;
|
||||
}
|
||||
|
||||
float CollisionShape::getX1()
|
||||
{
|
||||
return position.x - xw;
|
||||
}
|
||||
|
||||
float CollisionShape::getX2()
|
||||
{
|
||||
return position.x + xw;
|
||||
}
|
||||
|
||||
void CollisionShape::render()
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
glTranslatef(offsetPosition.x, offsetPosition.y,0);
|
||||
switch(getType())
|
||||
{
|
||||
case CIRCLE:
|
||||
drawCircle(radius);
|
||||
break;
|
||||
case AABB:
|
||||
//case CIRCLE:
|
||||
//glColor3f(1,1,1);
|
||||
|
||||
//glLineWidth(2);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
{
|
||||
glVertex2f(-xw,yw);
|
||||
glVertex2f(xw,yw);
|
||||
glVertex2f(xw,-yw);
|
||||
glVertex2f(-xw,-yw);
|
||||
|
||||
/*
|
||||
glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
|
||||
glVertex2f(topLeft.x, topLeft.y);
|
||||
glVertex2f(bottomRight.x, topLeft.y);
|
||||
|
||||
glVertex2f(bottomRight.x, topLeft.y);
|
||||
glVertex2f(bottomRight.x, bottomRight.y);
|
||||
|
||||
glVertex2f(bottomRight.x, bottomRight.y);
|
||||
glVertex2f(topLeft.x, bottomRight.y);
|
||||
|
||||
glVertex2f(topLeft.x, bottomRight.y);
|
||||
glVertex2f(topLeft.x, topLeft.y);
|
||||
|
||||
*/
|
||||
}
|
||||
glEnd();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
glTranslatef(-offsetPosition.x, -offsetPosition.y,0);
|
||||
#endif
|
||||
//glDisable(GL_BLEND);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
// FOR EDGES
|
||||
|
||||
if (position.y > collisionShape.getY1() - radius && position.y < collisionShape.getY2() + radius)
|
||||
{
|
||||
float dist = collisionShape.getX1() - position.x;
|
||||
if (dist > 0 && dist < radius)
|
||||
{
|
||||
c.collided = true;
|
||||
c.overlap = Vector(radius - dist,0);
|
||||
}
|
||||
else if (dist < 0 && -dist < radius)
|
||||
{
|
||||
c.collided = true;
|
||||
c.overlap = -Vector(radius - (-dist),0);
|
||||
}
|
||||
}
|
||||
|
||||
if (!c.collided)
|
||||
{
|
||||
if (position.y > collisionShape.getY1() - radius && position.y < collisionShape.getY2() + radius)
|
||||
{
|
||||
float dist = collisionShape.getX2() - position.x;
|
||||
if (dist > 0 && dist < radius)
|
||||
{
|
||||
c.collided = true;
|
||||
c.overlap += Vector(radius - dist,0);
|
||||
}
|
||||
else if (dist < 0 && -dist < radius)
|
||||
{
|
||||
c.collided = true;
|
||||
c.overlap += -Vector(radius - (-dist),0);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
CollisionResult CollisionShape::collideCircleWithAABB(CollisionShape &collisionShape, float x, float y, int oH, int oV)
|
||||
{
|
||||
CollisionResult c;
|
||||
if(oH == 0)
|
||||
{
|
||||
if(oV == 0)
|
||||
{
|
||||
|
||||
//collision with current cell
|
||||
if(x < y)
|
||||
{
|
||||
//penetration in x is smaller; project in x
|
||||
float dx = position.x - collisionShape.position.x;//get sign for projection along x-axis
|
||||
|
||||
|
||||
|
||||
// msg("oH==0, oV ==0, x <y");
|
||||
//NOTE: should we handle the delta == 0 case?! and how? (project towards oldpos?)
|
||||
if(dx < 0)
|
||||
{
|
||||
c.reportCollision(Vector(-x, 0));
|
||||
return c;
|
||||
}
|
||||
else
|
||||
{
|
||||
c.reportCollision(Vector(x,0));
|
||||
return c;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// msg("oH==0, oV ==0, x >= y");
|
||||
//penetration in y is smaller; project in y
|
||||
float dy = position.y - collisionShape.position.y;//get sign for projection along y-axis
|
||||
|
||||
//NOTE: should we handle the delta == 0 case?! and how? (project towards oldpos?)
|
||||
if(dy < 0)
|
||||
{
|
||||
c.reportCollision(Vector(0, -y));
|
||||
return c;
|
||||
}
|
||||
else
|
||||
{
|
||||
c.reportCollision(Vector(0, y));
|
||||
return c;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// msg ("oH == 0, oV != 0");
|
||||
c.reportCollision(Vector(0, y*oV));
|
||||
return c;
|
||||
}
|
||||
}
|
||||
else if(oV == 0)
|
||||
{
|
||||
// msg ("oV == 0");
|
||||
c.reportCollision(Vector(x*oH,0));
|
||||
return c;
|
||||
}
|
||||
else
|
||||
{
|
||||
//diagonal collision
|
||||
|
||||
//get diag vertex position
|
||||
float vx = collisionShape.position.x + (oH*collisionShape.xw);
|
||||
float vy = collisionShape.position.y + (oV*collisionShape.yw);
|
||||
|
||||
float dx = position.x - vx - 1;//calc vert->circle vector
|
||||
float dy = position.y - vy - 1;
|
||||
|
||||
float len = sqrtf(dx*dx + dy*dy);
|
||||
float pen = radius - len;
|
||||
if(0 < pen)
|
||||
{
|
||||
//vertex is in the circle; project outward
|
||||
if(len == 0)
|
||||
{
|
||||
//project out by 45deg
|
||||
dx = oH / SQRT2;
|
||||
dy = oV / SQRT2;
|
||||
}
|
||||
else
|
||||
{
|
||||
dx /= len;
|
||||
dy /= len;
|
||||
}
|
||||
|
||||
c.reportCollision(Vector(dx*pen, dy*pen));
|
||||
//obj.ReportCollisionVsWorld(dx*pen, dy*pen, dx, dy, t);
|
||||
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
return c;
|
||||
|
||||
}
|
||||
|
||||
bool CollisionShape::isPointWithin(Vector point)
|
||||
{
|
||||
switch (this->getType())
|
||||
{
|
||||
case CIRCLE:
|
||||
{
|
||||
Vector dist = point - this->position;
|
||||
return (dist.getSquaredLength2D() < sqr(this->radius));
|
||||
}
|
||||
break;
|
||||
case AABB:
|
||||
{
|
||||
if (point.x < position.x + xw && point.y < position.y + yw)
|
||||
{
|
||||
if (point.x > position.x - xw && point.y > position.y - yw)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
CollisionResult CollisionShape::collideCircleWithTopHalfCircle(CollisionShape &collisionShape)
|
||||
{
|
||||
CollisionResult c;
|
||||
Vector dist = collisionShape.position - position;
|
||||
float len = dist.getLength2D();
|
||||
float totalDist = (radius + collisionShape.radius);
|
||||
|
||||
//which edge did we hit?
|
||||
if (collisionShape.position.y > (position.y - (radius/2)))
|
||||
{
|
||||
if (len < collisionShape.radius)
|
||||
{
|
||||
c.collided = true;
|
||||
c.overlap = Vector(0, position.y - (collisionShape.position.y - collisionShape.radius));
|
||||
}
|
||||
}
|
||||
else if (len < totalDist && dist.y > 0)
|
||||
{
|
||||
c.collided = true;
|
||||
dist.setLength2D(totalDist - len);
|
||||
c.overlap = dist;
|
||||
}
|
||||
else
|
||||
{
|
||||
c.collided = false;
|
||||
}
|
||||
return c;
|
||||
}
|
146
BBGE/Collision.h
146
BBGE/Collision.h
|
@ -1,146 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef COLLISION_H
|
||||
#define COLLISION_H
|
||||
|
||||
#include "Base.h"
|
||||
|
||||
class RenderObject;
|
||||
struct CollisionResult
|
||||
{
|
||||
CollisionResult()
|
||||
{
|
||||
collided = false;
|
||||
collider = 0;
|
||||
project = true;
|
||||
}
|
||||
bool project;
|
||||
bool collided;
|
||||
Vector overlap;
|
||||
RenderObject *collider;
|
||||
|
||||
void reportCollision(Vector overlap)
|
||||
{
|
||||
collided = true;
|
||||
this->overlap = overlap;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class CollisionShape
|
||||
{
|
||||
public:
|
||||
CollisionShape();
|
||||
|
||||
/*
|
||||
void addCollisionGroup(int group);
|
||||
void removeCollisionGroup(int group);
|
||||
void canCollideWithGroup();
|
||||
*/
|
||||
|
||||
void updatePosition(const Vector &position);
|
||||
|
||||
void activate()
|
||||
{
|
||||
active = true;
|
||||
}
|
||||
void deactivate()
|
||||
{
|
||||
active = false;
|
||||
}
|
||||
|
||||
bool isActive()
|
||||
{
|
||||
return active;
|
||||
}
|
||||
|
||||
float getX1();
|
||||
float getX2();
|
||||
float getY1();
|
||||
float getY2();
|
||||
float xw, yw;
|
||||
float radius;
|
||||
|
||||
enum Type { NONE=0, AABB, CIRCLE, TOP_HALF_CIRCLE, TRIANGLE };
|
||||
|
||||
void setType(Type type);
|
||||
Type getType();
|
||||
|
||||
|
||||
|
||||
bool isPointWithin(Vector point);
|
||||
void render();
|
||||
|
||||
CollisionResult findOverlap(CollisionShape &collisionShape);
|
||||
Vector offsetPosition;
|
||||
|
||||
bool compareLayer(CollisionShape &c);
|
||||
//bool compareMask(CollisionShape &c);
|
||||
int getLayer() { return layer; }
|
||||
void setLayer(int layer) { this->layer = layer; }
|
||||
|
||||
bool project;
|
||||
protected:
|
||||
int layer;
|
||||
/*
|
||||
typedef std::vector<int> CollisionLayerMask;
|
||||
CollisionLayerMask colliderMask, collideeMask;
|
||||
*/
|
||||
std::vector<Vector> corners;
|
||||
Vector position;
|
||||
bool active;
|
||||
CollisionResult collideCircleWithCircle(CollisionShape &collisionShape);
|
||||
CollisionResult collideCircleWithTopHalfCircle(CollisionShape &collisionShape);
|
||||
CollisionResult collideCircleWithAABB(CollisionShape &collisionShape, float x, float y, int oH, int oV);
|
||||
|
||||
|
||||
|
||||
Type type;
|
||||
};
|
||||
|
||||
/*
|
||||
class CollisionObject
|
||||
{
|
||||
public:
|
||||
void onCollision();
|
||||
void collide()
|
||||
{
|
||||
CollisionResult c;
|
||||
for (int i = 0; i < collisionManager->colliders.size(); i++)
|
||||
{
|
||||
c = findOverlap(collisionManager->colliders[i]->collisionShape);
|
||||
if (c.collided)
|
||||
{
|
||||
position -= c.overlap;
|
||||
collisionShape.position =
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class CollisionManager
|
||||
{
|
||||
public:
|
||||
void addCollider(
|
||||
};
|
||||
*/
|
||||
|
||||
#endif
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef COMMONEVENTS_H
|
||||
#define COMMONEVENTS_H
|
||||
|
||||
#include "Event.h"
|
||||
|
||||
class SoundEvent : public Event
|
||||
{
|
||||
public:
|
||||
SoundEvent(const PlaySfx &p) : playSfx(p)
|
||||
{}
|
||||
void act()
|
||||
{
|
||||
core->sound->playSfx(playSfx);
|
||||
}
|
||||
private:
|
||||
PlaySfx playSfx;
|
||||
};
|
||||
|
||||
class JumpStateEvent : public Event
|
||||
{
|
||||
public:
|
||||
JumpStateEvent(const std::string &state) : state(state) {}
|
||||
void act()
|
||||
{
|
||||
core->enqueueJumpState(state, true);
|
||||
}
|
||||
private:
|
||||
std::string state;
|
||||
};
|
||||
|
||||
#endif
|
2012
BBGE/Core.cpp
2012
BBGE/Core.cpp
File diff suppressed because it is too large
Load diff
750
BBGE/Core.h
750
BBGE/Core.h
File diff suppressed because it is too large
Load diff
|
@ -1,37 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "Cube.h"
|
||||
|
||||
void Cube::onRender()
|
||||
{
|
||||
#if 0 // not used at the moment, and incompatible with OpenGL ES. --ryan.
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
glBegin(GL_QUADS);
|
||||
{
|
||||
//auxSolidCube(1);
|
||||
//auxSolidTorus(1,2);
|
||||
//auxSolidIcosahedron(1);
|
||||
//auxSolidSphere(1);
|
||||
}
|
||||
glEnd();
|
||||
#endif
|
||||
#endif
|
||||
}
|
34
BBGE/Cube.h
34
BBGE/Cube.h
|
@ -1,34 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef __cube__
|
||||
#define __cube__
|
||||
|
||||
#include "RenderObject.h"
|
||||
|
||||
|
||||
class Cube : public RenderObject
|
||||
{
|
||||
public:
|
||||
protected:
|
||||
void onRender();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,135 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "Cutscene.h"
|
||||
|
||||
Cutscene::Cutscene()
|
||||
{
|
||||
time = playing = 0;
|
||||
}
|
||||
|
||||
void Cutscene::play()
|
||||
{
|
||||
time = 0;
|
||||
playing = 1;
|
||||
}
|
||||
|
||||
void Cutscene::clear()
|
||||
{
|
||||
for (IDMap::iterator i = idMap.begin(); i != idMap.end(); ++i)
|
||||
{
|
||||
(*i).second->safeKill();
|
||||
}
|
||||
|
||||
idMap.clear();
|
||||
markers.clear();
|
||||
}
|
||||
|
||||
void Cutscene::load(const std::string &f)
|
||||
{
|
||||
clear();
|
||||
|
||||
doc.LoadFile(f.c_str());
|
||||
|
||||
XMLElement *e = doc.FirstChildElement("time");
|
||||
while (e)
|
||||
{
|
||||
CutsceneMarker m;
|
||||
m.e = e;
|
||||
|
||||
std::string s = e->Attribute("t");
|
||||
int p = 0, c1=0,c2=0;
|
||||
float t = 0;
|
||||
for (int c=0; c < s.size(); c++)
|
||||
{
|
||||
switch(c)
|
||||
{
|
||||
case 0:
|
||||
t += atoi(s[c]) * (600);
|
||||
break;
|
||||
case 1:
|
||||
t += atoi(s[c]) * 60;
|
||||
break;
|
||||
case 3:
|
||||
t += atoi(s[c]) * 10;
|
||||
break;
|
||||
case 4:
|
||||
t += atoi(s[c]);
|
||||
break;
|
||||
case 6:
|
||||
t += atoi(s[c]) * 0.1f;
|
||||
break;
|
||||
case 7:
|
||||
t += atoi(s[c]) * 0.01f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
markers.push_back(m);
|
||||
}
|
||||
}
|
||||
|
||||
void Cutscene::save(const std::string &f)
|
||||
{
|
||||
}
|
||||
|
||||
void Cutscene::playMarker(CutsceneMarker *m)
|
||||
{
|
||||
if (m)
|
||||
{
|
||||
XMLElement *r=0;
|
||||
if (r = m->e->FirstChildElement("quad"))
|
||||
{
|
||||
id = r->Attribute("id");
|
||||
if (idMap[id])
|
||||
{
|
||||
errorLog("id [" + id + "] already exists");
|
||||
}
|
||||
|
||||
std::string gfx = m->e->Attribute("gfx");
|
||||
std::istringstream is(m->e->Attribute("pos"));
|
||||
Vector pos;
|
||||
is >> pos.x >> pos.y >> pos.z;
|
||||
int layer = atoi(m->e->Attribute("layer"));
|
||||
|
||||
Quad *q = new Quad(gfx, pos);
|
||||
addRenderObject(q, layer);
|
||||
}
|
||||
if (r = m->e->FirstChildElement(""))
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Cutscene::update(float dt)
|
||||
{
|
||||
if (playing)
|
||||
{
|
||||
time += dt;
|
||||
|
||||
while ((curMarker < markers.size()) && (time >= markers[curMarker].t))
|
||||
{
|
||||
playMarker(&markers[curMarker]);
|
||||
|
||||
curMarker ++;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "Core.h"
|
||||
#include "SkeletalSprite.h"
|
||||
#include "Particles.h"
|
||||
|
||||
struct CutsceneMarker
|
||||
{
|
||||
float t;
|
||||
XMLElement *e;
|
||||
};
|
||||
|
||||
class Cutscene
|
||||
{
|
||||
public:
|
||||
Cutscene();
|
||||
|
||||
void play();
|
||||
void playMarker(CutsceneMarker *m);
|
||||
void load(const std::string &f);
|
||||
void save(const std::string &f);
|
||||
|
||||
void update(float dt);
|
||||
|
||||
XMLDocument file;
|
||||
|
||||
std::vector <CutsceneMarker> markers;
|
||||
|
||||
float time;
|
||||
int playing;
|
||||
int curMarker;
|
||||
|
||||
typedef std::map<std::string, RenderObject*> IDMap;
|
||||
IDMap idMap;
|
||||
|
||||
|
||||
// readers
|
||||
std::string id;
|
||||
};
|
||||
|
|
@ -1,174 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "DFSprite.h"
|
||||
#include "MathFunctions.h"
|
||||
|
||||
DFSprite::DFSprite() : AnimatedSprite()
|
||||
{
|
||||
//debugLog("DFSprite::DFSprite()");
|
||||
currentDatafile = 0;
|
||||
//debugLog("End DFSprite::DFSprite()");
|
||||
}
|
||||
|
||||
/*
|
||||
DFSprite::~DFSprite()
|
||||
{
|
||||
destroy();
|
||||
}
|
||||
*/
|
||||
|
||||
void DFSprite::destroy()
|
||||
{
|
||||
//make sure that animatedSprite::destroy() doesn't
|
||||
// destroy our texture
|
||||
// since its just a pointer to a texture in the datafile
|
||||
texture = 0;
|
||||
for (int i = 0; i < datafiles.size(); i++)
|
||||
{
|
||||
datafiles[i]->destroy();
|
||||
delete datafiles[i];
|
||||
}
|
||||
datafiles.clear();
|
||||
AnimatedSprite::destroy();
|
||||
}
|
||||
|
||||
void DFSprite::onUpdate(float dt)
|
||||
{
|
||||
AnimatedSprite::onUpdate(dt);
|
||||
|
||||
if (currentDatafile)
|
||||
{
|
||||
setTexturePointer(currentDatafile->get(frame), NO_ADD_REF);
|
||||
}
|
||||
}
|
||||
|
||||
void DFSprite::onSetTexture()
|
||||
{
|
||||
Quad::onSetTexture();
|
||||
/*
|
||||
width = texture->width;
|
||||
height = texture->height;
|
||||
*/
|
||||
|
||||
//scale = Vector(texture->width, texture->height,0);
|
||||
}
|
||||
|
||||
// returns index of datafile with the specified name
|
||||
// returns -1 on failure
|
||||
int DFSprite::findDatafile(const std::string &name)
|
||||
{
|
||||
for (int i = 0; i < datafiles.size(); i++)
|
||||
{
|
||||
if (datafiles[i]->getName()==name)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// select datafile # index
|
||||
void DFSprite::selectDatafile(int index)
|
||||
{
|
||||
if (datafiles.empty())
|
||||
msg("Datafiles empty");
|
||||
if (index >= datafiles.size() || index <0)
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << "Datafile selection index out of range [";
|
||||
os << index;
|
||||
os << "]";
|
||||
msg(os.str());
|
||||
errorLog(os.str());
|
||||
exit(0);
|
||||
}
|
||||
currentDatafile = datafiles[index];
|
||||
}
|
||||
|
||||
int DFSprite::addDatafile()
|
||||
{
|
||||
Datafile *d = new Datafile;
|
||||
datafiles.push_back(d);
|
||||
return datafiles.size()-1;
|
||||
}
|
||||
|
||||
void DFSprite::onAnimData(AnimData &animData)
|
||||
{
|
||||
selectDatafile(animData.datafile);
|
||||
}
|
||||
|
||||
Datafile *DFSprite::getDatafile(int index)
|
||||
{
|
||||
if (index < 0 || index >= datafiles.size())
|
||||
errorLog("Datafile index out of bounds");
|
||||
return datafiles[index];
|
||||
}
|
||||
|
||||
// shorctut code
|
||||
// select the datafile as specified by animData
|
||||
void DFSprite::selectDatafile(AnimData &animData)
|
||||
{
|
||||
selectDatafile(animData.datafile);
|
||||
}
|
||||
|
||||
// get the datafile specified in animData
|
||||
Datafile *DFSprite::getDatafile(AnimData &animData)
|
||||
{
|
||||
return getDatafile(animData.datafile);
|
||||
}
|
||||
|
||||
void DFSprite::setFrameBasedRotation(const Vector &p1, const Vector &p2)
|
||||
{
|
||||
if (currentDatafile)
|
||||
{
|
||||
float angle;
|
||||
MathFunctions::calculateAngleBetweenVectorsInDegrees(p1, p2, angle);
|
||||
angle += 90;
|
||||
int bframe = frame;
|
||||
bframe = int((angle*float(currentDatafile->getSize())) / 360.0f);
|
||||
if (bframe >= currentDatafile->getSize())
|
||||
bframe = currentDatafile->getSize()-1;
|
||||
else if (bframe < 0)
|
||||
bframe = 0;
|
||||
frame = bframe;
|
||||
}
|
||||
else
|
||||
{
|
||||
msg ("No datafile selected");
|
||||
}
|
||||
}
|
||||
|
||||
void DFSprite::selectDatafileBasedRotation(const Vector &p1, const Vector &p2, int datafileRange, int datafileIndexOffset, bool flipAngle, float angleOffset)
|
||||
{
|
||||
float angle;
|
||||
MathFunctions::calculateAngleBetweenVectorsInDegrees(p1, p2, angle);
|
||||
angle += 90;
|
||||
angle += angleOffset;
|
||||
if (flipAngle)
|
||||
angle = 360 - angle;
|
||||
int bframe = frame;
|
||||
bframe = int((angle*float(datafileRange)) / 360.0f);
|
||||
if (bframe >= datafileRange)
|
||||
bframe = datafileRange-1;
|
||||
else if (bframe < 0)
|
||||
bframe = 0;
|
||||
selectDatafile(bframe+datafileIndexOffset);
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef __dfsprite__
|
||||
#define __dfsprite__
|
||||
|
||||
#include "Quad.h"
|
||||
#include "Datafile.h"
|
||||
#include "AnimatedSprite.h"
|
||||
|
||||
class DFSprite : public AnimatedSprite
|
||||
{
|
||||
public:
|
||||
DFSprite();
|
||||
//~DFSprite();
|
||||
void destroy();
|
||||
|
||||
//void animate();
|
||||
|
||||
int findDatafile(const std::string &name);
|
||||
void selectDatafile(int index);
|
||||
void selectDatafile(AnimData &animData);
|
||||
Datafile *getDatafile(int index);
|
||||
Datafile *getDatafile(AnimData &animData);
|
||||
int addDatafile();
|
||||
void setFrameBasedRotation(const Vector &p1, const Vector &p2);
|
||||
void selectDatafileBasedRotation(const Vector &p1, const Vector &p2, int datafileRange, int datafileIndexOffset=0, bool flipAngle=false, float angleOffset=0);
|
||||
protected:
|
||||
void onAnimData(AnimData &animData);
|
||||
std::vector<Datafile*> datafiles;
|
||||
Datafile *currentDatafile;
|
||||
void onSetTexture();
|
||||
void onUpdate(float dt);
|
||||
};
|
||||
|
||||
#endif
|
|
@ -40,10 +40,8 @@ void DarkLayer::unloadDevice()
|
|||
frameBuffer.unloadDevice();
|
||||
else
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
if (texture)
|
||||
glDeleteTextures(1, &texture);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,7 +63,7 @@ bool DarkLayer::isUsed()
|
|||
//HACK: disabling dark layer for temporary testing build
|
||||
// MAKE SURE TO RESTORE THIS CODE TO THE WAY IT WAS
|
||||
return layer > -1 && active;
|
||||
//return false;
|
||||
|
||||
}
|
||||
|
||||
void DarkLayer::setLayers(int layer, int rl)
|
||||
|
@ -81,7 +79,7 @@ void DarkLayer::init(int quality, bool useFrameBufferParam)
|
|||
this->quality = quality;
|
||||
|
||||
if (useFrameBuffer)
|
||||
{
|
||||
{
|
||||
if (!frameBuffer.init(quality, quality))
|
||||
useFrameBuffer = false;
|
||||
else
|
||||
|
@ -106,33 +104,31 @@ void DarkLayer::toggle(bool on)
|
|||
|
||||
void DarkLayer::preRender()
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
bool verbose = core->coreVerboseDebug;
|
||||
if (layer != -1)
|
||||
{
|
||||
if (verbose) debugLog("viewport");
|
||||
|
||||
glViewport(0,0,quality,quality);
|
||||
//core->clearBuffers();
|
||||
|
||||
//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
|
||||
|
||||
|
||||
if (verbose) debugLog("startCapture");
|
||||
|
||||
if (useFrameBuffer)
|
||||
frameBuffer.startCapture();
|
||||
|
||||
if (verbose) debugLog("clearColor");
|
||||
|
||||
|
||||
glClearColor(1,1,1,1);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
if (verbose) debugLog("render");
|
||||
|
||||
core->render(layer, layer, false);
|
||||
|
||||
core->render(layer, layer, false);
|
||||
|
||||
if (verbose) debugLog("endCapture");
|
||||
|
||||
|
||||
if (useFrameBuffer)
|
||||
frameBuffer.endCapture();
|
||||
else
|
||||
|
@ -143,44 +139,36 @@ void DarkLayer::preRender()
|
|||
}
|
||||
|
||||
if (verbose) debugLog("viewport");
|
||||
|
||||
|
||||
glViewport(0, 0, core->width, core->height);
|
||||
glClearColor(0,0,0,0);
|
||||
|
||||
|
||||
if (verbose) debugLog("done");
|
||||
/*
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
*/
|
||||
//glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, quality, quality, 0);
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void DarkLayer::render()
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
if (renderLayer != -1)
|
||||
{
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
//float percentX = (float)core->width/(float)quality;
|
||||
//float percentY = (float)core->height/(float)quality;
|
||||
|
||||
|
||||
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
if (useFrameBuffer)
|
||||
frameBuffer.bindTexture();
|
||||
else
|
||||
glBindTexture(GL_TEXTURE_2D,texture);
|
||||
|
||||
//glDisable(GL_BLEND);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
//glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
//glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
//glBlendFunc(GL_ZERO, GL_SRC_COLOR);
|
||||
|
||||
//glBlendEquation(GL_FUNC_SUBTRACT);
|
||||
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
|
||||
|
||||
// subtractive blend! (using color)
|
||||
glBlendFunc(GL_ZERO, GL_SRC_COLOR);
|
||||
|
@ -194,9 +182,9 @@ void DarkLayer::render()
|
|||
{
|
||||
debugLog("darkLayer: invalid operation");
|
||||
}
|
||||
|
||||
//glBlendFunc(GL_SRC_ALPHA_SATURATE, GL_ONE);
|
||||
//glBlendFunc(GL_ONE_MINUS_SRC_COLOR, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
|
||||
|
||||
glColor4f(1,1,1,1);
|
||||
|
||||
float width = core->getWindowWidth();
|
||||
|
@ -221,10 +209,9 @@ void DarkLayer::render()
|
|||
glEnd();
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
|
||||
RenderObject::lastTextureApplied = 0;
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
int getLayer();
|
||||
int getRenderLayer();
|
||||
bool isUsed();
|
||||
|
||||
|
||||
void unloadDevice();
|
||||
void reloadDevice();
|
||||
|
||||
|
@ -47,8 +47,8 @@ protected:
|
|||
int quality;
|
||||
bool active;
|
||||
int layer, renderLayer;
|
||||
|
||||
|
||||
|
||||
|
||||
GLuint texture;
|
||||
GLuint format;
|
||||
};
|
||||
|
|
|
@ -1,158 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "Datafile.h"
|
||||
#include "Texture.h"
|
||||
|
||||
Datafile::Datafile()
|
||||
{
|
||||
w = 0; h = 0;
|
||||
}
|
||||
|
||||
Datafile::~Datafile()
|
||||
{
|
||||
destroy();
|
||||
}
|
||||
|
||||
void Datafile::destroy()
|
||||
{
|
||||
for (int i = 0; i < textures.size(); i++)
|
||||
{
|
||||
textures[i]->removeRef();
|
||||
}
|
||||
textures.clear();
|
||||
}
|
||||
|
||||
//hacky... for now
|
||||
void Datafile::addTexture(Texture *t)
|
||||
{
|
||||
textures.push_back(t);
|
||||
w = t->width;
|
||||
h = t->height;
|
||||
}
|
||||
|
||||
Texture* Datafile::get(int idx)
|
||||
{
|
||||
if (idx < 0 || idx >= textures.size())
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << "index [" << idx << "] out of range - textureName[" << this->name << "]";
|
||||
errorLog (os.str());
|
||||
}
|
||||
return textures[idx];
|
||||
}
|
||||
/*
|
||||
void Datafile::load(const std::string &name, int w, int h)
|
||||
{
|
||||
this->w = w;
|
||||
this->h = h;
|
||||
std::ifstream in;
|
||||
in.open(name);
|
||||
std::string read;
|
||||
while (std::getline(in,read))
|
||||
{
|
||||
Texture *t = new Texture;
|
||||
t->loadFromString(read);
|
||||
}
|
||||
}
|
||||
|
||||
void Datafile::save(const std::string &datafile)
|
||||
{
|
||||
std::ofstream out;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
void Datafile::loadFromAVI(const std::string &aviFile)
|
||||
{
|
||||
/*
|
||||
AviRender a(aviFile);
|
||||
|
||||
bool done = false;
|
||||
float time = 0;
|
||||
int counter = 20;
|
||||
while (!done)
|
||||
{
|
||||
// GLuint id;
|
||||
//a.bindFrameToTexture(time, &id);
|
||||
//if (id)
|
||||
{
|
||||
Texture *texture = new Texture;
|
||||
//a.setCurrentFrameAsTexture();
|
||||
//texture->id = a.id;
|
||||
a.bindFrameToTexture(time, texture->id, texture->imageData);
|
||||
|
||||
//texture->setID(id);
|
||||
texture->width = 512;
|
||||
texture->height = 512;
|
||||
addTexture(texture);
|
||||
//texture->addRef();
|
||||
//frame ++;
|
||||
}
|
||||
|
||||
|
||||
counter --;
|
||||
if (counter <= 0)
|
||||
done = true;
|
||||
|
||||
time += 1;
|
||||
//frame++;
|
||||
|
||||
}
|
||||
|
||||
//a.getCurrentFrameAsTexture();
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
void Datafile::loadTextureRange(const std::string &file, const std::string &type, int start, int end)
|
||||
{
|
||||
for (int t = start; t < end; t++)
|
||||
{
|
||||
|
||||
std::ostringstream num_os;
|
||||
num_os << t;
|
||||
|
||||
std::ostringstream os;
|
||||
os << file;
|
||||
|
||||
for (int j = 0; j < 4 - num_os.str().size(); j++)
|
||||
{
|
||||
os << "0";
|
||||
}
|
||||
|
||||
os << t;
|
||||
|
||||
os << type;
|
||||
|
||||
addTexture(core->addTexture(os.str()));
|
||||
}
|
||||
}
|
||||
|
||||
const std::string &Datafile::getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
void Datafile::setName(const std::string &name)
|
||||
{
|
||||
this->name = name;
|
||||
}
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef __datafile__
|
||||
#define __datafile__
|
||||
|
||||
#include "Core.h"
|
||||
|
||||
class Datafile
|
||||
{
|
||||
public:
|
||||
Datafile();
|
||||
~Datafile();
|
||||
void destroy();
|
||||
|
||||
void addTexture(Texture *t);
|
||||
Texture* get(int idx);
|
||||
void loadTextureRange(const std::string &file, const std::string &type, int start, int end);
|
||||
void loadFromAVI(const std::string &aviFile);
|
||||
|
||||
const std::string &getName();
|
||||
|
||||
void setName(const std::string &name);
|
||||
int getSize()
|
||||
{
|
||||
return textures.size();
|
||||
}
|
||||
protected:
|
||||
//void load(const std::string &name);
|
||||
std::string name;
|
||||
|
||||
|
||||
int w, h;
|
||||
|
||||
std::vector <Texture*> textures;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -132,10 +132,9 @@ void DebugFont::onRender()
|
|||
{
|
||||
const float vspc = 1.5;
|
||||
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
for (int i = 0; i < lines.size(); i++)
|
||||
{
|
||||
//float width = (lines[i].size()-1) * fontDrawSize * 1.4f * 0.75f;
|
||||
|
||||
float width = (lines[i].size()) * fontDrawSize * 1.4f * 0.75f;
|
||||
if (align == ALIGN_CENTER)
|
||||
{
|
||||
|
@ -152,7 +151,6 @@ void DebugFont::onRender()
|
|||
glTranslatef(width*0.5f, 0, 0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void DebugFont::setAlign(Align align)
|
||||
|
@ -164,7 +162,12 @@ void DebugFont::setAlign(Align align)
|
|||
#include "../BBGE/Quad.h"
|
||||
|
||||
DebugButton::DebugButton(int buttonID, DebugButtonReceiver *receiver, int bgWidth, int fsize, bool quitMain)
|
||||
: RenderObject(), label(0), highlight(0), quitMain(quitMain), receiver(receiver), buttonID(buttonID)
|
||||
: RenderObject()
|
||||
, label(0)
|
||||
, quitMain(quitMain)
|
||||
, buttonID(buttonID)
|
||||
, highlight(0)
|
||||
, receiver(receiver)
|
||||
{
|
||||
if (bgWidth == 0)
|
||||
bgWidth = 150;
|
||||
|
|
|
@ -58,7 +58,7 @@ public:
|
|||
EventPtr event;
|
||||
bool quitMain;
|
||||
int buttonID;
|
||||
|
||||
|
||||
protected:
|
||||
void onUpdate(float dt);
|
||||
Quad *highlight;
|
||||
|
|
|
@ -76,11 +76,12 @@ void PostProcessingFX::render()
|
|||
{
|
||||
if (enabled[i])
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
glPushMatrix();
|
||||
FXTypes type = (FXTypes)i;
|
||||
switch(type)
|
||||
{
|
||||
case FXT_MAX:
|
||||
break;
|
||||
case FXT_RADIALBLUR:
|
||||
|
||||
float windowW = core->getWindowWidth();
|
||||
|
@ -153,97 +154,9 @@ void PostProcessingFX::render()
|
|||
}
|
||||
glPopMatrix();
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
GLuint blurTexture;
|
||||
GLuint emptyTexture() // Create An Empty Texture
|
||||
{
|
||||
GLuint txtnumber; // Texture ID
|
||||
unsigned int* data; // Stored Data
|
||||
|
||||
// Create Storage Space For Texture Data (128x128x4)
|
||||
data = (unsigned int*)new GLuint[((128 * 128)* 4 * sizeof(unsigned int))];
|
||||
ZeroMemory(data,((128 * 128)* 4 * sizeof(unsigned int))); // Clear Storage Memory
|
||||
|
||||
glGenTextures(1, &txtnumber); // Create 1 Texture
|
||||
glBindTexture(GL_TEXTURE_2D, txtnumber); // Bind The Texture
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, 4, 128, 128, 0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, data); // Build Texture Using Information In data
|
||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
|
||||
|
||||
delete [] data; // Release data
|
||||
|
||||
return txtnumber; // Return The Texture ID
|
||||
}
|
||||
|
||||
PostProcessingFX::PostProcessingFX()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void PostProcessingFX::init(FXTypes type)
|
||||
{
|
||||
if (type == FXT_RADIALBLUR)
|
||||
{
|
||||
blurTexture = emptyTexture();
|
||||
}
|
||||
enabled[(int)type] = true;
|
||||
}
|
||||
|
||||
void PostProcessingFX::shutdown(FXTypes type)
|
||||
{
|
||||
enabled[int(type)] = false;
|
||||
}
|
||||
|
||||
void PostProcessingFX::preRender()
|
||||
{
|
||||
for (int i = 0; i < FXT_MAX; i++)
|
||||
{
|
||||
if (enabled[i])
|
||||
{
|
||||
FXTType type = (FXType)i;
|
||||
switch(type)
|
||||
{
|
||||
case FXT_RADIALBLUR:
|
||||
glViewport(0,0,128,128); // Set Our Viewport (Match Texture Size;
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And Depth Buffer
|
||||
core->render();
|
||||
glBindTexture(GL_TEXTURE_2D,BlurTexture); // Bind To The Blur Texture
|
||||
|
||||
// Copy Our ViewPort To The Blur Texture (From 0,0 To 128,128... No Border)
|
||||
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 0, 0, 128, 128, 0);
|
||||
|
||||
glClearColor(0.0f, 0.0f, 0.5f, 0.5); // Set The Clear Color To Medium Blue
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And Depth Buffer
|
||||
|
||||
glViewport(0, 0, 800, 600);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PostProcessingFX::render()
|
||||
{
|
||||
for (int i = 0; i < FXT_MAX; i++)
|
||||
{
|
||||
if (enabled[i])
|
||||
{
|
||||
FXTType type = (FXType)i;
|
||||
switch(type)
|
||||
{
|
||||
case FXT_RADIALBLUR:
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
glEnd();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
};
|
||||
|
|
|
@ -37,7 +37,7 @@ void Emitter::destroy()
|
|||
}
|
||||
particles.clear();
|
||||
Quad::destroy();
|
||||
//particleManager->setFree(firstFree);
|
||||
|
||||
}
|
||||
|
||||
void Emitter::spawnParticle(float perc)
|
||||
|
@ -46,7 +46,7 @@ void Emitter::spawnParticle(float perc)
|
|||
Particle *p = particleManager->getFreeParticle(this);
|
||||
|
||||
p->active = true;
|
||||
|
||||
|
||||
p->life = data.life;
|
||||
setBlendType(data.blendType);
|
||||
|
||||
|
@ -105,14 +105,7 @@ void Emitter::spawnParticle(float perc)
|
|||
p->rot.data->target.z += p->rot.z;
|
||||
}
|
||||
|
||||
/*
|
||||
if (data.calculateVelocityToCenter)
|
||||
{
|
||||
Vector pos = p->position - this->position;
|
||||
pos.setLength2D(1);
|
||||
quad->velocity = -p*particles[i].velocityMagnitude.x;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
if (data.randomVelocityMagnitude > 0)
|
||||
{
|
||||
|
@ -137,13 +130,8 @@ Vector Emitter::getSpawnPosition()
|
|||
void Emitter::onUpdate(float dt)
|
||||
{
|
||||
Quad::onUpdate(dt);
|
||||
|
||||
/*
|
||||
for (Particles::iterator i = particles.begin(); i != particles.end(); i++)
|
||||
{
|
||||
particleManager->updateParticle(*i, dt);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
if (pe->isRunning() && core->particlesPaused <= data.pauseLevel)
|
||||
{
|
||||
|
@ -232,16 +220,7 @@ void Emitter::removeParticle(Particle *p)
|
|||
}
|
||||
else
|
||||
particles.remove(p);
|
||||
/*
|
||||
for (Particles::reverse_iterator i = particles.rbegin(); i != particles.rend(); i++)
|
||||
{
|
||||
if (*i == p)
|
||||
{
|
||||
particles.erase(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
void Emitter::render()
|
||||
|
@ -257,20 +236,8 @@ void Emitter::onRender()
|
|||
|
||||
if (!data.spawnLocal)
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
glLoadIdentity();
|
||||
#endif
|
||||
/*
|
||||
if (pe && pe->followCamera)
|
||||
{
|
||||
glLoadIdentity();
|
||||
glScalef(core->globalResolutionScale.x, core->globalResolutionScale.y,0);
|
||||
}
|
||||
else
|
||||
{
|
||||
core->setupRenderPositionAndScale();
|
||||
}
|
||||
*/
|
||||
|
||||
core->setupRenderPositionAndScale();
|
||||
}
|
||||
|
||||
|
@ -294,32 +261,26 @@ void Emitter::onRender()
|
|||
const float dx = w2 * p->scale.x;
|
||||
const float dy = h2 * p->scale.y;
|
||||
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
Vector col = p->color * colorMult;
|
||||
glColor4f(col.x, col.y, col.z, p->alpha.x * alphaMult);
|
||||
|
||||
|
||||
|
||||
if (p->rot.z != 0 || p->rot.isInterpolating())
|
||||
{
|
||||
glPushMatrix();
|
||||
|
||||
|
||||
glTranslatef(p->pos.x, p->pos.y,0);
|
||||
|
||||
glRotatef(p->rot.z, 0, 0, 1);
|
||||
|
||||
if (data.flipH || (data.copyParentFlip && (pe->isfh() || (pe->getParent() && pe->getParent()->isfh()))))
|
||||
{
|
||||
//glDisable(GL_CULL_FACE);
|
||||
|
||||
glRotatef(180, 0, 1, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
if (data.flipV || (data.copyParentFlip && (this->isfv() || (parent && parent->isfv()))))
|
||||
{
|
||||
glDisable(GL_CULL_FACE);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0,1);
|
||||
glVertex2f(-dx, +dy);
|
||||
|
@ -329,7 +290,7 @@ void Emitter::onRender()
|
|||
|
||||
glTexCoord2f(1,0);
|
||||
glVertex2f(+dx, -dy);
|
||||
|
||||
|
||||
glTexCoord2f(0,0);
|
||||
glVertex2f(-dx, -dy);
|
||||
glEnd();
|
||||
|
@ -350,18 +311,16 @@ void Emitter::onRender()
|
|||
|
||||
glTexCoord2f(1,0);
|
||||
glVertex2f(x+dx, y-dy);
|
||||
|
||||
|
||||
glTexCoord2f(0,0);
|
||||
glVertex2f(x-dx, y-dy);
|
||||
glEnd();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
glBegin(GL_QUADS);
|
||||
for (Particles::iterator i = particles.begin(); i != particles.end(); i++)
|
||||
{
|
||||
|
@ -374,7 +333,7 @@ void Emitter::onRender()
|
|||
const float dy = h2 * p->scale.y;
|
||||
|
||||
glColor4f(p->color.x, p->color.y, p->color.z, p->alpha.x);
|
||||
|
||||
|
||||
glTexCoord2f(0,1);
|
||||
glVertex2f(x-dx, y+dy);
|
||||
|
||||
|
@ -383,34 +342,14 @@ void Emitter::onRender()
|
|||
|
||||
glTexCoord2f(1,0);
|
||||
glVertex2f(x+dx, y-dy);
|
||||
|
||||
|
||||
glTexCoord2f(0,0);
|
||||
glVertex2f(x-dx, y-dy);
|
||||
}
|
||||
}
|
||||
glEnd();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glPointSize(4);
|
||||
glBegin(GL_POINTS);
|
||||
|
||||
for (Particles::iterator i = particles.begin(); i != particles.end(); i++)
|
||||
{
|
||||
Particle *p = *i;
|
||||
if (p->active)
|
||||
{
|
||||
glColor4f(1, 0, 0, 1);
|
||||
x = p->pos.x;
|
||||
y = p->pos.y;
|
||||
glVertex2f(x, y);
|
||||
}
|
||||
}
|
||||
glEnd();
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
*/
|
||||
}
|
||||
|
|
|
@ -221,7 +221,7 @@ void Timer::update(float dt)
|
|||
}
|
||||
break;
|
||||
case 2:
|
||||
timer += dt;
|
||||
timer += dt;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -239,5 +239,5 @@ float Timer::getValue()
|
|||
{
|
||||
return timer;
|
||||
}
|
||||
//EventPtr endEvent, startEvent;
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
@ -80,7 +80,7 @@ enum EventManage
|
|||
{
|
||||
EVM_NONE = 0,
|
||||
EVM_CLEANUP = 1,
|
||||
EVM_MAX
|
||||
EVM_MAX
|
||||
};
|
||||
|
||||
class ActionMapper;
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "FileVars.h"
|
||||
|
||||
FileVars::FileVars()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void FileVars::load(const std::string &absPath)
|
||||
{
|
||||
std::string vname;
|
||||
std::ifstream in(absPath.c_str());
|
||||
while (in >> vname)
|
||||
{
|
||||
std::string val;
|
||||
in >> val;
|
||||
if (val.find('.') != std::string::npos)
|
||||
{
|
||||
std::istringstream is(val);
|
||||
is >> floats[vname];
|
||||
}
|
||||
else
|
||||
{
|
||||
std::istringstream is(val);
|
||||
is >> ints[vname];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float FileVars::f(const std::string &vname)
|
||||
{
|
||||
return floats[vname];
|
||||
}
|
||||
|
||||
int FileVars::i(const std::string &vname)
|
||||
{
|
||||
return ints[vname];
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef FILEVARS_H
|
||||
#define FILEVARS_H
|
||||
|
||||
#include "Base.h"
|
||||
|
||||
|
||||
class FileVars
|
||||
{
|
||||
public:
|
||||
FileVars();
|
||||
void load(const std::string &absPath);
|
||||
float f(const std::string &vname);
|
||||
int i(const std::string &vname);
|
||||
protected:
|
||||
std::map<std::string,float> floats;
|
||||
std::map<std::string, int> ints;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "Core.h"
|
||||
|
||||
Flags::Flags()
|
||||
{
|
||||
flags = 0;
|
||||
}
|
||||
|
||||
void Flags::set(uint32 flag)
|
||||
{
|
||||
flags |= flag;
|
||||
}
|
||||
|
||||
void Flags::unset(uint32 flag)
|
||||
{
|
||||
flags &= ~flag;
|
||||
}
|
||||
|
||||
bool Flags::get(uint32 flag)
|
||||
{
|
||||
return (flags & flag);
|
||||
}
|
||||
|
||||
void Flags::toggle(uint32 flag)
|
||||
{
|
||||
flags ^= flag;
|
||||
}
|
48
BBGE/Flags.h
48
BBGE/Flags.h
|
@ -1,48 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef BBGE_FLAGS_H
|
||||
#define BBGE_FLAGS_H
|
||||
|
||||
#ifdef BBGE_BUILD_WINDOWS
|
||||
typedef unsigned __int32 uint32;
|
||||
#endif
|
||||
#ifdef BBGE_BUILD_UNIX
|
||||
#include <stdint.h>
|
||||
typedef uint32_t uint32;
|
||||
#endif
|
||||
#ifdef BBGE_BUILD_X360
|
||||
typedef unsigned int uint32;
|
||||
#endif
|
||||
|
||||
class Flags
|
||||
{
|
||||
public:
|
||||
Flags();
|
||||
void set(uint32 flag);
|
||||
void unset(uint32 flag);
|
||||
void toggle(uint32 flag);
|
||||
bool get(uint32 flag);
|
||||
uint32 getValue() { return flags; }
|
||||
|
||||
uint32 flags;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -139,17 +139,11 @@ private:
|
|||
bool stopped; // true if enqueued deletion
|
||||
unsigned int samples_done; // Number of samples played and dequeued
|
||||
|
||||
#ifdef BBGE_BUILD_SDL
|
||||
static SDL_Thread *decoderThread;
|
||||
static LockedQueue<OggDecoder*> decoderQ;
|
||||
static volatile bool stop_thread;
|
||||
static std::list<OggDecoder*> decoderList; // used by decoder thread only
|
||||
|
||||
#else
|
||||
#warning Threads not supported, music may cut out on area changes!
|
||||
// ... because the stream runs out of decoded data while the area is
|
||||
// still loading, so OpenAL aborts playback.
|
||||
#endif
|
||||
|
||||
static void detachDecoder(OggDecoder *);
|
||||
};
|
||||
|
@ -181,16 +175,13 @@ static const ov_callbacks ogg_memory_callbacks = {
|
|||
OggDecoder::mem_tell
|
||||
};
|
||||
|
||||
#ifdef BBGE_BUILD_SDL
|
||||
SDL_Thread *OggDecoder::decoderThread = NULL;
|
||||
LockedQueue<OggDecoder*> OggDecoder::decoderQ;
|
||||
volatile bool OggDecoder::stop_thread;
|
||||
std::list<OggDecoder*> OggDecoder::decoderList;
|
||||
#endif
|
||||
|
||||
void OggDecoder::startDecoderThread()
|
||||
{
|
||||
#ifdef BBGE_BUILD_SDL
|
||||
stop_thread = false;
|
||||
#ifdef BBGE_BUILD_SDL2
|
||||
decoderThread = SDL_CreateThread((int (*)(void *))decode_loop, "OggDecoder", NULL);
|
||||
|
@ -202,12 +193,10 @@ void OggDecoder::startDecoderThread()
|
|||
debugLog("Failed to create Ogg Vorbis decode thread: "
|
||||
+ std::string(SDL_GetError()));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void OggDecoder::stopDecoderThread()
|
||||
{
|
||||
#ifdef BBGE_BUILD_SDL
|
||||
if (decoderThread)
|
||||
{
|
||||
stop_thread = true;
|
||||
|
@ -215,27 +204,22 @@ void OggDecoder::stopDecoderThread()
|
|||
SDL_WaitThread(decoderThread, NULL);
|
||||
decoderThread = NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void OggDecoder::detachDecoder(OggDecoder *ogg)
|
||||
{
|
||||
#ifdef BBGE_BUILD_SDL
|
||||
if(decoderThread)
|
||||
{
|
||||
ogg->thread = true;
|
||||
decoderQ.push(ogg);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void OggDecoder::decode_loop(OggDecoder *this_)
|
||||
{
|
||||
while (!this_->stop_thread)
|
||||
{
|
||||
#ifdef BBGE_BUILD_SDL
|
||||
SDL_Delay(10);
|
||||
#endif
|
||||
// Transfer decoder to this background thread
|
||||
OggDecoder *ogg;
|
||||
while(decoderQ.pop(ogg))
|
||||
|
@ -371,7 +355,7 @@ bool OggDecoder::preStart(ALuint source)
|
|||
/* NOTE: The failure to use alGetError() here and elsewhere is
|
||||
* intentional -- since alGetError() writes to a global buffer and
|
||||
* is thus not thread-safe, we can't use it either in the decoding
|
||||
* threads _or_ here in the main thread. In this case, we rely on
|
||||
* threads _or_ here in the main thread. In this case, we rely on
|
||||
* the specification that failing OpenAL calls do not modify return
|
||||
* parameters to detect failure; for functions that do not return
|
||||
* values, we have no choice but to hope for the best. (From a
|
||||
|
@ -1298,7 +1282,6 @@ void OpenALChannel::setSound(OpenALSound *_sound)
|
|||
|
||||
|
||||
|
||||
|
||||
// FMOD::System implementation ...
|
||||
|
||||
class OpenALSystem
|
||||
|
|
|
@ -24,7 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
//WARNING: FrameBuffer objects have to have reloadDevice/unloadDevice called manually!
|
||||
|
||||
#ifdef BBGE_BUILD_FRAMEBUFFER
|
||||
#if defined(BBGE_BUILD_OPENGL)
|
||||
PFNGLISRENDERBUFFEREXTPROC glIsRenderbufferEXT = NULL;
|
||||
PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT = NULL;
|
||||
PFNGLDELETERENDERBUFFERSEXTPROC glDeleteRenderbuffersEXT = NULL;
|
||||
|
@ -43,7 +42,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC glGetFramebufferAttachmentParameterivEXT = NULL;
|
||||
PFNGLGENERATEMIPMAPEXTPROC glGenerateMipmapEXT = NULL;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
FrameBuffer::FrameBuffer()
|
||||
{
|
||||
|
@ -85,7 +83,7 @@ bool FrameBuffer::init(int width, int height, bool fitToScreen, GLint filter)
|
|||
std::ostringstream oss;
|
||||
oss << "Vendor: [" << glGetString(GL_VENDOR) << "] Renderer: [" << glGetString(GL_RENDERER) << "]";
|
||||
debugLog(oss.str());
|
||||
|
||||
|
||||
std::string renderer = (const char*)glGetString(GL_RENDERER);
|
||||
if (renderer.find("Intel GMA 950") != std::string::npos)
|
||||
{
|
||||
|
@ -94,7 +92,7 @@ bool FrameBuffer::init(int width, int height, bool fitToScreen, GLint filter)
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef BBGE_BUILD_FRAMEBUFFER
|
||||
|
||||
_w = width;
|
||||
|
@ -115,15 +113,11 @@ bool FrameBuffer::init(int width, int height, bool fitToScreen, GLint filter)
|
|||
_fitToScreen = fitToScreen;
|
||||
if (width == 0 || height == 0)
|
||||
return false;
|
||||
/*
|
||||
if (width > height)
|
||||
height = width;
|
||||
*/
|
||||
|
||||
|
||||
w=width;
|
||||
h=height;
|
||||
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
char *ext = (char*)glGetString( GL_EXTENSIONS );
|
||||
|
||||
std::ostringstream os;
|
||||
|
@ -137,7 +131,6 @@ bool FrameBuffer::init(int width, int height, bool fitToScreen, GLint filter)
|
|||
}
|
||||
else
|
||||
{
|
||||
#if defined(BBGE_BUILD_SDL)
|
||||
if (!glIsRenderbufferEXT)
|
||||
{
|
||||
glIsRenderbufferEXT = (PFNGLISRENDERBUFFEREXTPROC)SDL_GL_GetProcAddress("glIsRenderbufferEXT");
|
||||
|
@ -158,7 +151,6 @@ bool FrameBuffer::init(int width, int height, bool fitToScreen, GLint filter)
|
|||
glGetFramebufferAttachmentParameterivEXT = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC)SDL_GL_GetProcAddress("glGetFramebufferAttachmentParameterivEXT");
|
||||
glGenerateMipmapEXT = (PFNGLGENERATEMIPMAPEXTPROC)SDL_GL_GetProcAddress("glGenerateMipmapEXT");
|
||||
}
|
||||
#endif
|
||||
|
||||
if( !glIsRenderbufferEXT || !glBindRenderbufferEXT || !glDeleteRenderbuffersEXT ||
|
||||
!glGenRenderbuffersEXT || !glRenderbufferStorageEXT || !glGetRenderbufferParameterivEXT ||
|
||||
|
@ -218,8 +210,7 @@ bool FrameBuffer::init(int width, int height, bool fitToScreen, GLint filter)
|
|||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
#endif
|
||||
|
||||
debugLog("Done");
|
||||
inited = true;
|
||||
enabled = true;
|
||||
|
@ -237,7 +228,6 @@ void FrameBuffer::unloadDevice()
|
|||
#ifdef BBGE_BUILD_FRAMEBUFFER
|
||||
|
||||
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
|
||||
if (glDeleteFramebuffersEXT == NULL)
|
||||
{
|
||||
|
@ -274,13 +264,11 @@ void FrameBuffer::unloadDevice()
|
|||
glDeleteRenderbuffersEXT(1, &g_depthRenderBuffer);
|
||||
g_depthRenderBuffer = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
debugLog("done");
|
||||
}
|
||||
|
||||
#if defined(BBGE_BUILD_SDL)
|
||||
void FrameBuffer::resetOpenGL()
|
||||
{
|
||||
#if defined(BBGE_BUILD_FRAMEBUFFER)
|
||||
|
@ -305,7 +293,6 @@ void FrameBuffer::resetOpenGL()
|
|||
glGenerateMipmapEXT = NULL;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
void FrameBuffer::reloadDevice()
|
||||
{
|
||||
|
@ -317,15 +304,13 @@ void FrameBuffer::startCapture()
|
|||
{
|
||||
#ifdef BBGE_BUILD_FRAMEBUFFER
|
||||
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, g_frameBuffer );
|
||||
//glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, g_depthRenderBuffer );
|
||||
|
||||
glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, g_dynamicTextureID, 0 );
|
||||
glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, g_depthRenderBuffer );
|
||||
|
||||
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
|
@ -334,9 +319,7 @@ void FrameBuffer::endCapture()
|
|||
{
|
||||
#ifdef BBGE_BUILD_FRAMEBUFFER
|
||||
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 );
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
|
@ -345,9 +328,7 @@ void FrameBuffer::bindTexture()
|
|||
{
|
||||
#ifdef BBGE_BUILD_FRAMEBUFFER
|
||||
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
glBindTexture( GL_TEXTURE_2D, g_dynamicTextureID );
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
class FrameBuffer
|
||||
{
|
||||
public:
|
||||
FrameBuffer();
|
||||
FrameBuffer();
|
||||
~FrameBuffer();
|
||||
bool init(int width, int height, bool fitToScreen=false, GLint filter=GL_LINEAR);
|
||||
bool isInited() { return inited; }
|
||||
|
@ -40,13 +40,11 @@ public:
|
|||
int getHeight() { return h; }
|
||||
float getWidthP();
|
||||
float getHeightP();
|
||||
|
||||
|
||||
void unloadDevice();
|
||||
void reloadDevice();
|
||||
|
||||
#if defined(BBGE_BUILD_SDL)
|
||||
static void resetOpenGL();
|
||||
#endif
|
||||
|
||||
protected:
|
||||
int _w, _h;
|
||||
|
|
249
BBGE/GL/gl.h
249
BBGE/GL/gl.h
|
@ -8,20 +8,20 @@ extern "C" {
|
|||
/*
|
||||
** Copyright 1998-2002, NVIDIA Corporation.
|
||||
** All Rights Reserved.
|
||||
**
|
||||
**
|
||||
** THE INFORMATION CONTAINED HEREIN IS PROPRIETARY AND CONFIDENTIAL TO
|
||||
** NVIDIA, CORPORATION. USE, REPRODUCTION OR DISCLOSURE TO ANY THIRD PARTY
|
||||
** IS SUBJECT TO WRITTEN PRE-APPROVAL BY NVIDIA, CORPORATION.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** Copyright 1992-1999, Silicon Graphics, Inc.
|
||||
** All Rights Reserved.
|
||||
**
|
||||
**
|
||||
** Portions of this file are UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon
|
||||
** Graphics, Inc.; the contents of this file may not be disclosed to third
|
||||
** parties, copied or duplicated in any form, in whole or in part, without
|
||||
** the prior written permission of Silicon Graphics, Inc.
|
||||
**
|
||||
**
|
||||
** RESTRICTED RIGHTS LEGEND:
|
||||
** Use, duplication or disclosure by the Government is subject to
|
||||
** restrictions as set forth in subdivision (c)(1)(ii) of the Rights in
|
||||
|
@ -44,9 +44,7 @@ extern "C" {
|
|||
#undef WINGDIAPI
|
||||
#define WINGDIAPI extern
|
||||
|
||||
/*#ifndef WIN32
|
||||
#define WINGDIAPI
|
||||
#endif*/
|
||||
|
||||
|
||||
#ifndef GLAPI
|
||||
# ifdef _WIN32
|
||||
|
@ -104,13 +102,13 @@ typedef void GLvoid;
|
|||
#define GL_SCISSOR_BIT 0x00080000
|
||||
#define GL_ALL_ATTRIB_BITS 0xFFFFFFFF
|
||||
|
||||
/* ClearBufferMask */
|
||||
/* GL_COLOR_BUFFER_BIT */
|
||||
/* GL_ACCUM_BUFFER_BIT */
|
||||
/* GL_STENCIL_BUFFER_BIT */
|
||||
/* GL_DEPTH_BUFFER_BIT */
|
||||
|
||||
/* ClientAttribMask */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define GL_CLIENT_PIXEL_STORE_BIT 0x00000001
|
||||
#define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002
|
||||
#define GL_CLIENT_ALL_ATTRIB_BITS 0xFFFFFFFF
|
||||
|
@ -158,55 +156,55 @@ typedef void GLvoid;
|
|||
#define GL_DST_ALPHA 0x0304
|
||||
#define GL_ONE_MINUS_DST_ALPHA 0x0305
|
||||
|
||||
/* BlendingFactorSrc */
|
||||
/* GL_ZERO */
|
||||
/* GL_ONE */
|
||||
|
||||
|
||||
|
||||
#define GL_DST_COLOR 0x0306
|
||||
#define GL_ONE_MINUS_DST_COLOR 0x0307
|
||||
#define GL_SRC_ALPHA_SATURATE 0x0308
|
||||
/* GL_SRC_ALPHA */
|
||||
/* GL_ONE_MINUS_SRC_ALPHA */
|
||||
/* GL_DST_ALPHA */
|
||||
/* GL_ONE_MINUS_DST_ALPHA */
|
||||
|
||||
/* ColorMaterialFace */
|
||||
/* GL_FRONT */
|
||||
/* GL_BACK */
|
||||
/* GL_FRONT_AND_BACK */
|
||||
|
||||
/* ColorMaterialParameter */
|
||||
/* GL_AMBIENT */
|
||||
/* GL_DIFFUSE */
|
||||
/* GL_SPECULAR */
|
||||
/* GL_EMISSION */
|
||||
/* GL_AMBIENT_AND_DIFFUSE */
|
||||
|
||||
/* ColorPointerType */
|
||||
/* GL_BYTE */
|
||||
/* GL_UNSIGNED_BYTE */
|
||||
/* GL_SHORT */
|
||||
/* GL_UNSIGNED_SHORT */
|
||||
/* GL_INT */
|
||||
/* GL_UNSIGNED_INT */
|
||||
/* GL_FLOAT */
|
||||
/* GL_DOUBLE */
|
||||
|
||||
/* CullFaceMode */
|
||||
/* GL_FRONT */
|
||||
/* GL_BACK */
|
||||
/* GL_FRONT_AND_BACK */
|
||||
|
||||
/* DepthFunction */
|
||||
/* GL_NEVER */
|
||||
/* GL_LESS */
|
||||
/* GL_EQUAL */
|
||||
/* GL_LEQUAL */
|
||||
/* GL_GREATER */
|
||||
/* GL_NOTEQUAL */
|
||||
/* GL_GEQUAL */
|
||||
/* GL_ALWAYS */
|
||||
|
||||
/* DrawBufferMode */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define GL_NONE 0
|
||||
#define GL_FRONT_LEFT 0x0400
|
||||
#define GL_FRONT_RIGHT 0x0401
|
||||
|
@ -222,75 +220,75 @@ typedef void GLvoid;
|
|||
#define GL_AUX2 0x040B
|
||||
#define GL_AUX3 0x040C
|
||||
|
||||
/* EnableCap */
|
||||
/* GL_FOG */
|
||||
/* GL_LIGHTING */
|
||||
/* GL_TEXTURE_1D */
|
||||
/* GL_TEXTURE_2D */
|
||||
/* GL_LINE_STIPPLE */
|
||||
/* GL_POLYGON_STIPPLE */
|
||||
/* GL_CULL_FACE */
|
||||
/* GL_ALPHA_TEST */
|
||||
/* GL_BLEND */
|
||||
/* GL_INDEX_LOGIC_OP */
|
||||
/* GL_COLOR_LOGIC_OP */
|
||||
/* GL_DITHER */
|
||||
/* GL_STENCIL_TEST */
|
||||
/* GL_DEPTH_TEST */
|
||||
/* GL_CLIP_PLANE0 */
|
||||
/* GL_CLIP_PLANE1 */
|
||||
/* GL_CLIP_PLANE2 */
|
||||
/* GL_CLIP_PLANE3 */
|
||||
/* GL_CLIP_PLANE4 */
|
||||
/* GL_CLIP_PLANE5 */
|
||||
/* GL_LIGHT0 */
|
||||
/* GL_LIGHT1 */
|
||||
/* GL_LIGHT2 */
|
||||
/* GL_LIGHT3 */
|
||||
/* GL_LIGHT4 */
|
||||
/* GL_LIGHT5 */
|
||||
/* GL_LIGHT6 */
|
||||
/* GL_LIGHT7 */
|
||||
/* GL_TEXTURE_GEN_S */
|
||||
/* GL_TEXTURE_GEN_T */
|
||||
/* GL_TEXTURE_GEN_R */
|
||||
/* GL_TEXTURE_GEN_Q */
|
||||
/* GL_MAP1_VERTEX_3 */
|
||||
/* GL_MAP1_VERTEX_4 */
|
||||
/* GL_MAP1_COLOR_4 */
|
||||
/* GL_MAP1_INDEX */
|
||||
/* GL_MAP1_NORMAL */
|
||||
/* GL_MAP1_TEXTURE_COORD_1 */
|
||||
/* GL_MAP1_TEXTURE_COORD_2 */
|
||||
/* GL_MAP1_TEXTURE_COORD_3 */
|
||||
/* GL_MAP1_TEXTURE_COORD_4 */
|
||||
/* GL_MAP2_VERTEX_3 */
|
||||
/* GL_MAP2_VERTEX_4 */
|
||||
/* GL_MAP2_COLOR_4 */
|
||||
/* GL_MAP2_INDEX */
|
||||
/* GL_MAP2_NORMAL */
|
||||
/* GL_MAP2_TEXTURE_COORD_1 */
|
||||
/* GL_MAP2_TEXTURE_COORD_2 */
|
||||
/* GL_MAP2_TEXTURE_COORD_3 */
|
||||
/* GL_MAP2_TEXTURE_COORD_4 */
|
||||
/* GL_POINT_SMOOTH */
|
||||
/* GL_LINE_SMOOTH */
|
||||
/* GL_POLYGON_SMOOTH */
|
||||
/* GL_SCISSOR_TEST */
|
||||
/* GL_COLOR_MATERIAL */
|
||||
/* GL_NORMALIZE */
|
||||
/* GL_AUTO_NORMAL */
|
||||
/* GL_POLYGON_OFFSET_POINT */
|
||||
/* GL_POLYGON_OFFSET_LINE */
|
||||
/* GL_POLYGON_OFFSET_FILL */
|
||||
/* GL_VERTEX_ARRAY */
|
||||
/* GL_NORMAL_ARRAY */
|
||||
/* GL_COLOR_ARRAY */
|
||||
/* GL_INDEX_ARRAY */
|
||||
/* GL_TEXTURE_COORD_ARRAY */
|
||||
/* GL_EDGE_FLAG_ARRAY */
|
||||
|
||||
/* ErrorCode */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define GL_NO_ERROR 0
|
||||
#define GL_INVALID_ENUM 0x0500
|
||||
#define GL_INVALID_VALUE 0x0501
|
||||
|
@ -317,8 +315,8 @@ typedef void GLvoid;
|
|||
#define GL_COPY_PIXEL_TOKEN 0x0706
|
||||
#define GL_LINE_RESET_TOKEN 0x0707
|
||||
|
||||
/* FogMode */
|
||||
/* GL_LINEAR */
|
||||
|
||||
|
||||
#define GL_EXP 0x0800
|
||||
#define GL_EXP2 0x0801
|
||||
|
||||
|
@ -1635,9 +1633,6 @@ WINGDIAPI void APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei hei
|
|||
# undef __DEFINED_GLAPI
|
||||
#endif
|
||||
|
||||
#ifndef GL_GLEXT_LEGACY
|
||||
#include <GL/glext.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -11,13 +11,13 @@ extern "C" {
|
|||
|
||||
TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED
|
||||
*AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
|
||||
NVIDIA OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR
|
||||
CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR
|
||||
LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION,
|
||||
OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE
|
||||
THIS SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
|
||||
NVIDIA OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR
|
||||
CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR
|
||||
LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION,
|
||||
OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE
|
||||
THIS SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
******************************************************************************/
|
||||
|
@ -30,21 +30,21 @@ extern "C" {
|
|||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2004 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
**
|
||||
** Additional Notice Provisions: This software was created using the
|
||||
** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has
|
||||
** not been independently verified as being compliant with the OpenGL(R)
|
||||
|
@ -3335,7 +3335,7 @@ extern "C" {
|
|||
#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA
|
||||
#endif
|
||||
|
||||
#ifndef GL_EXT_texture_compression_rgtc
|
||||
#ifndef GL_EXT_texture_compression_rgtc
|
||||
#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB
|
||||
#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC
|
||||
#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD
|
||||
|
|
|
@ -59,47 +59,26 @@ void Gradient::makeHorizontal(Vector c1, Vector c2)
|
|||
|
||||
void Gradient::onRender()
|
||||
{
|
||||
#ifdef BBGE_BUILD_DIRECTX
|
||||
core->blitD3DGradient
|
||||
( ulc0.getD3DColor(alpha.x),
|
||||
ulc1.getD3DColor(alpha.x),
|
||||
ulc2.getD3DColor(alpha.x),
|
||||
ulc3.getD3DColor(alpha.x));
|
||||
#endif
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
//glNormal3f(0, 0, 1);
|
||||
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
//glNormal3f(0, 0, 1);
|
||||
|
||||
|
||||
glColor4f(ulc2.x*color.x, ulc2.y*color.y, ulc2.z*color.z, alpha.x);
|
||||
glVertex3f(-0.5, 0.5, 0.0f);
|
||||
|
||||
// 2
|
||||
|
||||
glColor4f(ulc3.x*color.x, ulc3.y*color.y, ulc3.z*color.z, alpha.x);
|
||||
glVertex3f( 0.5, 0.5, 0.0f);
|
||||
|
||||
// 3
|
||||
|
||||
glColor4f(ulc0.x*color.x, ulc0.y*color.y, ulc0.z*color.z, alpha.x);
|
||||
glVertex3f( 0.5, -0.5, 0.0f);
|
||||
|
||||
// 4
|
||||
glColor4f(ulc1.x*color.x, ulc1.y*color.y, ulc1.z*color.z, alpha.x);
|
||||
|
||||
glColor4f(ulc1.x*color.x, ulc1.y*color.y, ulc1.z*color.z, alpha.x);
|
||||
glVertex3f(-0.5, -0.5, 0.0f);
|
||||
/*
|
||||
glColor3f(ulc0.x, ulc0.y, ulc0.z);
|
||||
glVertex3f(-0.5, -0.5, 0);
|
||||
|
||||
glColor3f(ulc1.x, ulc1.y, ulc1.z);
|
||||
glVertex3f(0.5, -0.5, 0);
|
||||
|
||||
glColor3f(ulc2.x, ulc2.y, ulc2.z);
|
||||
glVertex3f(0.5, 0.5, 0);
|
||||
|
||||
glColor3f(ulc3.x, ulc3.y, ulc3.z);
|
||||
glVertex3f(-0.5, 0.5, 0);
|
||||
*/
|
||||
glEnd();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -1,161 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "Interpolator.h"
|
||||
|
||||
void Interpolator::stop ()
|
||||
{
|
||||
interpolating = false;
|
||||
}
|
||||
|
||||
void Interpolator::setUpdatee (float *u)
|
||||
{
|
||||
updatee = u;
|
||||
}
|
||||
|
||||
void Interpolator::interpolateTo (float interTo, float time, int ltype)
|
||||
{
|
||||
if (!updatee)
|
||||
{
|
||||
errorLog ("No updatee set for interpolator!");
|
||||
return;
|
||||
}
|
||||
|
||||
loopType = ltype;
|
||||
to = interTo;
|
||||
timePeriod = time;
|
||||
from = *updatee;
|
||||
interpolating = true;
|
||||
timePassed = 0.0f;
|
||||
fakeTimePassed = 0.0f;
|
||||
useSpeed = false;
|
||||
}
|
||||
|
||||
void Interpolator::interpolateBySpeed (float interTo, float speed, int ltype)
|
||||
{
|
||||
this->speed = speed;
|
||||
loopType = ltype;
|
||||
to = interTo;
|
||||
from = *updatee;
|
||||
timePassed = 0.0f;
|
||||
useSpeed = false;
|
||||
timePeriod = fabsf(to-from) / speed;
|
||||
|
||||
interpolating = true;
|
||||
}
|
||||
|
||||
void Interpolator::setSpeed (float s)
|
||||
{
|
||||
useSpeed = true;
|
||||
interpolating = true;
|
||||
speed = s;
|
||||
}
|
||||
|
||||
void Interpolator::update (float dt)
|
||||
{
|
||||
|
||||
if (interpolating)
|
||||
{
|
||||
if (initialDelay > 0)
|
||||
{
|
||||
initialDelay -= dt;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!useSpeed)
|
||||
{
|
||||
timePassed += dt*timeMultiplier;
|
||||
if (timePassed >= timePeriod)
|
||||
{
|
||||
*updatee = to;
|
||||
interpolating = false;
|
||||
if (loopType != 0)
|
||||
{
|
||||
if (loopType > 0)
|
||||
loopType -= 1;
|
||||
if (pingPong)
|
||||
interpolateTo (from, timePeriod, loopType);
|
||||
else
|
||||
{
|
||||
*updatee = from;
|
||||
interpolateTo (to, timePeriod, loopType);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*updatee = (to - from) * (timePassed / timePeriod);
|
||||
*updatee += from;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*updatee += speed * dt;
|
||||
if(*updatee > 255) *updatee = 0;
|
||||
if(*updatee < 0) *updatee = 255;
|
||||
/*
|
||||
timePassed += speed *dt;
|
||||
|
||||
if (timePassed >= timePeriod)
|
||||
{
|
||||
*updatee = to;
|
||||
interpolating = false;
|
||||
if (loopType != 0)
|
||||
{
|
||||
if (loopType > 0)
|
||||
loopType -= 1;
|
||||
if (pingPong)
|
||||
interpolateTo (from, timePeriod, loopType);
|
||||
else
|
||||
{
|
||||
*updatee = from;
|
||||
interpolateTo (to, timePeriod, loopType);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*updatee = (to - from) * (timePassed / timePeriod);
|
||||
*updatee += from;
|
||||
}
|
||||
*/
|
||||
/*
|
||||
if (updatee >= to)
|
||||
{
|
||||
if (pingPong)
|
||||
{
|
||||
interpolateTo (from, timePeriod, loopType);
|
||||
//if(*updatee > to) *updatee = 0;
|
||||
//if(*updatee < from) *updatee = 255;
|
||||
}
|
||||
else
|
||||
{
|
||||
*updatee = from;
|
||||
interpolateTo (to, timePeriod, loopType);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,69 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef _interpolator_
|
||||
#define _interpolator_
|
||||
|
||||
#include "Base.h"
|
||||
|
||||
class Interpolator;
|
||||
|
||||
class Interpolator
|
||||
{
|
||||
public:
|
||||
Interpolator () : updatee (0), interpolating (false), loopType (0), useSpeed (false), pingPong (false)
|
||||
{
|
||||
initialDelay = 0.0f;
|
||||
timeMultiplier = 1;
|
||||
timePassed=to=speed=from=timePeriod=fakeTimePassed=0;
|
||||
}
|
||||
bool pingPong;
|
||||
void setUpdatee (float *u);
|
||||
void interpolateTo (float interTo, float time, int ltype);
|
||||
void interpolateBySpeed (float interTo, float speed, int ltype);
|
||||
void update (float dt);
|
||||
void setSpeed (float speed);
|
||||
void stop ();
|
||||
float getX2 ()
|
||||
{
|
||||
return (timePassed - timePeriod/2)*(timePassed - timePeriod/2);
|
||||
}
|
||||
|
||||
bool interpolating, useSpeed;
|
||||
int loopType;
|
||||
float timePeriod;
|
||||
float initialDelay;
|
||||
float to;
|
||||
float timeMultiplier;
|
||||
|
||||
EventPtr endOfInterpolationEvent;
|
||||
EventPtr startOfInterpolationEvent;
|
||||
|
||||
private:
|
||||
|
||||
float speed, from, timePassed, fakeTimePassed;
|
||||
float *updatee;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -21,51 +21,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#include "Core.h"
|
||||
|
||||
#if defined(BBGE_BUILD_WINDOWS) && defined(BBGE_BUILD_XINPUT)
|
||||
#include "Xinput.h"
|
||||
|
||||
#if defined(BBGE_BUILD_DELAYXINPUT)
|
||||
#include <DelayImp.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
HRESULT (WINAPI *XInputGetState)(HINSTANCE hinst, DWORD dwVersion, REFIID riidltf, LPVOID *ppvOut, LPUNKNOWN punkOuter) = 0;
|
||||
|
||||
if ( (winp.hInstDI = LoadLibrary( "dinput.dll" )) == 0 )
|
||||
|
||||
|
||||
if (!pDirectInput8Create) {
|
||||
pDirectInput8Create = (HRESULT (__stdcall *)(HINSTANCE, DWORD ,REFIID, LPVOID *, LPUNKNOWN)) GetProcAddress(winp.hInstDI,"DirectInput8Create");
|
||||
|
||||
if (!pDirectInput8Create) {
|
||||
error(L"Couldn't get DI proc addr\n");
|
||||
}
|
||||
}
|
||||
|
||||
bool importXInput()
|
||||
{
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
bool tryXInput()
|
||||
{
|
||||
__try
|
||||
{
|
||||
XINPUT_STATE xinp;
|
||||
XInputGetState(0, &xinp);
|
||||
}
|
||||
__except (EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __LINUX__
|
||||
#include <sys/types.h>
|
||||
|
@ -89,13 +44,11 @@ Joystick::Joystick()
|
|||
{
|
||||
xinited = false;
|
||||
stickIndex = -1;
|
||||
#ifdef BBGE_BUILD_SDL
|
||||
# ifdef BBGE_BUILD_SDL2
|
||||
sdl_controller = NULL;
|
||||
sdl_haptic = NULL;
|
||||
# endif
|
||||
sdl_joy = NULL;
|
||||
#endif
|
||||
#if defined(__LINUX__) && !defined(BBGE_BUILD_SDL2)
|
||||
eventfd = -1;
|
||||
effectid = -1;
|
||||
|
@ -124,11 +77,8 @@ Joystick::Joystick()
|
|||
|
||||
void Joystick::init(int stick)
|
||||
{
|
||||
#if defined(BBGE_BUILD_SDL) || defined(__LINUX__)
|
||||
std::ostringstream os;
|
||||
#endif
|
||||
|
||||
#ifdef BBGE_BUILD_SDL
|
||||
stickIndex = stick;
|
||||
const int numJoy = SDL_NumJoysticks();
|
||||
os << "Found [" << numJoy << "] joysticks";
|
||||
|
@ -184,8 +134,7 @@ void Joystick::init(int stick)
|
|||
{
|
||||
debugLog("Not enough Joystick(s) found");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__LINUX__) && !defined(BBGE_BUILD_SDL2)
|
||||
os.seekp(0);
|
||||
os << "AQUARIA_EVENT_JOYSTICK" << stick;
|
||||
|
@ -223,20 +172,6 @@ void Joystick::init(int stick)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef BBGE_BUILD_XINPUT
|
||||
debugLog("about to init xinput");
|
||||
|
||||
xinited = tryXInput();
|
||||
|
||||
if (!xinited)
|
||||
debugLog("XInput not found, not installed?");
|
||||
|
||||
debugLog("after catch");
|
||||
|
||||
#if !defined(BBGE_BUILD_SDL)
|
||||
inited = xinited;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void Joystick::shutdown()
|
||||
|
@ -250,7 +185,6 @@ void Joystick::shutdown()
|
|||
eventfd = -1;
|
||||
}
|
||||
#endif
|
||||
#ifdef BBGE_BUILD_SDL
|
||||
#ifdef BBGE_BUILD_SDL2
|
||||
if (sdl_haptic)
|
||||
{
|
||||
|
@ -269,7 +203,6 @@ void Joystick::shutdown()
|
|||
SDL_JoystickClose(sdl_joy);
|
||||
sdl_joy = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Joystick::rumble(float leftMotor, float rightMotor, float time)
|
||||
|
@ -292,25 +225,6 @@ void Joystick::rumble(float leftMotor, float rightMotor, float time)
|
|||
}
|
||||
}
|
||||
|
||||
#elif defined(BBGE_BUILD_WINDOWS) && defined(BBGE_BUILD_XINPUT)
|
||||
XINPUT_VIBRATION vib;
|
||||
vib.wLeftMotorSpeed = WORD(leftMotor*65535);
|
||||
vib.wRightMotorSpeed = WORD(rightMotor*65535);
|
||||
|
||||
clearRumbleTime = time;
|
||||
DWORD d = XInputSetState(0, &vib);
|
||||
if (d == ERROR_SUCCESS)
|
||||
{
|
||||
//debugLog("success");
|
||||
}
|
||||
else if (d == ERROR_DEVICE_NOT_CONNECTED)
|
||||
{
|
||||
//debugLog("joystick not connected");
|
||||
}
|
||||
else
|
||||
{
|
||||
//unknown error
|
||||
}
|
||||
#elif defined(__LINUX__)
|
||||
if (eventfd >= 0) {
|
||||
struct ff_effect effect;
|
||||
|
@ -331,24 +245,24 @@ void Joystick::rumble(float leftMotor, float rightMotor, float time)
|
|||
effect.u.rumble.strong_magnitude = (uint16_t) (rightMotor * 0xffff);
|
||||
effect.u.rumble.weak_magnitude = (uint16_t) (leftMotor * 0xffff);
|
||||
}
|
||||
|
||||
|
||||
if (ioctl(eventfd, EVIOCSFF, &effect) == -1) {
|
||||
debugLog(std::string("Upload rumble effect: ") + strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
event.time.tv_sec = 0;
|
||||
event.time.tv_usec = 0;
|
||||
event.type = EV_FF;
|
||||
event.code = effectid = effect.id;
|
||||
|
||||
|
||||
if (leftMotor == 0 && rightMotor == 0) {
|
||||
event.value = 0;
|
||||
}
|
||||
else {
|
||||
event.value = 1;
|
||||
}
|
||||
|
||||
|
||||
if (write(eventfd, (const void*) &event, sizeof(event)) == -1) {
|
||||
debugLog(std::string("Play rumble effect: ") + strerror(errno));
|
||||
}
|
||||
|
@ -359,7 +273,7 @@ void Joystick::rumble(float leftMotor, float rightMotor, float time)
|
|||
|
||||
void Joystick::callibrate(Vector &calvec, float deadZone)
|
||||
{
|
||||
//float len = position.getLength2D();
|
||||
|
||||
if (calvec.isLength2DIn(deadZone))
|
||||
{
|
||||
calvec = Vector(0,0,0);
|
||||
|
@ -367,7 +281,7 @@ void Joystick::callibrate(Vector &calvec, float deadZone)
|
|||
else
|
||||
{
|
||||
if (!calvec.isZero())
|
||||
{
|
||||
{
|
||||
Vector pos2 = calvec;
|
||||
pos2.setLength2D(deadZone);
|
||||
calvec -= pos2;
|
||||
|
@ -389,7 +303,6 @@ void Joystick::callibrate(Vector &calvec, float deadZone)
|
|||
|
||||
void Joystick::update(float dt)
|
||||
{
|
||||
#ifdef BBGE_BUILD_SDL
|
||||
if (core->joystickEnabled && inited && sdl_joy && stickIndex != -1)
|
||||
{
|
||||
#ifdef BBGE_BUILD_SDL2
|
||||
|
@ -451,23 +364,14 @@ void Joystick::update(float dt)
|
|||
rightStick.y = yaxis2/32768.0f;
|
||||
#endif
|
||||
|
||||
/*
|
||||
std::ostringstream os;
|
||||
os << "joy(" << position.x << ", " << position.y << ")";
|
||||
debugLog(os.str());
|
||||
*/
|
||||
|
||||
|
||||
callibrate(position, deadZone1);
|
||||
|
||||
callibrate(rightStick, deadZone2);
|
||||
|
||||
|
||||
/*
|
||||
std::ostringstream os2;
|
||||
os2 << "joy2(" << position.x << ", " << position.y << ")";
|
||||
debugLog(os2.str());
|
||||
*/
|
||||
|
||||
|
||||
#ifdef BBGE_BUILD_SDL2
|
||||
if (sdl_controller)
|
||||
{
|
||||
|
@ -485,21 +389,10 @@ void Joystick::update(float dt)
|
|||
for (int i = 0; i < maxJoyBtns; i++)
|
||||
buttons[i] = SDL_JoystickGetButton(sdl_joy, i)?DOWN:UP;
|
||||
#endif
|
||||
/*
|
||||
unsigned char btns[maxJoyBtns];
|
||||
glfwGetJoystickButtons(GLFW_JOYSTICK_1, btns, maxJoyBtns);
|
||||
for (int i = 0; i < maxJoyBtns; i++)
|
||||
{
|
||||
if (btns[i] == GLFW_PRESS)
|
||||
buttons[i] = DOWN;
|
||||
else
|
||||
buttons[i] = UP;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
if (clearRumbleTime >= 0)
|
||||
{
|
||||
|
@ -510,59 +403,8 @@ void Joystick::update(float dt)
|
|||
}
|
||||
}
|
||||
|
||||
#if defined(BBGE_BUILD_WINDOWS) && defined(BBGE_BUILD_XINPUT)
|
||||
if (inited && xinited)
|
||||
{
|
||||
XINPUT_STATE xinp;
|
||||
XInputGetState(0, &xinp);
|
||||
|
||||
leftTrigger = float(xinp.Gamepad.bLeftTrigger)/255.0f;
|
||||
rightTrigger = float(xinp.Gamepad.bRightTrigger)/255.0f;
|
||||
|
||||
leftShoulder = xinp.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_SHOULDER;
|
||||
rightShoulder = xinp.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_SHOULDER;
|
||||
|
||||
leftThumb = xinp.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_THUMB;
|
||||
rightThumb = xinp.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_THUMB;
|
||||
|
||||
dpadUp = xinp.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_UP;
|
||||
dpadDown = xinp.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN;
|
||||
dpadLeft = xinp.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT;
|
||||
dpadRight = xinp.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT;
|
||||
|
||||
|
||||
|
||||
|
||||
#if !defined(BBGE_BUILD_SDL)
|
||||
|
||||
buttons[0] = xinp.Gamepad.wButtons & XINPUT_GAMEPAD_A?DOWN:UP;
|
||||
buttons[1] = xinp.Gamepad.wButtons & XINPUT_GAMEPAD_B?DOWN:UP;
|
||||
buttons[2] = xinp.Gamepad.wButtons & XINPUT_GAMEPAD_X?DOWN:UP;
|
||||
buttons[3] = xinp.Gamepad.wButtons & XINPUT_GAMEPAD_Y?DOWN:UP;
|
||||
|
||||
position = Vector(xinp.Gamepad.sThumbLX, xinp.Gamepad.sThumbLY)/32768.0f;
|
||||
position.y = -rightStick.y;
|
||||
|
||||
rightStick = Vector(xinp.Gamepad.sThumbRX, xinp.Gamepad.sThumbRY)/32768.0f;
|
||||
rightStick.y = -rightStick.y;
|
||||
|
||||
callibrate(position, deadZone1);
|
||||
|
||||
callibrate(rightStick, deadZone2);
|
||||
|
||||
#endif
|
||||
|
||||
btnStart = xinp.Gamepad.wButtons & XINPUT_GAMEPAD_START;
|
||||
btnSelect = xinp.Gamepad.wButtons & XINPUT_GAMEPAD_BACK;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
std::ostringstream os;
|
||||
os << "j-pos(" << position.x << ", " << position.y << " - b0[" << buttons[0] << "]) - len[" << len << "]";
|
||||
debugLog(os.str());
|
||||
*/
|
||||
}
|
||||
|
||||
bool Joystick::anyButton()
|
||||
|
|
|
@ -43,7 +43,7 @@ void LensFlare::addFlare(const std::string &tex, Vector color, int w, int h)
|
|||
|
||||
void LensFlare::onUpdate(float dt)
|
||||
{
|
||||
//const int maxLen = 1500;
|
||||
|
||||
RenderObject::onUpdate(dt);
|
||||
Vector v = core->screenCenter - this->position;
|
||||
if (v.getSquaredLength2D() > sqr(maxLen))
|
||||
|
@ -53,7 +53,7 @@ void LensFlare::onUpdate(float dt)
|
|||
float l = v.getLength2D();
|
||||
float a = 1.0f-(l/(float)maxLen);
|
||||
a*=0.8f;
|
||||
//Vector vbit = v*(1.0f/flares.size());
|
||||
|
||||
Vector vbit = v;
|
||||
vbit *= inc;
|
||||
for (int i = 0; i < flares.size(); i++)
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "Light.h"
|
||||
|
||||
Light::Light()
|
||||
{
|
||||
num = 0;
|
||||
enabled = false;
|
||||
ambient = Vector(0.0f,0.0f,0.0f);
|
||||
diffuse = Vector(1,1,1);
|
||||
position = Vector(0,0,0);
|
||||
}
|
||||
|
||||
void Light::apply()
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
int t = GL_LIGHT0;
|
||||
switch (num)
|
||||
{
|
||||
case 0: t=GL_LIGHT0; break;
|
||||
case 1: t=GL_LIGHT1; break;
|
||||
case 2: t=GL_LIGHT2; break;
|
||||
case 3: t=GL_LIGHT3; break;
|
||||
case 4: t=GL_LIGHT4; break;
|
||||
case 5: t=GL_LIGHT5; break;
|
||||
case 6: t=GL_LIGHT6; break;
|
||||
case 7: t=GL_LIGHT7; break;
|
||||
}
|
||||
if (enabled)
|
||||
{
|
||||
glEnable(t);
|
||||
float v[4];
|
||||
glLightfv(t, GL_AMBIENT, ambient.getv4(v, 1));
|
||||
glLightfv(t, GL_DIFFUSE, diffuse.getv4(v, 1));
|
||||
glLightfv(t, GL_POSITION, position.getv4(v, 0));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
glDisable(t);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Light::update (float dt)
|
||||
{
|
||||
diffuse.update(dt);
|
||||
ambient.update(dt);
|
||||
position.update(dt);
|
||||
}
|
41
BBGE/Light.h
41
BBGE/Light.h
|
@ -1,41 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef __light__
|
||||
#define __light__
|
||||
|
||||
#include "Base.h"
|
||||
#include "Vector.h"
|
||||
|
||||
class Light
|
||||
{
|
||||
public:
|
||||
Light();
|
||||
InterpolatedVector ambient, diffuse, position;
|
||||
bool enabled;
|
||||
int num;
|
||||
void apply();
|
||||
void update(float dt);
|
||||
protected:
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "LightCone.h"
|
||||
|
||||
LightCone::LightCone() : RenderObject()
|
||||
{
|
||||
length = 64;
|
||||
spread = 32;
|
||||
}
|
||||
|
||||
void LightCone::onRender()
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
RenderObject::onRender();
|
||||
glBegin(GL_QUADS);
|
||||
//glNormal3f( 0.0f, 0, 1.0f);
|
||||
glColor4f(color.x, color.y, color.z, 1*alpha.x);
|
||||
glVertex3f(0, 0, 0);
|
||||
glColor4f(color.x, color.y, color.z,1*alpha.x);
|
||||
glVertex3f(0, 0, 0);
|
||||
glColor4f(color.x, color.y, color.z,0*alpha.x);
|
||||
glVertex3f(spread/2, length, 0);
|
||||
glColor4f(color.x, color.y, color.z,0*alpha.x);
|
||||
glVertex3f(-spread/2, length, 0);
|
||||
glEnd();
|
||||
#endif
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef __light_cone__
|
||||
#define __light_cone__
|
||||
|
||||
#include "RenderObject.h"
|
||||
|
||||
class LightCone : public RenderObject
|
||||
{
|
||||
public:
|
||||
LightCone();
|
||||
int length;
|
||||
int spread;
|
||||
protected:
|
||||
void onRender();
|
||||
};
|
||||
|
||||
#endif
|
20
BBGE/MT.cpp
20
BBGE/MT.cpp
|
@ -1,37 +1,28 @@
|
|||
#include "MT.h"
|
||||
#include "Base.h"
|
||||
|
||||
#ifdef BBGE_BUILD_SDL
|
||||
|
||||
// --------- Lockable ----------
|
||||
|
||||
Lockable::Lockable()
|
||||
: _mtx(NULL)
|
||||
{
|
||||
#ifdef BBGE_BUILD_SDL
|
||||
_mtx = SDL_CreateMutex();
|
||||
#endif
|
||||
}
|
||||
|
||||
Lockable::~Lockable()
|
||||
{
|
||||
#ifdef BBGE_BUILD_SDL
|
||||
SDL_DestroyMutex((SDL_mutex*)_mtx);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Lockable::lock()
|
||||
{
|
||||
#ifdef BBGE_BUILD_SDL
|
||||
SDL_LockMutex((SDL_mutex*)_mtx);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Lockable::unlock()
|
||||
{
|
||||
#ifdef BBGE_BUILD_SDL
|
||||
SDL_UnlockMutex((SDL_mutex*)_mtx);
|
||||
#endif
|
||||
}
|
||||
|
||||
// --------- Waitable ----------
|
||||
|
@ -39,37 +30,26 @@ void Lockable::unlock()
|
|||
Waitable::Waitable()
|
||||
: _cond(NULL)
|
||||
{
|
||||
#ifdef BBGE_BUILD_SDL
|
||||
_cond = SDL_CreateCond();
|
||||
#endif
|
||||
}
|
||||
|
||||
Waitable::~Waitable()
|
||||
{
|
||||
#ifdef BBGE_BUILD_SDL
|
||||
SDL_DestroyCond((SDL_cond*)_cond);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Waitable::wait()
|
||||
{
|
||||
#ifdef BBGE_BUILD_SDL
|
||||
SDL_CondWait((SDL_cond*)_cond, (SDL_mutex*)mutex());
|
||||
#endif
|
||||
}
|
||||
|
||||
void Waitable::signal()
|
||||
{
|
||||
#ifdef BBGE_BUILD_SDL
|
||||
SDL_CondSignal((SDL_cond*)_cond);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Waitable::broadcast()
|
||||
{
|
||||
#ifdef BBGE_BUILD_SDL
|
||||
SDL_CondBroadcast((SDL_cond*)_cond);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // BBGE_BUILD_SDL
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include <assert.h>
|
||||
|
||||
//#define DD(...) fprintf(stderr, __VA_ARGS__)
|
||||
|
||||
#define DD(...)
|
||||
#define logdev(...)
|
||||
#define logerror(...)
|
||||
|
|
|
@ -79,8 +79,8 @@ private:
|
|||
|
||||
inline unsigned int GetIndexForElemSize(unsigned int elemSize)
|
||||
{
|
||||
//ASSERT(elemSize);
|
||||
//ASSERT(elemSize <= _blockSizeMax);
|
||||
|
||||
|
||||
return ((elemSize + (_blockSizeIncr - 1)) / _blockSizeIncr) - 1;
|
||||
}
|
||||
|
||||
|
|
460
BBGE/Model.cpp
460
BBGE/Model.cpp
|
@ -1,460 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "Model.h"
|
||||
#include "Core.h"
|
||||
|
||||
#include "cal3d/cal3d.h"
|
||||
|
||||
#include "../ExternalLibs/glpng.h"
|
||||
|
||||
const std::string modelPath = "models/";
|
||||
|
||||
Model::Model() : RenderObject()
|
||||
{
|
||||
m_calModel = 0;
|
||||
//, coreModel("poot")
|
||||
m_calCoreModel = new CalCoreModel("model");
|
||||
if (!m_calCoreModel)
|
||||
{
|
||||
errorLog("Model: failed: new CalCoreModel");
|
||||
}
|
||||
|
||||
m_motionBlend[0] = 0.6f;
|
||||
m_motionBlend[1] = 0.1f;
|
||||
m_motionBlend[2] = 0.3f;
|
||||
m_animationCount = 0;
|
||||
m_meshCount = 0;
|
||||
m_renderScale = 1.0f;
|
||||
m_lodLevel = 1.0f;
|
||||
|
||||
cull = false;
|
||||
}
|
||||
|
||||
void Model::destroy()
|
||||
{
|
||||
RenderObject::destroy();
|
||||
}
|
||||
|
||||
|
||||
bool Model::load(const std::string& _strFilename)
|
||||
{
|
||||
// open the model configuration file
|
||||
std::ifstream file;
|
||||
std::string strFilename(core->adjustFilenameCase(_strFilename));
|
||||
file.open(strFilename.c_str(), std::ios::in | std::ios::binary);
|
||||
if(!file)
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << "Failed to open model configuration file '" << strFilename << "'." << std::endl;
|
||||
errorLog(os.str());
|
||||
return false;
|
||||
}
|
||||
|
||||
// initialize the data path
|
||||
std::string strPath = m_path;
|
||||
|
||||
// initialize the animation count
|
||||
int animationCount;
|
||||
animationCount = 0;
|
||||
|
||||
// parse all lines from the model configuration file
|
||||
int line;
|
||||
for(line = 1; ; line++)
|
||||
{
|
||||
// read the next model configuration line
|
||||
std::string strBuffer;
|
||||
std::getline(file, strBuffer);
|
||||
|
||||
// stop if we reached the end of file
|
||||
if(file.eof()) break;
|
||||
|
||||
// check if an error happend while reading from the file
|
||||
if(!file)
|
||||
{
|
||||
std::cerr << "Error while reading from the model configuration file '" << strFilename << "'." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// find the first non-whitespace character
|
||||
std::string::size_type pos;
|
||||
pos = strBuffer.find_first_not_of(" \t");
|
||||
|
||||
// check for empty lines
|
||||
if((pos == std::string::npos) || (strBuffer[pos] == '\n') || (strBuffer[pos] == '\r') || (strBuffer[pos] == 0)) continue;
|
||||
|
||||
// check for comment lines
|
||||
if(strBuffer[pos] == '#') continue;
|
||||
|
||||
// get the key
|
||||
std::string strKey;
|
||||
strKey = strBuffer.substr(pos, strBuffer.find_first_of(" =\t\n\r", pos) - pos);
|
||||
pos += strKey.size();
|
||||
|
||||
// get the '=' character
|
||||
pos = strBuffer.find_first_not_of(" \t", pos);
|
||||
if((pos == std::string::npos) || (strBuffer[pos] != '='))
|
||||
{
|
||||
std::cerr << strFilename << "(" << line << "): Invalid syntax." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// find the first non-whitespace character after the '=' character
|
||||
pos = strBuffer.find_first_not_of(" \t", pos + 1);
|
||||
|
||||
// get the data
|
||||
std::string strData;
|
||||
strData = strBuffer.substr(pos, strBuffer.find_first_of("\n\r", pos) - pos);
|
||||
|
||||
// handle the model creation
|
||||
if(strKey == "scale")
|
||||
{
|
||||
// set rendering scale factor
|
||||
m_renderScale = atof(strData.c_str());
|
||||
}
|
||||
else if(strKey == "path")
|
||||
{
|
||||
// set the new path for the data files if one hasn't been set already
|
||||
if (m_path == "") strPath = strData;
|
||||
}
|
||||
else if(strKey == "skeleton")
|
||||
{
|
||||
// load core skeleton
|
||||
std::cout << "Loading skeleton '" << strData << "'..." << std::endl;
|
||||
if(!m_calCoreModel->loadCoreSkeleton(strPath + strData))
|
||||
{
|
||||
CalError::printLastError();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(strKey == "animation")
|
||||
{
|
||||
// load core animation
|
||||
std::cout << "Loading animation '" << strData << "'..." << std::endl;
|
||||
m_animationId[animationCount] = m_calCoreModel->loadCoreAnimation(strPath + strData);
|
||||
if(m_animationId[animationCount] == -1)
|
||||
{
|
||||
CalError::printLastError();
|
||||
return false;
|
||||
}
|
||||
|
||||
animationCount++;
|
||||
}
|
||||
else if(strKey == "mesh")
|
||||
{
|
||||
// load core mesh
|
||||
std::cout << "Loading mesh '" << strData << "'..." << std::endl;
|
||||
if(m_calCoreModel->loadCoreMesh(strPath + strData) == -1)
|
||||
{
|
||||
CalError::printLastError();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(strKey == "material")
|
||||
{
|
||||
// load core material
|
||||
std::cout << "Loading material '" << strData << "'..." << std::endl;
|
||||
if(m_calCoreModel->loadCoreMaterial(strPath + strData) == -1)
|
||||
{
|
||||
CalError::printLastError();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << strFilename << "(" << line << "): Invalid syntax." << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// explicitely close the file
|
||||
file.close();
|
||||
|
||||
// load all textures and store the opengl texture id in the corresponding map in the material
|
||||
int materialId;
|
||||
for(materialId = 0; materialId < m_calCoreModel->getCoreMaterialCount(); materialId++)
|
||||
{
|
||||
// get the core material
|
||||
CalCoreMaterial *pCoreMaterial;
|
||||
pCoreMaterial = m_calCoreModel->getCoreMaterial(materialId);
|
||||
|
||||
// loop through all maps of the core material
|
||||
int mapId;
|
||||
for(mapId = 0; mapId < pCoreMaterial->getMapCount(); mapId++)
|
||||
{
|
||||
// get the filename of the texture
|
||||
std::string strFilename;
|
||||
strFilename = pCoreMaterial->getMapFilename(mapId);
|
||||
|
||||
// load the texture from the file
|
||||
GLuint textureId;
|
||||
pngInfo info;
|
||||
textureId = pngBind((strPath + strFilename).c_str(), PNG_BUILDMIPMAPS, PNG_ALPHA, &info, GL_CLAMP, GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR);
|
||||
//loadTexture(strPath + strFilename);
|
||||
|
||||
// store the opengl texture id in the user data of the map
|
||||
pCoreMaterial->setMapUserData(mapId, (Cal::UserData)textureId);
|
||||
}
|
||||
}
|
||||
|
||||
// make one material thread for each material
|
||||
// NOTE: this is not the right way to do it, but this viewer can't do the right
|
||||
// mapping without further information on the model etc.
|
||||
for(materialId = 0; materialId < m_calCoreModel->getCoreMaterialCount(); materialId++)
|
||||
{
|
||||
// create the a material thread
|
||||
m_calCoreModel->createCoreMaterialThread(materialId);
|
||||
|
||||
// initialize the material thread
|
||||
m_calCoreModel->setCoreMaterialId(materialId, 0, materialId);
|
||||
}
|
||||
|
||||
// Calculate Bounding Boxes
|
||||
|
||||
m_calCoreModel->getCoreSkeleton()->calculateBoundingBoxes(m_calCoreModel);
|
||||
|
||||
m_calModel = new CalModel(m_calCoreModel);
|
||||
|
||||
// attach all meshes to the model
|
||||
int meshId;
|
||||
for(meshId = 0; meshId < m_calCoreModel->getCoreMeshCount(); meshId++)
|
||||
{
|
||||
m_calModel->attachMesh(meshId);
|
||||
}
|
||||
|
||||
// set the material set of the whole model
|
||||
m_calModel->setMaterialSet(0);
|
||||
|
||||
// set initial animation state
|
||||
/*
|
||||
m_state = STATE_MOTION;
|
||||
m_calModel->getMixer()->blendCycle(m_animationId[STATE_MOTION], m_motionBlend[0], 0.0f);
|
||||
m_calModel->getMixer()->blendCycle(m_animationId[STATE_MOTION + 1], m_motionBlend[1], 0.0f);
|
||||
m_calModel->getMixer()->blendCycle(m_animationId[STATE_MOTION + 2], m_motionBlend[2], 0.0f);
|
||||
*/
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Model::onUpdate(float dt)
|
||||
{
|
||||
RenderObject::onUpdate(dt);
|
||||
|
||||
if (m_calModel)
|
||||
m_calModel->update(dt);
|
||||
}
|
||||
|
||||
void Model::renderMesh(bool bWireframe, bool bLight)
|
||||
{
|
||||
// get the renderer of the model
|
||||
CalRenderer *pCalRenderer;
|
||||
pCalRenderer = m_calModel->getRenderer();
|
||||
|
||||
// begin the rendering loop
|
||||
if(!pCalRenderer->beginRendering()) return;
|
||||
|
||||
// set wireframe mode if necessary
|
||||
if(bWireframe)
|
||||
{
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
}
|
||||
|
||||
// set the global OpenGL states
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glShadeModel(GL_SMOOTH);
|
||||
|
||||
// set the lighting mode if necessary
|
||||
if(bLight)
|
||||
{
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_LIGHT0);
|
||||
}
|
||||
|
||||
// we will use vertex arrays, so enable them
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_NORMAL_ARRAY);
|
||||
|
||||
// get the number of meshes
|
||||
int meshCount;
|
||||
meshCount = pCalRenderer->getMeshCount();
|
||||
|
||||
// render all meshes of the model
|
||||
int meshId;
|
||||
for(meshId = 0; meshId < meshCount; meshId++)
|
||||
{
|
||||
// get the number of submeshes
|
||||
int submeshCount;
|
||||
submeshCount = pCalRenderer->getSubmeshCount(meshId);
|
||||
|
||||
// render all submeshes of the mesh
|
||||
int submeshId;
|
||||
for(submeshId = 0; submeshId < submeshCount; submeshId++)
|
||||
{
|
||||
// select mesh and submesh for further data access
|
||||
if(pCalRenderer->selectMeshSubmesh(meshId, submeshId))
|
||||
{
|
||||
unsigned char meshColor[4];
|
||||
GLfloat materialColor[4];
|
||||
|
||||
// set the material ambient color
|
||||
pCalRenderer->getAmbientColor(&meshColor[0]);
|
||||
materialColor[0] = meshColor[0] / 255.0f; materialColor[1] = meshColor[1] / 255.0f; materialColor[2] = meshColor[2] / 255.0f; materialColor[3] = meshColor[3] / 255.0f;
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT, materialColor);
|
||||
|
||||
// set the material diffuse color
|
||||
pCalRenderer->getDiffuseColor(&meshColor[0]);
|
||||
materialColor[0] = meshColor[0] / 255.0f; materialColor[1] = meshColor[1] / 255.0f; materialColor[2] = meshColor[2] / 255.0f; materialColor[3] = meshColor[3] / 255.0f;
|
||||
glMaterialfv(GL_FRONT, GL_DIFFUSE, materialColor);
|
||||
|
||||
// set the vertex color if we have no lights
|
||||
if(!bLight)
|
||||
{
|
||||
glColor4fv(materialColor);
|
||||
}
|
||||
|
||||
// set the material specular color
|
||||
pCalRenderer->getSpecularColor(&meshColor[0]);
|
||||
materialColor[0] = meshColor[0] / 255.0f; materialColor[1] = meshColor[1] / 255.0f; materialColor[2] = meshColor[2] / 255.0f; materialColor[3] = meshColor[3] / 255.0f;
|
||||
glMaterialfv(GL_FRONT, GL_SPECULAR, materialColor);
|
||||
|
||||
// set the material shininess factor
|
||||
float shininess;
|
||||
shininess = 50.0f; //TODO: pCalRenderer->getShininess();
|
||||
glMaterialfv(GL_FRONT, GL_SHININESS, &shininess);
|
||||
|
||||
// get the transformed vertices of the submesh
|
||||
static float meshVertices[30000][3];
|
||||
int vertexCount;
|
||||
vertexCount = pCalRenderer->getVertices(&meshVertices[0][0]);
|
||||
|
||||
// get the transformed normals of the submesh
|
||||
static float meshNormals[30000][3];
|
||||
pCalRenderer->getNormals(&meshNormals[0][0]);
|
||||
|
||||
// get the texture coordinates of the submesh
|
||||
static float meshTextureCoordinates[30000][2];
|
||||
int textureCoordinateCount;
|
||||
textureCoordinateCount = pCalRenderer->getTextureCoordinates(0, &meshTextureCoordinates[0][0]);
|
||||
|
||||
// get the faces of the submesh
|
||||
static CalIndex meshFaces[50000][3];
|
||||
int faceCount;
|
||||
faceCount = pCalRenderer->getFaces(&meshFaces[0][0]);
|
||||
|
||||
// set the vertex and normal buffers
|
||||
glVertexPointer(3, GL_FLOAT, 0, &meshVertices[0][0]);
|
||||
glNormalPointer(GL_FLOAT, 0, &meshNormals[0][0]);
|
||||
|
||||
// set the texture coordinate buffer and state if necessary
|
||||
if((pCalRenderer->getMapCount() > 0) && (textureCoordinateCount > 0))
|
||||
{
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glEnable(GL_COLOR_MATERIAL);
|
||||
|
||||
// set the texture id we stored in the map user data
|
||||
glBindTexture(GL_TEXTURE_2D, (GLuint)pCalRenderer->getMapUserData(0));
|
||||
|
||||
// set the texture coordinate buffer
|
||||
glTexCoordPointer(2, GL_FLOAT, 0, &meshTextureCoordinates[0][0]);
|
||||
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
// draw the submesh
|
||||
|
||||
if(sizeof(CalIndex)==2)
|
||||
glDrawElements(GL_TRIANGLES, faceCount * 3, GL_UNSIGNED_SHORT, &meshFaces[0][0]);
|
||||
else
|
||||
glDrawElements(GL_TRIANGLES, faceCount * 3, GL_UNSIGNED_INT, &meshFaces[0][0]);
|
||||
|
||||
// disable the texture coordinate state if necessary
|
||||
if((pCalRenderer->getMapCount() > 0) && (textureCoordinateCount > 0))
|
||||
{
|
||||
glDisable(GL_COLOR_MATERIAL);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
// DEBUG-CODE //////////////////////////////////////////////////////////////////
|
||||
/*
|
||||
glBegin(GL_LINES);
|
||||
glColor3f(1.0f, 1.0f, 1.0f);
|
||||
int vertexId;
|
||||
for(vertexId = 0; vertexId < vertexCount; vertexId++)
|
||||
{
|
||||
const float scale = 0.3f;
|
||||
glVertex3f(meshVertices[vertexId][0], meshVertices[vertexId][1], meshVertices[vertexId][2]);
|
||||
glVertex3f(meshVertices[vertexId][0] + meshNormals[vertexId][0] * scale, meshVertices[vertexId][1] + meshNormals[vertexId][1] * scale, meshVertices[vertexId][2] + meshNormals[vertexId][2] * scale);
|
||||
}
|
||||
glEnd();
|
||||
*/
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// clear vertex array state
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
// reset the lighting mode
|
||||
if(bLight)
|
||||
{
|
||||
glDisable(GL_LIGHTING);
|
||||
glDisable(GL_LIGHT0);
|
||||
}
|
||||
|
||||
// reset the global OpenGL states
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
// reset wireframe mode if necessary
|
||||
if(bWireframe)
|
||||
{
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
}
|
||||
|
||||
// end the rendering
|
||||
pCalRenderer->endRendering();
|
||||
}
|
||||
|
||||
void Model::onRender()
|
||||
{
|
||||
/*
|
||||
glClearDepth(1.0f);
|
||||
core->resize3D();
|
||||
*/
|
||||
|
||||
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
|
||||
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
glShadeModel(GL_SMOOTH);
|
||||
|
||||
// check if we need to render the mesh
|
||||
renderMesh(false, false);
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
}
|
62
BBGE/Model.h
62
BBGE/Model.h
|
@ -1,62 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef BBGE_MODEL_H
|
||||
#define BBGE_MODEL_H
|
||||
|
||||
#include "RenderObject.h"
|
||||
|
||||
|
||||
class CalCoreModel;
|
||||
class CalModel;
|
||||
|
||||
|
||||
class Model : public RenderObject
|
||||
{
|
||||
public:
|
||||
Model();
|
||||
void destroy();
|
||||
|
||||
bool load(const std::string &file);
|
||||
|
||||
|
||||
protected:
|
||||
void onUpdate(float dt);
|
||||
|
||||
void onRender();
|
||||
void renderMesh(bool bWireframe, bool bLight);
|
||||
|
||||
protected:
|
||||
//int m_state;
|
||||
CalCoreModel* m_calCoreModel;
|
||||
CalModel* m_calModel;
|
||||
int m_animationId[16];
|
||||
int m_animationCount;
|
||||
int m_meshId[32];
|
||||
int m_meshCount;
|
||||
GLuint m_textureId[32];
|
||||
int m_textureCount;
|
||||
float m_motionBlend[3];
|
||||
float m_renderScale;
|
||||
float m_lodLevel;
|
||||
std::string m_path;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,302 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "OggStream.h"
|
||||
#include "SoundManager.h"
|
||||
#include "Base.h"
|
||||
|
||||
#define BUFFER_SIZE (4096 * 4)
|
||||
|
||||
OggStream::OggStream()
|
||||
{
|
||||
loop=false;
|
||||
source = 0;
|
||||
buffers[0] = 0;
|
||||
buffers[1] = 0;
|
||||
}
|
||||
|
||||
void OggStream::open(std::string path)
|
||||
{
|
||||
int result;
|
||||
|
||||
oggFile = fopen(core->adjustFilenameCase(path.c_str()), "rb");
|
||||
|
||||
if (!oggFile)
|
||||
{
|
||||
sound->error("Could not open Ogg file.");
|
||||
return;
|
||||
}
|
||||
|
||||
result = ov_open(oggFile, &oggStream, NULL, 0);
|
||||
|
||||
if (result < 0)
|
||||
{
|
||||
fclose(oggFile);
|
||||
|
||||
sound->error(std::string("Could not open Ogg stream. ") + errorString(result));
|
||||
return;
|
||||
}
|
||||
|
||||
vorbisInfo = ov_info(&oggStream, -1);
|
||||
vorbisComment = ov_comment(&oggStream, -1);
|
||||
|
||||
if(vorbisInfo->channels == 1)
|
||||
format = AL_FORMAT_MONO16;
|
||||
else
|
||||
format = AL_FORMAT_STEREO16;
|
||||
|
||||
|
||||
alGenBuffers(2, buffers);
|
||||
check();
|
||||
alGenSources(1, &source);
|
||||
check();
|
||||
|
||||
alSource3f(source, AL_POSITION, 0.0, 0.0, 0.0);
|
||||
alSource3f(source, AL_VELOCITY, 0.0, 0.0, 0.0);
|
||||
alSource3f(source, AL_DIRECTION, 0.0, 0.0, 0.0);
|
||||
alSourcef (source, AL_ROLLOFF_FACTOR, 0.0 );
|
||||
alSourcei (source, AL_SOURCE_RELATIVE, AL_TRUE );
|
||||
}
|
||||
|
||||
void OggStream::release()
|
||||
{
|
||||
BBGE_PROF(OggStream::release);
|
||||
if (source)
|
||||
{
|
||||
alSourceStop(source);
|
||||
empty();
|
||||
alDeleteSources(1, &source);
|
||||
check();
|
||||
}
|
||||
if (buffers && (buffers[0] || buffers[1]))
|
||||
{
|
||||
alDeleteBuffers(1, buffers);
|
||||
check();
|
||||
}
|
||||
|
||||
ov_clear(&oggStream);
|
||||
|
||||
source = 0;
|
||||
buffers[0] = 0;
|
||||
buffers[1] = 0;
|
||||
}
|
||||
|
||||
void OggStream::display()
|
||||
{
|
||||
std::cout
|
||||
<< "version " << vorbisInfo->version << "\n"
|
||||
<< "channels " << vorbisInfo->channels << "\n"
|
||||
<< "rate (hz) " << vorbisInfo->rate << "\n"
|
||||
<< "bitrate upper " << vorbisInfo->bitrate_upper << "\n"
|
||||
<< "bitrate nominal " << vorbisInfo->bitrate_nominal << "\n"
|
||||
<< "bitrate lower " << vorbisInfo->bitrate_lower << "\n"
|
||||
<< "bitrate window " << vorbisInfo->bitrate_window << "\n"
|
||||
<< "\n"
|
||||
<< "vendor " << vorbisComment->vendor << "\n";
|
||||
|
||||
for(int i = 0; i < vorbisComment->comments; i++)
|
||||
std::cout << " " << vorbisComment->user_comments[i] << "\n";
|
||||
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
bool OggStream::play(bool l)
|
||||
{
|
||||
BBGE_PROF(OggStream::play);
|
||||
if(isPlaying())
|
||||
return true;
|
||||
|
||||
if(!stream(buffers[0]))
|
||||
return false;
|
||||
|
||||
if(!stream(buffers[1]))
|
||||
return false;
|
||||
|
||||
loop=l;
|
||||
|
||||
alSourceQueueBuffers(source, 2, buffers);
|
||||
alSourcePlay(source);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OggStream::isPlaying()
|
||||
{
|
||||
ALenum state;
|
||||
|
||||
if (source)
|
||||
{
|
||||
alGetSourcei(source, AL_SOURCE_STATE, &state);
|
||||
|
||||
return (state == AL_PLAYING);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void OggStream::setGain(float gain)
|
||||
{
|
||||
if (!source) return;
|
||||
|
||||
alSourcef(source, AL_GAIN, gain);
|
||||
ALenum error=alGetError();
|
||||
|
||||
if(error!=AL_FALSE)
|
||||
{
|
||||
switch(error)
|
||||
{
|
||||
case(AL_INVALID_VALUE):
|
||||
sound->error("Invalid value for gain");
|
||||
break;
|
||||
default:
|
||||
sound->error("Error trying to set gain!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool OggStream::update()
|
||||
{
|
||||
if (!source) return false;
|
||||
|
||||
int processed;
|
||||
bool active = true;
|
||||
|
||||
if (!isPlaying())
|
||||
{
|
||||
alSourcePlay(source);
|
||||
}
|
||||
|
||||
alGetSourcei(source, AL_BUFFERS_PROCESSED, &processed);
|
||||
|
||||
while(processed--)
|
||||
{
|
||||
ALuint buffer;
|
||||
|
||||
alSourceUnqueueBuffers(source, 1, &buffer);
|
||||
check();
|
||||
|
||||
active = stream(buffer);
|
||||
|
||||
alSourceQueueBuffers(source, 1, &buffer);
|
||||
check();
|
||||
}
|
||||
|
||||
if (!active)
|
||||
{
|
||||
release();
|
||||
}
|
||||
|
||||
return active;
|
||||
}
|
||||
|
||||
bool OggStream::stream(ALuint buffer)
|
||||
{
|
||||
char pcm[BUFFER_SIZE];
|
||||
int size = 0;
|
||||
int section;
|
||||
int result;
|
||||
|
||||
while(size < BUFFER_SIZE)
|
||||
{
|
||||
result = ov_read(&oggStream, pcm + size, BUFFER_SIZE - size, 0, 2, 1, §ion);
|
||||
|
||||
if(result > 0)
|
||||
size += result;
|
||||
else
|
||||
{ if(result < 0) {} else break; }
|
||||
}
|
||||
|
||||
if(size == 0)
|
||||
{
|
||||
if (loop)
|
||||
{
|
||||
std::cout << "looping\n";
|
||||
int r = ov_pcm_seek(&oggStream, 0);
|
||||
if (r != 0)
|
||||
{
|
||||
std::cout << "error\n";
|
||||
}
|
||||
|
||||
while(size < BUFFER_SIZE)
|
||||
{
|
||||
result = ov_read(&oggStream, pcm + size, BUFFER_SIZE - size, 0, 2, 1, §ion);
|
||||
|
||||
if(result > 0)
|
||||
size += result;
|
||||
else
|
||||
{ if(result < 0) {} else break; }
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
alBufferData(buffer, format, pcm, size, vorbisInfo->rate);
|
||||
//check();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void OggStream::empty()
|
||||
{
|
||||
if (!source) return;
|
||||
int queued;
|
||||
|
||||
alGetSourcei(source, AL_BUFFERS_QUEUED, &queued);
|
||||
|
||||
while(queued--)
|
||||
{
|
||||
ALuint buffer;
|
||||
|
||||
alSourceUnqueueBuffers(source, 1, &buffer);
|
||||
check();
|
||||
}
|
||||
}
|
||||
|
||||
void OggStream::check()
|
||||
{
|
||||
int error = alGetError();
|
||||
|
||||
if(error != AL_NO_ERROR)
|
||||
sound->error(std::string("OpenAL error was raised."));
|
||||
}
|
||||
|
||||
std::string OggStream::errorString(int code)
|
||||
{
|
||||
switch(code)
|
||||
{
|
||||
case OV_EREAD:
|
||||
return std::string("Read from media.");
|
||||
case OV_ENOTVORBIS:
|
||||
return std::string("Not Vorbis data.");
|
||||
case OV_EVERSION:
|
||||
return std::string("Vorbis version mismatch.");
|
||||
case OV_EBADHEADER:
|
||||
return std::string("Invalid Vorbis header.");
|
||||
case OV_EFAULT:
|
||||
return std::string("Internal logic fault (bug or heap/stack corruption.");
|
||||
default:
|
||||
return std::string("Unknown Ogg error.");
|
||||
}
|
||||
}
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef __ogg_h__
|
||||
#define __ogg_h__
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
#include "al.h"
|
||||
#include "vorbis/vorbisfile.h"
|
||||
|
||||
class OggStream
|
||||
{
|
||||
public:
|
||||
OggStream();
|
||||
void open(std::string path);
|
||||
void release();
|
||||
void display();
|
||||
bool play(bool loop=false);
|
||||
bool isPlaying();
|
||||
bool update();
|
||||
void setGain(float g);
|
||||
protected:
|
||||
bool stream(ALuint buffer);
|
||||
void empty();
|
||||
void check();
|
||||
std::string errorString(int code);
|
||||
|
||||
private:
|
||||
FILE* oggFile;
|
||||
OggVorbis_File oggStream;
|
||||
vorbis_info* vorbisInfo;
|
||||
vorbis_comment* vorbisComment;
|
||||
|
||||
ALuint buffers[2];
|
||||
ALuint source;
|
||||
ALenum format;
|
||||
bool loop;
|
||||
};
|
||||
|
||||
|
||||
#endif // __ogg_h__
|
||||
|
|
@ -1,140 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "PackRead.h"
|
||||
#include <fcntl.h>
|
||||
|
||||
#if defined(BBGE_BUILD_UNIX)
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#define _open open
|
||||
#define _read read
|
||||
#define _lseek lseek
|
||||
#define _close close
|
||||
#else
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
#define LOC_UNIT long int
|
||||
|
||||
void packGetLoc(const std::string &pack, const std::string &file, long int *location, int *size)
|
||||
{
|
||||
*location = 0;
|
||||
*size = 0;
|
||||
|
||||
int fd = _open(pack.c_str(), O_RDONLY);
|
||||
int numFiles, nameSize, fileSize; LOC_UNIT loc;
|
||||
|
||||
_read(fd, &numFiles, sizeof(int));
|
||||
|
||||
for (int i = 0; i < numFiles; i++)
|
||||
{
|
||||
_lseek(fd, (i * sizeof(LOC_UNIT)) + sizeof(int), SEEK_SET);
|
||||
|
||||
_read(fd, &loc, sizeof(LOC_UNIT));
|
||||
|
||||
_lseek(fd, loc, SEEK_SET);
|
||||
|
||||
_read(fd, &fileSize, sizeof(int));
|
||||
|
||||
_read(fd, &nameSize, sizeof(int));
|
||||
|
||||
char *name = (char*)malloc(nameSize+1);
|
||||
_read(fd, name, nameSize);
|
||||
name[nameSize] = '\0';
|
||||
|
||||
/*
|
||||
sprintf(dbg, "fs: %d ns: %d n: %s", fileSize, nameSize, name);
|
||||
debugLog(dbg);
|
||||
*/
|
||||
|
||||
if (nocasecmp(file, std::string(name))==0)
|
||||
{
|
||||
char *buffer = (char*)malloc(fileSize);
|
||||
_read(fd, buffer, fileSize);
|
||||
|
||||
free(name);
|
||||
_close(fd);
|
||||
|
||||
*location = loc + sizeof(int) + sizeof(int) + nameSize;
|
||||
*size = fileSize;
|
||||
|
||||
return;
|
||||
//return buffer;
|
||||
}
|
||||
|
||||
free(name);
|
||||
}
|
||||
|
||||
_close(fd);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void packReadInfo(const char *pack)
|
||||
{
|
||||
debugLog("pack read info");
|
||||
|
||||
//char dbg[256];
|
||||
|
||||
int fd = _open(pack, O_RDONLY);
|
||||
|
||||
int numFiles, nameSize, fileSize;
|
||||
LOC_UNIT loc;
|
||||
|
||||
_read(fd, &numFiles, sizeof(int));
|
||||
|
||||
/*
|
||||
sprintf(dbg, "numFiles: %d", numFiles);
|
||||
debugLog(dbg);
|
||||
*/
|
||||
|
||||
for (int i = 0; i < numFiles; i++)
|
||||
{
|
||||
_lseek(fd, (i * sizeof(LOC_UNIT)) + sizeof(int), SEEK_SET);
|
||||
|
||||
_read(fd, &loc, sizeof(LOC_UNIT));
|
||||
|
||||
/*
|
||||
sprintf(dbg, "loc[%d] = %d", i, loc);
|
||||
debugLog(dbg);
|
||||
*/
|
||||
|
||||
_lseek(fd, loc, SEEK_SET);
|
||||
|
||||
_read(fd, &fileSize, sizeof(int));
|
||||
|
||||
_read(fd, &nameSize, sizeof(int));
|
||||
|
||||
char *name = (char*)malloc(nameSize+1);
|
||||
_read(fd, name, nameSize);
|
||||
name[nameSize] = '\0';
|
||||
|
||||
|
||||
/*
|
||||
sprintf(dbg, "fs: %d ns: %d n: %s", fileSize, nameSize, name);
|
||||
debugLog(dbg);
|
||||
*/
|
||||
|
||||
free(name);
|
||||
}
|
||||
|
||||
_close(fd);
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "Base.h"
|
||||
|
||||
void packReadInfo(const char *pack);
|
||||
|
||||
void packGetLoc(const std::string &pack, const std::string &file, long int *location, int *size);
|
|
@ -54,18 +54,7 @@ void ParticleEffect::transfer(ParticleEffect *pe)
|
|||
Emitter *e = pe->addNewEmitter();
|
||||
e->data = (*i)->data;
|
||||
e->setTexture(e->data.texture);
|
||||
/*
|
||||
if (e->data.flipH)
|
||||
{
|
||||
if (!e->isfh())
|
||||
e->flipHorizontal();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (e->isfh())
|
||||
e->flipHorizontal();
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -112,7 +101,7 @@ void ParticleEffect::bankLoad(const std::string &file, const std::string &path)
|
|||
Emitter *currentEmitter = 0;
|
||||
while (inf >> token)
|
||||
{
|
||||
//debugLog("Token: " + token);
|
||||
|
||||
if (token == "[Emitter]")
|
||||
{
|
||||
state = 1;
|
||||
|
@ -156,11 +145,7 @@ void ParticleEffect::bankLoad(const std::string &file, const std::string &path)
|
|||
currentEmitter->data.color.data->path.addPathNode(Vector(x,y,z), t);
|
||||
currentEmitter->data.color.startPath(currentEmitter->data.life);
|
||||
|
||||
/*
|
||||
std::ostringstream os;
|
||||
os << "colorNode: " << t << ", " << x << ", " << y << ", " << z;
|
||||
debugLog(os.str());
|
||||
*/
|
||||
|
||||
}
|
||||
if (state == 3 && currentEmitter)
|
||||
{
|
||||
|
@ -172,11 +157,7 @@ void ParticleEffect::bankLoad(const std::string &file, const std::string &path)
|
|||
currentEmitter->data.number.data->path.addPathNode(num, t);
|
||||
currentEmitter->data.number.startPath(currentEmitter->data.life);
|
||||
|
||||
/*
|
||||
std::ostringstream os;
|
||||
os << "numberNode: " << t << ", " << num;
|
||||
debugLog(os.str());
|
||||
*/
|
||||
|
||||
}
|
||||
if (state == 4 && currentEmitter)
|
||||
{
|
||||
|
@ -188,11 +169,7 @@ void ParticleEffect::bankLoad(const std::string &file, const std::string &path)
|
|||
currentEmitter->data.alpha.data->path.addPathNode(num, t);
|
||||
currentEmitter->data.alpha.startPath(currentEmitter->data.life);
|
||||
|
||||
/*
|
||||
std::ostringstream os;
|
||||
os << "alphaNode: " << t << ", " << num;
|
||||
debugLog(os.str());
|
||||
*/
|
||||
|
||||
}
|
||||
if (state == 5 && currentEmitter)
|
||||
{
|
||||
|
@ -204,11 +181,7 @@ void ParticleEffect::bankLoad(const std::string &file, const std::string &path)
|
|||
currentEmitter->data.rotation.data->path.addPathNode(Vector(0,0,num), t);
|
||||
currentEmitter->data.rotation.startPath(currentEmitter->data.life);
|
||||
|
||||
/*
|
||||
std::ostringstream os;
|
||||
os << "rotationNode: " << t << ", " << num;
|
||||
debugLog(os.str());
|
||||
*/
|
||||
|
||||
}
|
||||
if (state == 6 && currentEmitter)
|
||||
{
|
||||
|
@ -220,11 +193,7 @@ void ParticleEffect::bankLoad(const std::string &file, const std::string &path)
|
|||
currentEmitter->data.scale.data->path.addPathNode(Vector(sx, sy), t);
|
||||
currentEmitter->data.scale.startPath(currentEmitter->data.life);
|
||||
|
||||
/*
|
||||
std::ostringstream os;
|
||||
os << "scaleNode: " << t << ", " << sx << ", " << sy;
|
||||
debugLog(os.str());
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -422,12 +391,7 @@ void ParticleEffect::onUpdate(float dt)
|
|||
{
|
||||
RenderObject::onUpdate(dt);
|
||||
|
||||
/*
|
||||
for (Emitters::iterator i = emitters.begin(); i != emitters.end(); i++)
|
||||
{
|
||||
(*i)->update(dt);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
if (effectLifeCounter == 0)
|
||||
{
|
||||
|
|
|
@ -191,34 +191,9 @@ void ParticleManager::endParticle(Particle *p)
|
|||
}
|
||||
if (p->index != -1)
|
||||
{
|
||||
/*
|
||||
// set free if the neighbours are also free
|
||||
int backupFree = free;
|
||||
int oldFree = p->index;
|
||||
free = oldFree;
|
||||
nextFree();
|
||||
if (!particles[free].active)
|
||||
{
|
||||
free = oldFree;
|
||||
prevFree();
|
||||
if (!particles[free].active)
|
||||
{
|
||||
// good to go!
|
||||
}
|
||||
else
|
||||
{
|
||||
free = backupFree;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
free = backupFree;
|
||||
}
|
||||
*/
|
||||
//if (p->index > free)
|
||||
//{
|
||||
//free = p->index;
|
||||
//}
|
||||
|
||||
|
||||
|
||||
}
|
||||
p->reset();
|
||||
}
|
||||
|
@ -273,67 +248,11 @@ Particle *ParticleManager::stomp()
|
|||
}
|
||||
while (p->active);
|
||||
|
||||
/*
|
||||
int nFree = free;
|
||||
int pFree = free;
|
||||
|
||||
nextFree();
|
||||
nFree = free;
|
||||
|
||||
free = bFree;
|
||||
prevFree();
|
||||
pFree = free;
|
||||
|
||||
do
|
||||
{
|
||||
free = nFree;
|
||||
p = &particles[free];
|
||||
idx = free;
|
||||
nextFree();
|
||||
nFree = free;
|
||||
|
||||
if (p->active)
|
||||
{
|
||||
free = pFree;
|
||||
p = &particles[free];
|
||||
idx = free;
|
||||
prevFree();
|
||||
pFree = free;
|
||||
}
|
||||
c++;
|
||||
if (c >= spreadCheck)
|
||||
{
|
||||
exceed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (p->active);
|
||||
*/
|
||||
/*
|
||||
if (p->active)
|
||||
{
|
||||
c = 0;
|
||||
free = backupFree;
|
||||
nextFree();
|
||||
do
|
||||
{
|
||||
p = &particles[free];
|
||||
idx = free;
|
||||
nextFree();
|
||||
c++;
|
||||
if (c >= 8)
|
||||
{
|
||||
exceed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (p->active);
|
||||
}
|
||||
*/
|
||||
|
||||
if (exceed)
|
||||
{
|
||||
//debugLog("EXCEEDED");
|
||||
|
||||
}
|
||||
|
||||
endParticle(p);
|
||||
|
@ -341,27 +260,7 @@ Particle *ParticleManager::stomp()
|
|||
return p;
|
||||
}
|
||||
|
||||
/*
|
||||
const int FREELISTSIZE = 32;
|
||||
|
||||
void ParticleManager::getFreeList(int list)
|
||||
{
|
||||
for (int i = 0; i < FREELISTSIZE; i++)
|
||||
{
|
||||
if (freeList[curList] != -1)
|
||||
{
|
||||
Particle *p = &particles[freeList[curList]];
|
||||
freeList[curList] = -1;
|
||||
return p;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ParticleManager::addFreeList()
|
||||
{
|
||||
}
|
||||
*/
|
||||
|
||||
Particle *ParticleManager::getFreeParticle(Emitter *emitter)
|
||||
{
|
||||
|
@ -383,21 +282,6 @@ Particle *ParticleManager::getFreeParticle(Emitter *emitter)
|
|||
nextFree(spread);
|
||||
}
|
||||
|
||||
/*
|
||||
static int lpstep = 0;
|
||||
if (c > lpstep)
|
||||
lpstep = c;
|
||||
std::ostringstream os;
|
||||
os << "psteps: " << c << " largest: " << lpstep;
|
||||
debugLog(os.str());
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
p = &particles[free];
|
||||
nextFree();
|
||||
*/
|
||||
|
||||
|
||||
|
||||
if (emitter)
|
||||
|
|
|
@ -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;
|
||||
|
@ -231,7 +231,7 @@ public:
|
|||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
std::vector<Vector> suckPositions;
|
||||
int numActive;
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "PointSprites.h"
|
||||
|
||||
#ifdef BBGE_BUILD_WINDOWS
|
||||
|
||||
PointSprites::PointSprites()
|
||||
{
|
||||
glPointParameterfARB = NULL;
|
||||
glPointParameterfvARB = NULL;
|
||||
}
|
||||
|
||||
void PointSprites::init()
|
||||
{
|
||||
char *ext = (char*)glGetString( GL_EXTENSIONS );
|
||||
|
||||
if( strstr( ext, "GL_ARB_point_parameters" ) == NULL )
|
||||
{
|
||||
debugLog("PointSprites: GL_ARB_point_parameters extension was not found");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef BBGE_BUILD_GLFW
|
||||
glPointParameterfARB = (PFNGLPOINTPARAMETERFARBPROC)glfwGetProcAddress("glPointParameterfARB");
|
||||
glPointParameterfvARB = (PFNGLPOINTPARAMETERFVARBPROC)glfwGetProcAddress("glPointParameterfvARB");
|
||||
#endif
|
||||
|
||||
#ifdef BBGE_BUILD_SDL
|
||||
glPointParameterfARB = (PFNGLPOINTPARAMETERFARBPROC)SDL_GL_GetProcAddress("glPointParameterfARB");
|
||||
glPointParameterfvARB = (PFNGLPOINTPARAMETERFVARBPROC)SDL_GL_GetProcAddress("glPointParameterfvARB");
|
||||
#endif
|
||||
|
||||
if( !glPointParameterfARB || !glPointParameterfvARB )
|
||||
{
|
||||
debugLog("PointSprites: One or more GL_ARB_point_parameters functions were not found");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007, 2010 - Bit-Blot
|
||||
|
||||
This file is part of Aquaria.
|
||||
|
||||
Aquaria is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef POINTSPRITES_H
|
||||
#define POINTSPRITES_H
|
||||
|
||||
#include "Base.h"
|
||||
|
||||
#ifdef BBGE_BUILD_WINDOWS
|
||||
|
||||
class PointSprites
|
||||
{
|
||||
public:
|
||||
PointSprites();
|
||||
void init();
|
||||
|
||||
PFNGLPOINTPARAMETERFARBPROC glPointParameterfARB;
|
||||
PFNGLPOINTPARAMETERFVARBPROC glPointParameterfvARB;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
|
@ -82,7 +82,7 @@ void precacherCallback(const std::string &file, intptr_t param)
|
|||
}
|
||||
|
||||
// precacheTex
|
||||
// caches one texture
|
||||
// caches one texture
|
||||
// also support simple wildcard to cache multiple textures
|
||||
// e.g. naija/*.png
|
||||
void Precacher::precacheTex(const std::string &tex)
|
||||
|
@ -97,12 +97,12 @@ void Precacher::precacheTex(const std::string &tex)
|
|||
|
||||
if (core->debugLogTextures)
|
||||
debugLog("PRECACHING: " + tex);
|
||||
|
||||
|
||||
if (tex.find('*')!=std::string::npos)
|
||||
{
|
||||
if (core->debugLogTextures)
|
||||
debugLog("searching directory");
|
||||
|
||||
|
||||
int loc = tex.find('*');
|
||||
std::string path = tex.substr(0, loc);
|
||||
std::string type = tex.substr(loc+1, tex.size());
|
||||
|
@ -137,11 +137,11 @@ void Precacher::precacheList(const std::string &list, void progressCallback())
|
|||
if (!t.empty())
|
||||
{
|
||||
#if defined(BBGE_BUILD_UNIX)
|
||||
//debugLog("precache["+t+"]");
|
||||
|
||||
t = t.substr(0,t.size()-1);
|
||||
debugLog("precache["+t+"]");
|
||||
#endif
|
||||
stringToLower(t);
|
||||
stringToLower(t);
|
||||
precacheTex(t);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,22 +51,14 @@ ProfRender::ProfRender() : RenderObject()
|
|||
cull = false;
|
||||
alpha = 0.5;
|
||||
|
||||
//Prof_set_report_mode(Prof_CALL_GRAPH);
|
||||
|
||||
}
|
||||
|
||||
void ProfRender::onRender()
|
||||
{
|
||||
/*
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
core->print(10, 10+i*10, "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz");
|
||||
}
|
||||
*/
|
||||
|
||||
#ifdef BBGE_BUILD_WINDOWS
|
||||
/*
|
||||
Prof_draw_gl(20, 50, 400, 400, 20, 2, prof_print, prof_width);
|
||||
Prof_draw_graph_gl(430, 50, 2, 8);
|
||||
*/
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
233
BBGE/Quad.cpp
233
BBGE/Quad.cpp
|
@ -33,15 +33,7 @@ Quad::Quad(const std::string &tex, const Vector &pos)
|
|||
setTexture(tex);
|
||||
}
|
||||
|
||||
/*
|
||||
void Quad::initDefaultVBO()
|
||||
{
|
||||
}
|
||||
|
||||
void Quad::shutdownDefaultVBO()
|
||||
{
|
||||
}
|
||||
*/
|
||||
|
||||
void Quad::setSegs(int x, int y, float dgox, float dgoy, float dgmx, float dgmy, float dgtm, bool dgo)
|
||||
{
|
||||
|
@ -67,7 +59,7 @@ void Quad::setSegs(int x, int y, float dgox, float dgoy, float dgmx, float dgmy,
|
|||
createGrid(x, y);
|
||||
|
||||
gridTimer = 0;
|
||||
|
||||
|
||||
doUpdateGrid = true;
|
||||
}
|
||||
}
|
||||
|
@ -95,10 +87,10 @@ void Quad::setStrip(const std::vector<Vector> &st)
|
|||
void Quad::createGrid(int xd, int yd)
|
||||
{
|
||||
deleteGrid();
|
||||
|
||||
|
||||
xDivs = xd;
|
||||
yDivs = yd;
|
||||
|
||||
|
||||
drawGrid = new Vector * [xDivs];
|
||||
for (int i = 0; i < xDivs; i++)
|
||||
{
|
||||
|
@ -108,7 +100,7 @@ void Quad::createGrid(int xd, int yd)
|
|||
drawGrid[i][j].z = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
resetGrid();
|
||||
}
|
||||
|
||||
|
@ -166,7 +158,7 @@ void Quad::resetStrip()
|
|||
{
|
||||
for (int i = 0; i < strip.size(); i++)
|
||||
{
|
||||
//float v = (i/(float)(strip.size()-1))-0.5f;
|
||||
|
||||
float v = (i/(float(strip.size())));
|
||||
strip[i].x = v;
|
||||
strip[i].y = 0;
|
||||
|
@ -190,44 +182,6 @@ void Quad::resetGrid()
|
|||
}
|
||||
}
|
||||
|
||||
void Quad::spawnChildClone(float t)
|
||||
{
|
||||
if (!this->texture) return;
|
||||
Quad *q = new Quad;
|
||||
q->setTexture(this->texture->name);
|
||||
q->setLife(t+0.1f);
|
||||
q->setDecayRate(1);
|
||||
q->width = this->width;
|
||||
q->height = this->height;
|
||||
q->alpha = 1;
|
||||
q->alpha.interpolateTo(0, t);
|
||||
if (isfh())
|
||||
q->flipHorizontal();
|
||||
q->position = this->position;
|
||||
q->followCamera = this->followCamera;
|
||||
q->scale = this->scale;
|
||||
q->offset = this->offset;
|
||||
q->blendType = this->blendType;
|
||||
|
||||
//q->parentManagedPointer = true;
|
||||
//q->renderBeforeParent = false;
|
||||
core->getTopStateData()->addRenderObject(q, this->layer);
|
||||
//addChild(q);
|
||||
}
|
||||
/*
|
||||
smoothly transition to texture
|
||||
by creating a copy of the current quad on top and fading it out
|
||||
*/
|
||||
void Quad::setTextureSmooth(const std::string &texture, float t)
|
||||
{
|
||||
if (this->texture && !this->texture->name.empty())
|
||||
{
|
||||
spawnChildClone(t);
|
||||
//core->getTopStateData()->addRenderObject(q, this->layer);
|
||||
}
|
||||
this->setTexture(texture);
|
||||
}
|
||||
|
||||
void Quad::initQuad()
|
||||
{
|
||||
repeatToFillScale = Vector(1,1);
|
||||
|
@ -235,39 +189,37 @@ void Quad::initQuad()
|
|||
gridTimer = 0;
|
||||
xDivs = 0;
|
||||
yDivs = 0;
|
||||
|
||||
|
||||
doUpdateGrid = false;
|
||||
|
||||
autoWidth = autoHeight = 0;
|
||||
|
||||
//debugLog("Quad::initQuad()");
|
||||
|
||||
|
||||
repeatingTextureToFill = false;
|
||||
|
||||
|
||||
drawGrid = 0;
|
||||
|
||||
renderBorder = false;
|
||||
renderCenter = true;
|
||||
width = 2; height = 2;
|
||||
//llalpha = Vector(1);
|
||||
//lralpha = Vector(1);
|
||||
//ulalpha = Vector(1);
|
||||
//uralpha = Vector(1);
|
||||
//oriented = false;
|
||||
|
||||
|
||||
|
||||
upperLeftTextureCoordinates = Vector(0,0);
|
||||
lowerRightTextureCoordinates = Vector(1,1);
|
||||
renderQuad = true;
|
||||
//debugLog("End Quad::initQuad()");
|
||||
|
||||
}
|
||||
|
||||
Quad::Quad() : RenderObject()
|
||||
{
|
||||
addType(SCO_QUAD);
|
||||
borderAlpha = 0.5;
|
||||
//debugLog("Quad::Quad()");
|
||||
|
||||
initQuad();
|
||||
//debugLog("End Quad::Quad()");
|
||||
//textureSize = Vector(1,1);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Quad::deleteGrid()
|
||||
|
@ -349,7 +301,7 @@ bool Quad::isCoordinateInsideWorldRect(const Vector &coord, int w, int h)
|
|||
|
||||
void Quad::updateGrid(float dt)
|
||||
{
|
||||
//if (xDivs == 0 && yDivs == 0) return;
|
||||
|
||||
if (!doUpdateGrid) return;
|
||||
|
||||
if (gridType == GRID_WAVY)
|
||||
|
@ -385,7 +337,6 @@ void Quad::renderGrid()
|
|||
if (xDivs < 2 || yDivs < 2)
|
||||
return;
|
||||
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
const float percentX = fabsf(this->lowerRightTextureCoordinates.x - this->upperLeftTextureCoordinates.x);
|
||||
const float percentY = fabsf(this->upperLeftTextureCoordinates.y - this->lowerRightTextureCoordinates.y);
|
||||
|
||||
|
@ -411,10 +362,7 @@ void Quad::renderGrid()
|
|||
const float blue = this->color.z;
|
||||
const float alpha = this->alpha.x * this->alphaMod;
|
||||
|
||||
/*
|
||||
glDisable(GL_BLEND);
|
||||
glDisable(GL_CULL_FACE);
|
||||
*/
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
float u0 = baseX;
|
||||
float u1 = u0 + incX;
|
||||
|
@ -429,26 +377,26 @@ void Quad::renderGrid()
|
|||
|
||||
glColor4f(red, green, blue, alpha*drawGrid[i][j].z);
|
||||
glTexCoord2f(u0, v0);
|
||||
//glMultiTexCoord2fARB(GL_TEXTURE0_ARB, u0-baseX, v0-baseY);
|
||||
//glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0,0);
|
||||
|
||||
|
||||
glVertex2f(w*drawGrid[i][j].x, h*drawGrid[i][j].y);
|
||||
//
|
||||
|
||||
glColor4f(red, green, blue, alpha*drawGrid[i][j+1].z);
|
||||
glTexCoord2f(u0, v1);
|
||||
//glMultiTexCoord2fARB(GL_TEXTURE0_ARB, u0-baseX, v1-baseY);
|
||||
//glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0,(float)(screenHeight/(yDivs-1))/16);
|
||||
|
||||
|
||||
glVertex2f(w*drawGrid[i][j+1].x, h*drawGrid[i][j+1].y);
|
||||
//
|
||||
|
||||
glColor4f(red, green, blue, alpha*drawGrid[i+1][j+1].z);
|
||||
glTexCoord2f(u1, v1);
|
||||
//glMultiTexCoord2fARB(GL_TEXTURE0_ARB, u1-baseX, v1-baseY);
|
||||
//glMultiTexCoord2fARB(GL_TEXTURE1_ARB,(float)(screenWidth/(xDivs-1))/16,(float)(screenHeight/(yDivs-1))/16);
|
||||
|
||||
|
||||
glVertex2f(w*drawGrid[i+1][j+1].x, h*drawGrid[i+1][j+1].y);
|
||||
//
|
||||
|
||||
glColor4f(red, green, blue, alpha*drawGrid[i+1][j].z);
|
||||
glTexCoord2f(u1, v0);
|
||||
//glMultiTexCoord2fARB(GL_TEXTURE0_ARB, u1-baseX, v0-baseY);
|
||||
//glMultiTexCoord2fARB(GL_TEXTURE1_ARB,(float)(screenWidth/(xDivs-1))/16,0);
|
||||
|
||||
|
||||
glVertex2f(w*drawGrid[i+1][j].x, h*drawGrid[i+1][j].y);
|
||||
}
|
||||
}
|
||||
|
@ -476,7 +424,6 @@ void Quad::renderGrid()
|
|||
if (texture)
|
||||
glBindTexture(GL_TEXTURE_2D, texture->textures[0]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Quad::repeatTextureToFill(bool on)
|
||||
|
@ -491,15 +438,14 @@ void Quad::onRender()
|
|||
{
|
||||
if (!renderQuad) return;
|
||||
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
|
||||
float _w2 = width/2.0f;
|
||||
float _h2 = height/2.0f;
|
||||
|
||||
if (!strip.empty())
|
||||
{
|
||||
//glDisable(GL_BLEND);gggg
|
||||
//glDisable(GL_CULL_FACE);
|
||||
|
||||
|
||||
|
||||
const float texBits = 1.0f / (strip.size()-1);
|
||||
|
||||
|
@ -517,7 +463,7 @@ void Quad::onRender()
|
|||
}
|
||||
glEnd();
|
||||
|
||||
//glEnable(GL_CULL_FACE);
|
||||
|
||||
glBindTexture( GL_TEXTURE_2D, 0 );
|
||||
glColor4f(1,0,0,1);
|
||||
glPointSize(64);
|
||||
|
@ -585,123 +531,6 @@ void Quad::onRender()
|
|||
RenderObject::lastTextureApplied = 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef BBGE_BUILD_DIRECTX
|
||||
//core->setColor(color.x, color.y, color.z, alpha.x);
|
||||
//if (!children.empty() || useDXTransform)
|
||||
if (true)
|
||||
{
|
||||
if (this->texture)
|
||||
{
|
||||
if (upperLeftTextureCoordinates.x != 0 || upperLeftTextureCoordinates.y != 0
|
||||
|| lowerRightTextureCoordinates.x != 1 || lowerRightTextureCoordinates.y != 1)
|
||||
{
|
||||
//core->blitD3DEx(this->texture->d3dTexture, fontDrawSize/2, fontDrawSize/2, u, v-ybit, u+xbit, v+ybit-ybit);
|
||||
core->blitD3DEx(this->texture->d3dTexture, width, height, upperLeftTextureCoordinates.x, upperLeftTextureCoordinates.y, lowerRightTextureCoordinates.x, lowerRightTextureCoordinates.y);
|
||||
}
|
||||
else
|
||||
core->blitD3D(this->texture->d3dTexture, width, height);
|
||||
}
|
||||
else
|
||||
{
|
||||
core->blitD3D(0, width, height);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this->texture)
|
||||
core->blitD3DPreTrans(this->texture->d3dTexture, position.x+offset.x, position.y+offset.y, width*scale.x, width.y*scale.y);
|
||||
else
|
||||
core->blitD3DPreTrans(0, position.x+offset.x, position.y+offset.y, width*scale.x, width.y*scale.y);
|
||||
}
|
||||
|
||||
/*
|
||||
if (this->texture)
|
||||
{
|
||||
core->getD3DSprite()->Begin(D3DXSPRITE_ALPHABLEND);
|
||||
D3DXVECTOR2 scaling((1.0f/float(this->texture->width))*width*scale.x,
|
||||
(1.0f/float(this->texture->height))*height*scale.y);
|
||||
if (isfh())
|
||||
scaling.x = -scaling.x;
|
||||
D3DXVECTOR2 spriteCentre=D3DXVECTOR2((this->texture->width/2), (this->texture->height/2));
|
||||
///scale.x
|
||||
//D3DXVECTOR2 trans=D3DXVECTOR2(position.x, position.y);
|
||||
|
||||
|
||||
if (blendType == BLEND_DEFAULT)
|
||||
{
|
||||
core->getD3DDevice()->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
|
||||
core->getD3DDevice()->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
|
||||
}
|
||||
else
|
||||
{
|
||||
core->getD3DDevice()->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
|
||||
core->getD3DDevice()->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE );
|
||||
}
|
||||
|
||||
D3DXVECTOR2 rotationCentre = spriteCentre;
|
||||
D3DXVECTOR2 trans=D3DXVECTOR2(position.x,position.y) - spriteCentre;
|
||||
if (followCamera != 1)
|
||||
{
|
||||
trans.x -= core->cameraPos.x;
|
||||
trans.y -= core->cameraPos.y;
|
||||
}
|
||||
D3DXMATRIX mat, scale, final;
|
||||
//D3DXVECTOR2 centre = trans + spriteCentre;
|
||||
float rotation = (this->rotation.z*PI)/180.0f;
|
||||
//D3DXVECTOR2 scaling((1.0f/float(this->texture->width))*width*scale.x,(1.0f/float(this->texture->height))*height*scale.y);
|
||||
|
||||
//D3DXVECTOR2 scaling(1,1);
|
||||
const D3DCOLOR d3dColor=D3DCOLOR_ARGB(int(alpha.x*255), int(color.x*255), int(color.y*255), int(color.z*255));
|
||||
//const D3DCOLOR d3dColor=D3DCOLOR_ARGB(int(alpha.x*255), int(color.x*255), int(color.y*255), int(color.z*255));
|
||||
FLOAT scalingRotation = 0;
|
||||
//D3DXMatrixTransformation2D(&mat,NULL,0.0,&scaling,&spriteCentre,rotation,&trans);
|
||||
D3DXMatrixTransformation2D(&mat,
|
||||
&spriteCentre,
|
||||
scalingRotation,
|
||||
&scaling,
|
||||
&spriteCentre,
|
||||
rotation,
|
||||
&trans
|
||||
);
|
||||
|
||||
if (followCamera != 1)
|
||||
{
|
||||
D3DXMatrixScaling(&scale,core->globalScale.x*core->globalResolutionScale.x,core->globalScale.y*core->globalResolutionScale.y,1);
|
||||
D3DXMatrixMultiply(&final, &mat, &scale);
|
||||
|
||||
core->getD3DSprite()->SetTransform(&final);
|
||||
}
|
||||
else
|
||||
{
|
||||
D3DXMatrixScaling(&scale,core->globalResolutionScale.x,core->globalResolutionScale.y,1);
|
||||
D3DXMatrixMultiply(&final, &mat, &scale);
|
||||
core->getD3DSprite()->SetTransform(&final);
|
||||
}
|
||||
|
||||
|
||||
//mat = scale * mat;
|
||||
|
||||
if (this->texture)
|
||||
{
|
||||
core->getD3DSprite()->Draw(this->texture->d3dTexture,NULL,NULL,NULL,d3dColor);//0xFFFFFFFF);//d3dColor);
|
||||
core->getD3DSprite()->End();
|
||||
}
|
||||
else
|
||||
{
|
||||
core->getD3DSprite()->End();
|
||||
D3DRECT rect;
|
||||
rect.x1 = trans.x - this->width/2;
|
||||
rect.x2 = trans.x + this->width/2;
|
||||
rect.y1 = trans.y - this->height/2;
|
||||
rect.y2 = trans.y + this->height/2;
|
||||
core->getD3DDevice()->Clear(1,&rect,D3DCLEAR_TARGET,d3dColor,0,0);
|
||||
}
|
||||
//core->getD3DSprite()->End();
|
||||
}
|
||||
*/
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
30
BBGE/Quad.h
30
BBGE/Quad.h
|
@ -32,7 +32,7 @@ public:
|
|||
|
||||
bool renderCenter;
|
||||
protected:
|
||||
|
||||
|
||||
int w, h, w2, h2;
|
||||
int lineSize;
|
||||
|
||||
|
@ -43,7 +43,7 @@ class Quad : public RenderObject
|
|||
{
|
||||
public:
|
||||
Quad(const std::string &tex, const Vector &pos);
|
||||
Quad();
|
||||
Quad();
|
||||
void createGrid(int x, int y);
|
||||
void destroy();
|
||||
bool isCoordinateInside(Vector coord, int minSize=0);
|
||||
|
@ -52,19 +52,14 @@ public:
|
|||
|
||||
void flipVertical();
|
||||
void flipHorizontal();
|
||||
void setTextureSmooth(const std::string &texture, float t);
|
||||
void spawnChildClone(float t);
|
||||
void burn();
|
||||
void unburn();
|
||||
void setWidthHeight(float w, float h=-1);
|
||||
void setWidth(float w);
|
||||
void setHeight(float h);
|
||||
int getWidth() const {return int(width);}
|
||||
int getHeight() const {return int(height);}
|
||||
|
||||
void setSegs(int x, int y, float dgox, float dgoy, float dgmx, float dgmy, float dgtm, bool dgo);
|
||||
|
||||
void setSegs(int x, int y, float dgox, float dgoy, float dgmx, float dgmy, float dgtm, bool dgo);
|
||||
void setDrawGridAlpha(int x, int y, float alpha);
|
||||
void calculateQuadLighting();
|
||||
void repeatTextureToFill(bool on);
|
||||
void refreshRepeatTextureToFill();
|
||||
bool isRepeatingTextureToFill() const { return repeatingTextureToFill; }
|
||||
|
@ -74,16 +69,15 @@ public:
|
|||
float getStripSegmentSize();
|
||||
void resetStrip();
|
||||
Vector ** getDrawGrid() { return drawGrid; }
|
||||
|
||||
|
||||
void reloadDevice();
|
||||
|
||||
void deleteGrid();
|
||||
|
||||
|
||||
InterpolatedVector upperLeftTextureCoordinates, lowerRightTextureCoordinates;
|
||||
//InterpolatedVector upperLeftColor, upperRightColor, lowerLeftColor, lowerRightColor;
|
||||
//InterpolatedVector llalpha, lralpha, ulalpha, uralpha;
|
||||
//bool oriented;
|
||||
|
||||
|
||||
|
||||
enum GridType
|
||||
{
|
||||
|
@ -93,7 +87,7 @@ public:
|
|||
unsigned char gridType; // unsigned char to save space
|
||||
|
||||
char autoWidth, autoHeight; // char to save space
|
||||
|
||||
|
||||
bool renderQuad, renderBorder, renderCenter;
|
||||
bool stripVert;
|
||||
std::vector<Vector>strip;
|
||||
|
@ -111,7 +105,7 @@ protected:
|
|||
void resetGrid();
|
||||
void updateGrid(float dt);
|
||||
void renderGrid();
|
||||
|
||||
|
||||
|
||||
float drawGridOffsetX;
|
||||
float drawGridOffsetY;
|
||||
|
@ -119,9 +113,9 @@ protected:
|
|||
float drawGridModY;
|
||||
float drawGridTimeMultiplier;
|
||||
bool drawGridOut;
|
||||
|
||||
|
||||
static Vector renderBorderColor;
|
||||
|
||||
|
||||
void onSetTexture();
|
||||
void onRender();
|
||||
void onUpdate(float dt);
|
||||
|
@ -136,7 +130,7 @@ public:
|
|||
PauseQuad();
|
||||
int pauseLevel;
|
||||
protected:
|
||||
|
||||
|
||||
void onUpdate(float dt);
|
||||
};
|
||||
|
||||
|
|
|
@ -22,7 +22,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include <assert.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;
|
||||
|
@ -58,8 +61,7 @@ void QuadTrail::onRender()
|
|||
{
|
||||
if (numPoints < 2) return;
|
||||
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
//glDisable(GL_CULL_FACE);
|
||||
|
||||
int c = 0;
|
||||
Vector p, diff, dl, dr;
|
||||
Vector lastPoint;
|
||||
|
@ -114,7 +116,6 @@ void QuadTrail::onRender()
|
|||
glVertex2f((*i).point.x, (*i).point.y);
|
||||
}
|
||||
glEnd();
|
||||
#endif
|
||||
}
|
||||
|
||||
void QuadTrail::onUpdate(float dt)
|
||||
|
|
|
@ -50,7 +50,7 @@ public:
|
|||
|
||||
float lifeRate;
|
||||
protected:
|
||||
|
||||
|
||||
Vector backOffset;
|
||||
int numPoints;
|
||||
int maxPoints;
|
||||
|
|
|
@ -45,8 +45,8 @@ public:
|
|||
}
|
||||
void setCWH(int x, int y, int w, int h)
|
||||
{
|
||||
//int w2 = w*0.5f;
|
||||
//int h2 = h*0.5f;
|
||||
|
||||
|
||||
const int w2 = w / 2;
|
||||
const int h2 = h / 2;
|
||||
x1 = x - w2;
|
||||
|
|
|
@ -59,7 +59,6 @@ int RenderObject::getTopLayer()
|
|||
|
||||
void RenderObject::applyBlendType()
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
if (blendEnabled)
|
||||
{
|
||||
glEnable(GL_BLEND);
|
||||
|
@ -84,42 +83,6 @@ void RenderObject::applyBlendType()
|
|||
glDisable(GL_BLEND);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
}
|
||||
#endif
|
||||
#ifdef BBGE_BUILD_DIRECTX
|
||||
if (blendEnabled)
|
||||
{
|
||||
core->getD3DDevice()->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
|
||||
switch (blendType)
|
||||
{
|
||||
case BLEND_DEFAULT:
|
||||
core->getD3DDevice()->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||
core->getD3DDevice()->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
|
||||
//glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
break;
|
||||
case BLEND_ADD:
|
||||
core->getD3DDevice()->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||
core->getD3DDevice()->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
|
||||
//glBlendFunc(GL_SRC_ALPHA,GL_ONE);
|
||||
break;
|
||||
case BLEND_SUB:
|
||||
core->getD3DDevice()->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ZERO);
|
||||
core->getD3DDevice()->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_SRCALPHA);
|
||||
//glBlendFunc(GL_ZERO, GL_SRC_ALPHA);
|
||||
break;
|
||||
}
|
||||
|
||||
core->getD3DDevice()->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
||||
core->getD3DDevice()->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
|
||||
}
|
||||
else
|
||||
{
|
||||
core->getD3DDevice()->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
|
||||
/*
|
||||
glDisable(GL_BLEND);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
*/
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void RenderObject::setColorMult(const Vector &color, const float alpha)
|
||||
|
@ -179,13 +142,10 @@ RenderObject::RenderObject()
|
|||
motionBlurFrameOffset = 0;
|
||||
motionBlur = false;
|
||||
idx = -1;
|
||||
#ifdef BBGE_BUILD_DIRECTX
|
||||
useDXTransform = false;
|
||||
#endif
|
||||
_fv = false;
|
||||
_fh = false;
|
||||
updateCull = -1;
|
||||
//rotateFirst = true;
|
||||
|
||||
layer = LR_NONE;
|
||||
cull = true;
|
||||
|
||||
|
@ -193,7 +153,7 @@ RenderObject::RenderObject()
|
|||
|
||||
positionSnapTo = 0;
|
||||
|
||||
//updateMultiplier = 1;
|
||||
|
||||
blendEnabled = true;
|
||||
texture = 0;
|
||||
width = 0;
|
||||
|
@ -201,7 +161,7 @@ RenderObject::RenderObject()
|
|||
scale = Vector(1,1,1);
|
||||
color = Vector(1,1,1);
|
||||
alpha.x = 1;
|
||||
//mode = 0;
|
||||
|
||||
life = maxLife = 1;
|
||||
decayRate = 0;
|
||||
_dead = false;
|
||||
|
@ -209,14 +169,14 @@ RenderObject::RenderObject()
|
|||
_static = false;
|
||||
fadeAlphaWithLife = false;
|
||||
blendType = BLEND_DEFAULT;
|
||||
//lifeAlphaFadeMultiplier = 1;
|
||||
|
||||
followCamera = 0;
|
||||
stateData = 0;
|
||||
parent = 0;
|
||||
//useColor = true;
|
||||
|
||||
renderBeforeParent = false;
|
||||
//followXOnly = false;
|
||||
//renderOrigin = false;
|
||||
|
||||
|
||||
colorIsSaved = false;
|
||||
shareAlphaWithChildren = false;
|
||||
shareColorWithChildren = false;
|
||||
|
@ -255,7 +215,6 @@ bool RenderObject::isPieceFlippedHorizontal()
|
|||
|
||||
Vector RenderObject::getInvRotPosition(const Vector &vec)
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
|
||||
|
@ -266,21 +225,21 @@ Vector RenderObject::getInvRotPosition(const Vector &vec)
|
|||
chain.push_back(p);
|
||||
p = p->parent;
|
||||
}
|
||||
|
||||
|
||||
for (int i = chain.size()-1; i >= 0; i--)
|
||||
{
|
||||
glRotatef(-(chain[i]->rotation.z+chain[i]->rotationOffset.z), 0, 0, 1);
|
||||
|
||||
|
||||
if (chain[i]->isfh())
|
||||
{
|
||||
//glDisable(GL_CULL_FACE);
|
||||
|
||||
glRotatef(180, 0, 1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (vec.x != 0 || vec.y != 0)
|
||||
{
|
||||
//glRotatef(this->rotation.z, 0,0,1,this->rotation.z);
|
||||
|
||||
glTranslatef(vec.x, vec.y, 0);
|
||||
}
|
||||
|
||||
|
@ -292,9 +251,6 @@ Vector RenderObject::getInvRotPosition(const Vector &vec)
|
|||
|
||||
glPopMatrix();
|
||||
return Vector(x,y,z);
|
||||
#elif BBGE_BUILD_DIRECTX
|
||||
return vec;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef BBGE_USE_GLM
|
||||
|
@ -326,19 +282,17 @@ static void matrixChain(RenderObject *ro)
|
|||
{
|
||||
if (RenderObject *parent = ro->getParent())
|
||||
matrixChain(parent);
|
||||
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
|
||||
glTranslatef(ro->position.x+ro->offset.x, ro->position.y+ro->offset.y, 0);
|
||||
glRotatef(ro->rotation.z+ro->rotationOffset.z, 0, 0, 1);
|
||||
glTranslatef(ro->beforeScaleOffset.x, ro->beforeScaleOffset.y, 0);
|
||||
glScalef(ro->scale.x, ro->scale.y, 0);
|
||||
if (ro->isfh())
|
||||
{
|
||||
//glDisable(GL_CULL_FACE);
|
||||
|
||||
glRotatef(180, 0, 1, 0);
|
||||
}
|
||||
glTranslatef(ro->internalOffset.x, ro->internalOffset.y, 0);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -364,17 +318,16 @@ Vector RenderObject::getWorldCollidePosition(const Vector &vec)
|
|||
#ifdef BBGE_USE_GLM
|
||||
glm::mat4 transformMatrix = glm::translate(
|
||||
matrixChain(this),
|
||||
glm::vec3(collidePosition.x + vec.x, collidePosition.y + vec.y, 0.0f)
|
||||
glm::vec3(vec.x, vec.y, 0.0f)
|
||||
);
|
||||
|
||||
return Vector(transformMatrix[3][0], transformMatrix[3][1], 0);
|
||||
#else
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
|
||||
matrixChain(this);
|
||||
glTranslatef(collidePosition.x+vec.x, collidePosition.y+vec.y, 0);
|
||||
glTranslatef(vec.x, vec.y, 0);
|
||||
|
||||
float m[16];
|
||||
glGetFloatv(GL_MODELVIEW_MATRIX, m);
|
||||
|
@ -383,9 +336,6 @@ Vector RenderObject::getWorldCollidePosition(const Vector &vec)
|
|||
|
||||
glPopMatrix();
|
||||
return Vector(x,y,0);
|
||||
#elif BBGE_BUILD_DIRECTX
|
||||
return vec;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -407,28 +357,14 @@ void RenderObject::flipHorizontal()
|
|||
{
|
||||
onFH();
|
||||
}
|
||||
/*
|
||||
if (wasFlippedHorizontal && !_fh)
|
||||
for (int i = 0; i < this->collisionMask.size(); i++)
|
||||
collisionMask[i].x = -collisionMask[i].x;
|
||||
else if (!wasFlippedHorizontal && _fh)
|
||||
for (int i = 0; i < this->collisionMask.size(); i++)
|
||||
collisionMask[i].x = -collisionMask[i].x;
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
void RenderObject::flipVertical()
|
||||
{
|
||||
//bool wasFlippedVertical = _fv;
|
||||
|
||||
_fv = !_fv;
|
||||
/*
|
||||
if (wasFlippedVertical && !_fv)
|
||||
for (int i = 0; i < this->collisionMask.size(); i++)
|
||||
collisionMask[i].y = -collisionMask[i].y;
|
||||
else if (!wasFlippedVertical && _fv)
|
||||
for (int i = 0; i < this->collisionMask.size(); i++)
|
||||
collisionMask[i].y = -collisionMask[i].y;
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
void RenderObject::destroy()
|
||||
|
@ -618,7 +554,7 @@ void RenderObject::render()
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (motionBlur || motionBlurTransition)
|
||||
{
|
||||
Vector oldPos = position;
|
||||
|
@ -635,7 +571,7 @@ void RenderObject::render()
|
|||
alpha *= motionBlurTransitionTimer;
|
||||
}
|
||||
renderCall();
|
||||
}
|
||||
}
|
||||
position = oldPos;
|
||||
alpha.x = oldAlpha;
|
||||
rotation.z = oldRotZ;
|
||||
|
@ -649,26 +585,20 @@ void RenderObject::render()
|
|||
void RenderObject::renderCall()
|
||||
{
|
||||
|
||||
//RenderObjectLayer *rlayer = core->getRenderObjectLayer(getTopLayer());
|
||||
|
||||
|
||||
if (positionSnapTo)
|
||||
this->position = *positionSnapTo;
|
||||
|
||||
position += offset;
|
||||
|
||||
#ifdef BBGE_BUILD_DIRECTX
|
||||
if (!RENDEROBJECT_FASTTRANSFORM)
|
||||
core->getD3DMatrixStack()->Push();
|
||||
#endif
|
||||
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
if (!RENDEROBJECT_FASTTRANSFORM)
|
||||
glPushMatrix();
|
||||
if (!RENDEROBJECT_SHAREATTRIBUTES)
|
||||
{
|
||||
glPushAttrib(GL_ALL_ATTRIB_BITS);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
if (!RENDEROBJECT_FASTTRANSFORM)
|
||||
|
@ -685,70 +615,40 @@ void RenderObject::renderCall()
|
|||
{
|
||||
if (followCamera == 1)
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
glLoadIdentity();
|
||||
glScalef(core->globalResolutionScale.x, core->globalResolutionScale.y,0);
|
||||
glTranslatef(position.x, position.y, position.z);
|
||||
if (isfh())
|
||||
{
|
||||
//glDisable(GL_CULL_FACE);
|
||||
|
||||
glRotatef(180, 0, 1, 0);
|
||||
}
|
||||
|
||||
glRotatef(rotation.z+rotationOffset.z, 0, 0, 1);
|
||||
#endif
|
||||
#ifdef BBGE_BUILD_DIRECTX
|
||||
core->getD3DMatrixStack()->LoadIdentity();
|
||||
core->scaleMatrixStack(core->globalResolutionScale.x, core->globalResolutionScale.y,0);
|
||||
core->translateMatrixStack(position.x, position.y, 0);
|
||||
if (isfh())
|
||||
{
|
||||
//HACK: disable cull ->
|
||||
core->getD3DMatrixStack()->RotateAxisLocal(&D3DXVECTOR3(0, 1, 0), D3DXToRadian(180));
|
||||
}
|
||||
core->rotateMatrixStack(rotation.z + rotationOffset.z);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector pos = getFollowCameraPosition();
|
||||
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
glTranslatef(pos.x, pos.y, pos.z);
|
||||
if (isfh())
|
||||
{
|
||||
//glDisable(GL_CULL_FACE);
|
||||
|
||||
glRotatef(180, 0, 1, 0);
|
||||
}
|
||||
glRotatef(rotation.z+rotationOffset.z, 0, 0, 1);
|
||||
#endif
|
||||
#ifdef BBGE_BUILD_DIRECTX
|
||||
core->translateMatrixStack(pos.x, pos.y, 0);
|
||||
if (isfh())
|
||||
{
|
||||
//HACK: disable cull ->
|
||||
core->getD3DMatrixStack()->RotateAxisLocal(&D3DXVECTOR3(0, 1, 0), D3DXToRadian(180));
|
||||
}
|
||||
core->rotateMatrixStack(rotation.z + rotationOffset.z);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
glTranslatef(position.x, position.y, position.z);
|
||||
#endif
|
||||
#ifdef BBGE_BUILD_DIRECTX
|
||||
core->translateMatrixStack(position.x, position.y, 0);
|
||||
#endif
|
||||
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
if (RenderObject::renderPaths && position.data && position.data->path.getNumPathNodes() > 0)
|
||||
{
|
||||
glLineWidth(4);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
|
||||
int i = 0;
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 0.5f);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
@ -770,69 +670,21 @@ void RenderObject::renderCall()
|
|||
}
|
||||
glEnd();
|
||||
}
|
||||
#endif
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
|
||||
glRotatef(rotation.z+rotationOffset.z, 0, 0, 1);
|
||||
glRotatef(rotation.z+rotationOffset.z, 0, 0, 1);
|
||||
if (isfh())
|
||||
{
|
||||
//glDisable(GL_CULL_FACE);
|
||||
|
||||
glRotatef(180, 0, 1, 0);
|
||||
}
|
||||
#endif
|
||||
#ifdef BBGE_BUILD_DIRECTX
|
||||
//core->getD3DMatrixStack()->RotateAxisLocal(&D3DXVECTOR3(0, 0, 1), rotation.z+rotationOffset.z);
|
||||
core->rotateMatrixStack(rotation.z + rotationOffset.z);
|
||||
if (isfh())
|
||||
{
|
||||
//HACK: disable cull
|
||||
core->getD3DDevice()->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
|
||||
//core->getD3DMatrixStack()->Scale(-1, 1, 1);
|
||||
//core->applyMatrixStackToWorld();
|
||||
core->getD3DMatrixStack()->RotateAxisLocal(&D3DXVECTOR3(0, 1, 0), D3DXToRadian(180));
|
||||
//core->applyMatrixStackToWorld();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
|
||||
glTranslatef(beforeScaleOffset.x, beforeScaleOffset.y, beforeScaleOffset.z);
|
||||
glScalef(scale.x, scale.y, 1);
|
||||
glTranslatef(internalOffset.x, internalOffset.y, internalOffset.z);
|
||||
#endif
|
||||
#ifdef BBGE_BUILD_DIRECTX
|
||||
core->translateMatrixStack(beforeScaleOffset.x, beforeScaleOffset.y, 0);
|
||||
core->scaleMatrixStack(scale.x, scale.y, 1);
|
||||
core->translateMatrixStack(internalOffset.x, internalOffset.y, 0);
|
||||
|
||||
core->applyMatrixStackToWorld();
|
||||
#endif
|
||||
|
||||
|
||||
//glDisable(GL_CULL_FACE);
|
||||
/* Never set anywhere. --achurch
|
||||
if (renderOrigin)
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
|
||||
glVertex3f(0.0f, 5.0f, 0.0f);
|
||||
glVertex3f(50.0f, 0.0f, 0.0f);
|
||||
glVertex3f(0.0f, -5.0f, 0.0f);
|
||||
|
||||
glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
|
||||
glVertex3f(0.0f, 0.0f, 5.0f);
|
||||
glVertex3f(0.0f, 50.0f, 0.0f);
|
||||
glVertex3f(0.0f, 0.0f, -5.0f);
|
||||
|
||||
glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
|
||||
glVertex3f(5.0f, 0.0f, 0.0f);
|
||||
glVertex3f(0.0f, 0.0f, 50.0f);
|
||||
glVertex3f(-5.0f, 0.0f, 0.0f);
|
||||
glEnd();
|
||||
#endif
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
for (Children::iterator i = children.begin(); i != children.end(); i++)
|
||||
|
@ -842,48 +694,34 @@ void RenderObject::renderCall()
|
|||
}
|
||||
|
||||
|
||||
//if (useColor)
|
||||
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
if (rlayer)
|
||||
glColor4f(color.x * rlayer->color.x, color.y * rlayer->color.y, color.z * rlayer->color.z, alpha.x*alphaMod);
|
||||
else
|
||||
glColor4f(color.x, color.y, color.z, alpha.x*alphaMod);
|
||||
#elif defined(BBGE_BUILD_DIRECTX)
|
||||
core->setColor(color.x, color.y, color.z, alpha.x*alphaMod);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
if (texture)
|
||||
{
|
||||
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
if (texture->textures[0] != lastTextureApplied || repeatTexture != lastTextureRepeat)
|
||||
{
|
||||
texture->apply(repeatTexture);
|
||||
lastTextureRepeat = repeatTexture;
|
||||
lastTextureApplied = texture->textures[0];
|
||||
}
|
||||
#endif
|
||||
#ifdef BBGE_BUILD_DIRECTX
|
||||
texture->apply(repeatTexture);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
if (lastTextureApplied != 0 || repeatTexture != lastTextureRepeat)
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
#endif
|
||||
#ifdef BBGE_BUILD_DIRECTX
|
||||
core->bindTexture(0, 0);
|
||||
#endif
|
||||
lastTextureApplied = 0;
|
||||
lastTextureRepeat = repeatTexture;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
applyBlendType();
|
||||
|
||||
|
||||
|
@ -907,7 +745,7 @@ void RenderObject::renderCall()
|
|||
if (doRender)
|
||||
onRender();
|
||||
|
||||
//collisionShape.render();
|
||||
|
||||
if (!RENDEROBJECT_SHAREATTRIBUTES)
|
||||
{
|
||||
glPopAttrib();
|
||||
|
@ -922,13 +760,7 @@ void RenderObject::renderCall()
|
|||
|
||||
if (!RENDEROBJECT_FASTTRANSFORM)
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
glPopMatrix();
|
||||
#endif
|
||||
#ifdef BBGE_BUILD_DIRECTX
|
||||
core->getD3DMatrixStack()->Pop();
|
||||
core->applyMatrixStackToWorld();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -937,62 +769,17 @@ void RenderObject::renderCall()
|
|||
|
||||
void RenderObject::renderCollision()
|
||||
{
|
||||
if (!collisionRects.empty())
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
glPushAttrib(GL_ALL_ATTRIB_BITS);
|
||||
glPushMatrix();
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
//glLoadIdentity();
|
||||
//core->setupRenderPositionAndScale();
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glColor4f(1.0f, 0.5f, 1.0f, 0.5f);
|
||||
glPointSize(5);
|
||||
|
||||
for (int i = 0; i < collisionRects.size(); i++)
|
||||
{
|
||||
RectShape *r = &collisionRects[i];
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glVertex3f(r->x1, r->y1, 0);
|
||||
glVertex3f(r->x1, r->y2, 0);
|
||||
glVertex3f(r->x2, r->y2, 0);
|
||||
glVertex3f(r->x2, r->y1, 0);
|
||||
glEnd();
|
||||
glBegin(GL_POINTS);
|
||||
glVertex3f(r->x1, r->y1, 0);
|
||||
glVertex3f(r->x1, r->y2, 0);
|
||||
glVertex3f(r->x2, r->y2, 0);
|
||||
glVertex3f(r->x2, r->y1, 0);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
glPopAttrib();
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!collisionMask.empty())
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
glPushAttrib(GL_ALL_ATTRIB_BITS);
|
||||
glPushMatrix();
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
/*
|
||||
glTranslatef(-offset.x, -offset.y,0);
|
||||
glTranslatef(collidePosition.x, collidePosition.y,0);
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
glLoadIdentity();
|
||||
core->setupRenderPositionAndScale();
|
||||
|
||||
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
@ -1002,28 +789,22 @@ void RenderObject::renderCollision()
|
|||
for (int i = 0; i < transformedCollisionMask.size(); i++)
|
||||
{
|
||||
Vector collide = this->transformedCollisionMask[i];
|
||||
//Vector collide = getWorldCollidePosition(collisionMask[i]);
|
||||
//Vector collide = collisionMask[i];
|
||||
/*
|
||||
if (isPieceFlippedHorizontal())
|
||||
{
|
||||
collide.x = -collide.x;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
glTranslatef(collide.x, collide.y, 0);
|
||||
RenderObject *parent = this->getTopParent();
|
||||
if (parent)
|
||||
drawCircle(collideRadius*parent->scale.x, 45);
|
||||
glTranslatef(-collide.x, -collide.y, 0);
|
||||
}
|
||||
|
||||
//glTranslatef(-collidePosition.x, -collidePosition.y,0);
|
||||
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
glPopMatrix();
|
||||
glPopAttrib();
|
||||
|
||||
//glTranslatef(offset.x, offset.y,0);
|
||||
#endif
|
||||
|
||||
}
|
||||
else if (collideRadius > 0)
|
||||
{
|
||||
|
@ -1032,12 +813,12 @@ void RenderObject::renderCollision()
|
|||
core->setupRenderPositionAndScale();
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
glTranslatef(position.x+offset.x, position.y+offset.y, 0);
|
||||
//glScalef(scale.x, scale.y, 0);
|
||||
|
||||
glTranslatef(internalOffset.x, internalOffset.y, 0);
|
||||
glEnable(GL_BLEND);
|
||||
//glTranslatef(collidePosition.x, collidePosition.y,0);
|
||||
//glEnable(GL_ALPHA_TEST);
|
||||
//glAlphaFunc(GL_GREATER, 0);
|
||||
|
||||
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glColor4f(1,0,0,0.5);
|
||||
drawCircle(collideRadius, 8);
|
||||
|
@ -1077,14 +858,10 @@ Vector RenderObject::getCollisionMaskNormal(int index)
|
|||
if (!sum.isZero())
|
||||
{
|
||||
sum /= num;
|
||||
|
||||
|
||||
sum.normalize2D();
|
||||
|
||||
/*
|
||||
std::ostringstream os;
|
||||
os << "found [" << num << "] circles, got normal [" << sum.x << ", " << sum.y << "]";
|
||||
debugLog(os.str());
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
return sum;
|
||||
|
@ -1094,12 +871,12 @@ void RenderObject::lookAt(const Vector &pos, float t, float minAngle, float maxA
|
|||
{
|
||||
Vector myPos = this->getWorldPosition();
|
||||
float angle = 0;
|
||||
|
||||
|
||||
if (myPos.x == pos.x && myPos.y == pos.y)
|
||||
{
|
||||
return;
|
||||
}
|
||||
MathFunctions::calculateAngleBetweenVectorsInDegrees(myPos, pos, angle);
|
||||
MathFunctions::calculateAngleBetweenVectorsInDegrees(myPos, pos, angle);
|
||||
|
||||
RenderObject *p = parent;
|
||||
while (p)
|
||||
|
@ -1111,21 +888,9 @@ void RenderObject::lookAt(const Vector &pos, float t, float minAngle, float maxA
|
|||
if (isPieceFlippedHorizontal())
|
||||
{
|
||||
angle = 180-angle;
|
||||
|
||||
/*
|
||||
minAngle = -minAngle;
|
||||
maxAngle = -maxAngle;
|
||||
std::swap(minAngle, maxAngle);
|
||||
*/
|
||||
//std::swap(minAngle, maxAngle);
|
||||
/*
|
||||
minAngle = -(180+minAngle);
|
||||
maxAngle = -(180+maxAngle);
|
||||
*/
|
||||
/*
|
||||
if (minAngle > maxAngle)
|
||||
std::swap(minAngle, maxAngle);
|
||||
*/
|
||||
|
||||
|
||||
|
||||
offset = -offset;
|
||||
}
|
||||
angle += offset;
|
||||
|
@ -1165,7 +930,7 @@ void RenderObject::update(float dt)
|
|||
}
|
||||
if (!isDead())
|
||||
{
|
||||
//dt *= updateMultiplier;
|
||||
|
||||
onUpdate(dt);
|
||||
|
||||
if (isHidden())
|
||||
|
@ -1202,6 +967,10 @@ void RenderObject::enqueueChildDeletion(RenderObject *r)
|
|||
{
|
||||
if (r->parent == this)
|
||||
{
|
||||
// Don't garbage a child more than once
|
||||
for (size_t i = 0; i < childGarbage.size(); ++i)
|
||||
if(childGarbage[i] == r)
|
||||
return;
|
||||
childGarbage.push_back(r);
|
||||
}
|
||||
}
|
||||
|
@ -1211,19 +980,16 @@ void RenderObject::safeKill()
|
|||
alpha = 0;
|
||||
life = 0;
|
||||
onEndOfLife();
|
||||
//deathEvent.call();
|
||||
|
||||
for (RenderObjectList::iterator i = deathNotifications.begin(); i != deathNotifications.end(); i++)
|
||||
{
|
||||
(*i)->deathNotify(this);
|
||||
}
|
||||
//dead = true;
|
||||
|
||||
if (this->parent)
|
||||
{
|
||||
parent->enqueueChildDeletion(this);
|
||||
/*
|
||||
parent->removeChild(this);
|
||||
core->enqueueRenderObjectDeletion(this);
|
||||
*/
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1247,12 +1013,7 @@ Vector RenderObject::getForward()
|
|||
Vector r = v - getWorldCollidePosition();
|
||||
r.normalize2D();
|
||||
|
||||
/*
|
||||
std::ostringstream os;
|
||||
os << "forward v(" << v.x << ", " << v.y << ") ";
|
||||
os << "r(" << r.x << ", " << r.y << ") ";
|
||||
debugLog(os.str());
|
||||
*/
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -1269,7 +1030,7 @@ Vector RenderObject::getAbsoluteRotation()
|
|||
void RenderObject::onUpdate(float dt)
|
||||
{
|
||||
if (isDead()) return;
|
||||
//collisionShape.updatePosition(position);
|
||||
|
||||
updateLife(dt);
|
||||
|
||||
// FIXME: We might not need to do lifetime checks either; I just
|
||||
|
@ -1301,7 +1062,7 @@ void RenderObject::onUpdate(float dt)
|
|||
(*i)->update(dt);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!childGarbage.empty())
|
||||
{
|
||||
for (Children::iterator i = childGarbage.begin(); i != childGarbage.end(); i++)
|
||||
|
@ -1338,7 +1099,7 @@ void RenderObject::onUpdate(float dt)
|
|||
}
|
||||
}
|
||||
|
||||
// updateCullVariables();
|
||||
|
||||
}
|
||||
|
||||
void RenderObject::unloadDevice()
|
||||
|
@ -1368,18 +1129,12 @@ bool RenderObject::setTexture(const std::string &n)
|
|||
return false;
|
||||
}
|
||||
|
||||
if(texture && name == texture->name)
|
||||
if(texture && texture->getLoadResult() == TEX_SUCCESS && name == texture->name)
|
||||
return true; // no texture change
|
||||
|
||||
TextureLoadResult res = TEX_FAILED;
|
||||
CountedPtr<Texture> tex = core->addTexture(name, &res);
|
||||
CountedPtr<Texture> tex = core->addTexture(name);
|
||||
setTexturePointer(tex);
|
||||
return !!tex && res != TEX_FAILED;
|
||||
}
|
||||
|
||||
float RenderObject::getSortDepth()
|
||||
{
|
||||
return position.y;
|
||||
return tex && tex->getLoadResult() == TEX_SUCCESS;
|
||||
}
|
||||
|
||||
void RenderObject::addChild(RenderObject *r, ParentManaged pm, RenderBeforeParent rbp, ChildOrder order)
|
||||
|
@ -1428,6 +1183,6 @@ void RenderObject::setOverrideCullRadius(float ovr)
|
|||
bool RenderObject::isCoordinateInRadius(const Vector &pos, float r)
|
||||
{
|
||||
Vector d = pos-getRealPosition();
|
||||
|
||||
|
||||
return (d.getSquaredLength2D() < r*r);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#include "Base.h"
|
||||
#include "Texture.h"
|
||||
#include "Flags.h"
|
||||
#include "ScriptObject.h"
|
||||
|
||||
class Core;
|
||||
|
@ -69,8 +68,6 @@ struct MotionBlurFrame
|
|||
float rotz;
|
||||
};
|
||||
|
||||
typedef std::vector<RectShape> CollideRects;
|
||||
|
||||
class RenderObjectLayer;
|
||||
|
||||
class RenderObject : public ScriptObject
|
||||
|
@ -123,7 +120,7 @@ public:
|
|||
blendType = bt;
|
||||
}
|
||||
|
||||
//enum DestroyType { RANDOM=0, REMOVE_STATE };
|
||||
|
||||
virtual void destroy();
|
||||
|
||||
virtual void flipHorizontal();
|
||||
|
@ -166,8 +163,6 @@ public:
|
|||
Vector getRealPosition();
|
||||
Vector getRealScale();
|
||||
|
||||
virtual float getSortDepth();
|
||||
|
||||
StateData *getStateData();
|
||||
|
||||
void setPositionSnapTo(InterpolatedVector *positionSnapTo);
|
||||
|
@ -183,7 +178,7 @@ public:
|
|||
const RenderObject &operator=(const RenderObject &r);
|
||||
|
||||
void toggleCull(bool value);
|
||||
|
||||
|
||||
void safeKill();
|
||||
|
||||
void enqueueChildDeletion(RenderObject *r);
|
||||
|
@ -245,18 +240,14 @@ public:
|
|||
unsigned char blendType;
|
||||
|
||||
float life;
|
||||
//float lifeAlphaFadeMultiplier;
|
||||
|
||||
float followCamera;
|
||||
|
||||
//bool useColor;
|
||||
|
||||
bool renderBeforeParent;
|
||||
bool updateAfterParent;
|
||||
|
||||
//bool followXOnly;
|
||||
//bool renderOrigin;
|
||||
|
||||
//float updateMultiplier;
|
||||
//EventPtr deathEvent;
|
||||
|
||||
bool colorIsSaved; // Used for both color and alpha
|
||||
Vector savedColor; // Saved values from setColorMult()
|
||||
|
@ -271,30 +262,23 @@ public:
|
|||
|
||||
InterpolatedVector *positionSnapTo;
|
||||
|
||||
//DestroyType destroyType;
|
||||
|
||||
typedef std::vector<RenderObject*> Children;
|
||||
Children children, childGarbage;
|
||||
|
||||
//Flags flags;
|
||||
|
||||
#ifdef BBGE_BUILD_DIRECTX
|
||||
bool useDXTransform;
|
||||
//D3DXMATRIX matrix;
|
||||
#endif
|
||||
|
||||
float collideRadius;
|
||||
Vector collidePosition;
|
||||
std::vector<Vector> collisionMask;
|
||||
std::vector<Vector> transformedCollisionMask;
|
||||
|
||||
CollideRects collisionRects;
|
||||
float collisionMaskRadius;
|
||||
|
||||
float alphaMod;
|
||||
|
||||
bool ignoreUpdate;
|
||||
bool useOldDT;
|
||||
|
||||
|
||||
protected:
|
||||
virtual void onFH(){}
|
||||
virtual void onFV(){}
|
||||
|
@ -317,7 +301,7 @@ protected:
|
|||
}
|
||||
if (fadeAlphaWithLife && !alpha.isInterpolating())
|
||||
{
|
||||
//alpha = ((life*lifeAlphaFadeMultiplier)/maxLife);
|
||||
|
||||
alpha = life/maxLife;
|
||||
}
|
||||
}
|
||||
|
@ -329,7 +313,6 @@ protected:
|
|||
void renderCollision();
|
||||
|
||||
bool repeatTexture;
|
||||
//ParentManaged pm;
|
||||
unsigned char pm; // unsigned char to save space
|
||||
typedef std::list<RenderObject*> RenderObjectList;
|
||||
RenderObjectList deathNotifications;
|
||||
|
@ -345,7 +328,7 @@ protected:
|
|||
bool _hidden;
|
||||
bool _static;
|
||||
bool _fv, _fh;
|
||||
//bool rotateFirst;
|
||||
|
||||
int idx;
|
||||
RenderObject *parent;
|
||||
StateData *stateData;
|
||||
|
|
|
@ -20,15 +20,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
#include "Core.h"
|
||||
|
||||
#ifdef RLT_FIXED
|
||||
#define BASE_ARRAY_SIZE 100 // Size of an object array in a new layer
|
||||
#endif
|
||||
|
||||
RenderObjectLayer::RenderObjectLayer()
|
||||
#ifdef RLT_FIXED
|
||||
: renderObjects(BASE_ARRAY_SIZE)
|
||||
#endif
|
||||
{
|
||||
{
|
||||
followCamera = NO_FOLLOW_CAMERA;
|
||||
visible = true;
|
||||
startPass = endPass = 0;
|
||||
|
@ -42,14 +38,12 @@ RenderObjectLayer::RenderObjectLayer()
|
|||
color = Vector(1,1,1);
|
||||
|
||||
displayListValid = false;
|
||||
|
||||
#ifdef RLT_FIXED
|
||||
|
||||
const int size = renderObjects.size();
|
||||
for (int i = 0; i < size; i++)
|
||||
renderObjects[i] = 0;
|
||||
objectCount = 0;
|
||||
firstFreeIdx = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
RenderObjectLayer::~RenderObjectLayer()
|
||||
|
@ -68,88 +62,8 @@ void RenderObjectLayer::setOptimizeStatic(bool opt)
|
|||
clearDisplayList();
|
||||
}
|
||||
|
||||
#ifdef RLT_DYNAMIC
|
||||
bool sortRenderObjectsByDepth(RenderObject *r1, RenderObject *r2)
|
||||
{
|
||||
return r1->getSortDepth() < r2->getSortDepth();
|
||||
}
|
||||
#endif
|
||||
|
||||
void RenderObjectLayer::sort()
|
||||
{
|
||||
if (optimizeStatic && displayListValid)
|
||||
return; // Assume the order hasn't changed
|
||||
|
||||
#ifdef RLT_FIXED
|
||||
// Compress the list before sorting to boost speed.
|
||||
const int size = renderObjects.size();
|
||||
int from, to;
|
||||
for (to = 0; to < size; to++) {
|
||||
if (!renderObjects[to])
|
||||
break;
|
||||
}
|
||||
for (from = to+1; from < size; from++) {
|
||||
if (renderObjects[from])
|
||||
{
|
||||
renderObjects[to] = renderObjects[from];
|
||||
renderObjects[to]->setIdx(to);
|
||||
to++;
|
||||
}
|
||||
}
|
||||
if (to < size)
|
||||
renderObjects[to] = 0;
|
||||
if (to != objectCount)
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << "Objects lost in sort! (" << to << " != " << objectCount << ")";
|
||||
errorLog(os.str());
|
||||
objectCount = to;
|
||||
}
|
||||
const int count = objectCount;
|
||||
|
||||
// Save a copy of all objects' depths so we don't have to call
|
||||
// getSortDepth() in a greater-order loop.
|
||||
std::vector<float> sortDepths(count);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
sortDepths[i] = renderObjects[i]->getSortDepth();
|
||||
}
|
||||
|
||||
// FIXME: Just a simple selection sort for now. Is this fast enough?
|
||||
// Might need to use quicksort instead.
|
||||
for (int i = 0; i < count-1; i++)
|
||||
{
|
||||
int best = i;
|
||||
float bestDepth = sortDepths[i];
|
||||
for (int j = i+1; j < count; j++)
|
||||
{
|
||||
if (sortDepths[j] < bestDepth)
|
||||
{
|
||||
best = j;
|
||||
bestDepth = sortDepths[j];
|
||||
}
|
||||
}
|
||||
if (best != i)
|
||||
{
|
||||
RenderObject *r = renderObjects[i];
|
||||
renderObjects[i] = renderObjects[best];
|
||||
renderObjects[i]->setIdx(i);
|
||||
renderObjects[best] = r;
|
||||
renderObjects[best]->setIdx(best);
|
||||
float d = sortDepths[i];
|
||||
sortDepths[i] = sortDepths[best];
|
||||
sortDepths[best] = d;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef RLT_DYNAMIC
|
||||
renderObjectList.sort(sortRenderObjectsByDepth);
|
||||
#endif
|
||||
}
|
||||
|
||||
void RenderObjectLayer::add(RenderObject* r)
|
||||
{
|
||||
#ifdef RLT_FIXED
|
||||
int size = renderObjects.size();
|
||||
if (firstFreeIdx >= size)
|
||||
{
|
||||
|
@ -166,20 +80,12 @@ void RenderObjectLayer::add(RenderObject* r)
|
|||
if (!renderObjects[firstFreeIdx])
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#ifdef RLT_DYNAMIC
|
||||
renderObjectList.push_back(r);
|
||||
#endif
|
||||
#ifdef RLT_MAP
|
||||
renderObjectMap[intptr_t(r)] = r;
|
||||
#endif
|
||||
|
||||
clearDisplayList();
|
||||
}
|
||||
|
||||
void RenderObjectLayer::remove(RenderObject* r)
|
||||
{
|
||||
#ifdef RLT_FIXED
|
||||
const int idx = r->getIdx();
|
||||
if (idx < 0 || idx >= renderObjects.size())
|
||||
{
|
||||
|
@ -196,20 +102,12 @@ void RenderObjectLayer::remove(RenderObject* r)
|
|||
if (idx < firstFreeIdx)
|
||||
firstFreeIdx = idx;
|
||||
r->setIdx(-1);
|
||||
#endif
|
||||
#ifdef RLT_DYNAMIC
|
||||
renderObjectList.remove(r);
|
||||
#endif
|
||||
#ifdef RLT_MAP
|
||||
renderObjectMap[intptr_t(r)] = 0;
|
||||
#endif
|
||||
|
||||
clearDisplayList();
|
||||
}
|
||||
|
||||
void RenderObjectLayer::moveToFront(RenderObject *r)
|
||||
{
|
||||
#ifdef RLT_FIXED
|
||||
const int size = renderObjects.size();
|
||||
const int curIdx = r->getIdx();
|
||||
int lastUsed;
|
||||
|
@ -267,18 +165,12 @@ void RenderObjectLayer::moveToFront(RenderObject *r)
|
|||
while (renderObjects[firstFreeIdx])
|
||||
firstFreeIdx++;
|
||||
}
|
||||
#endif // RLT_FIXED
|
||||
#ifdef RLT_DYNAMIC
|
||||
renderObjectList.remove(r);
|
||||
renderObjectList.push_back(r);
|
||||
#endif
|
||||
|
||||
clearDisplayList();
|
||||
}
|
||||
|
||||
void RenderObjectLayer::moveToBack(RenderObject *r)
|
||||
{
|
||||
#ifdef RLT_FIXED
|
||||
const int size = renderObjects.size();
|
||||
const int curIdx = r->getIdx();
|
||||
int firstUsed;
|
||||
|
@ -341,11 +233,6 @@ void RenderObjectLayer::moveToBack(RenderObject *r)
|
|||
break;
|
||||
}
|
||||
}
|
||||
#endif // RLT_FIXED
|
||||
#ifdef RLT_DYNAMIC
|
||||
renderObjectList.remove(r);
|
||||
renderObjectList.push_front(r);
|
||||
#endif
|
||||
|
||||
clearDisplayList();
|
||||
}
|
||||
|
@ -364,9 +251,7 @@ void RenderObjectLayer::renderPass(int pass)
|
|||
{
|
||||
if (displayList[i].isList)
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
glCallList(displayList[i].u.listID);
|
||||
#endif
|
||||
RenderObject::lastTextureApplied = 0;
|
||||
}
|
||||
else
|
||||
|
@ -430,7 +315,6 @@ void RenderObjectLayer::generateDisplayList()
|
|||
}
|
||||
else
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
int listID = glGenLists(1);
|
||||
if (listID != 0)
|
||||
{
|
||||
|
@ -450,16 +334,13 @@ void RenderObjectLayer::generateDisplayList()
|
|||
}
|
||||
else
|
||||
debugLog("glGenLists failed");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (lastWasStatic)
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
glEndList();
|
||||
#endif
|
||||
lastWasStatic = false;
|
||||
}
|
||||
}
|
||||
|
@ -477,9 +358,7 @@ void RenderObjectLayer::generateDisplayList()
|
|||
|
||||
if (lastWasStatic)
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
glEndList();
|
||||
#endif
|
||||
}
|
||||
|
||||
displayList.resize(listLength);
|
||||
|
|
|
@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
inline bool RenderObject::isOnScreen()
|
||||
{
|
||||
if (followCamera == 1) return true;
|
||||
//if (followCamera != 0) return true;
|
||||
|
||||
|
||||
// note: radii are sqr-ed for speed
|
||||
const float cullRadiusSqr = (getCullRadiusSqr() * core->invGlobalScaleSqr) + core->cullRadiusSqr;
|
||||
|
|
|
@ -42,7 +42,6 @@ void OutlineRect::setLineSize(int ls)
|
|||
|
||||
void OutlineRect::onRender()
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
glLineWidth(lineSize);
|
||||
glBegin(GL_LINES);
|
||||
// l
|
||||
|
@ -71,7 +70,6 @@ void OutlineRect::onRender()
|
|||
glVertex2f(0,h2);
|
||||
glEnd();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ RoundedRect::RoundedRect() : RenderObject()
|
|||
height = 100;
|
||||
|
||||
radius = 20;
|
||||
|
||||
|
||||
cull = false;
|
||||
|
||||
canMove = false;
|
||||
|
@ -91,21 +91,21 @@ void RoundedRect::onUpdate(float dt)
|
|||
{
|
||||
if (moving == this)
|
||||
{
|
||||
// do stuff
|
||||
|
||||
|
||||
moving = 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RoundedRect::onRender()
|
||||
{
|
||||
//glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
int w2 = width/2;
|
||||
int h2 = height/2;
|
||||
//glDisable(GL_CULL_FACE);
|
||||
|
||||
float iter = 0.1f;
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
|
@ -146,20 +146,20 @@ void RoundedRect::onRender()
|
|||
glVertex3f(-w2 + x1, h2 + 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//middle, top, btm
|
||||
glVertex3f(-w2, -h2 - radius, 0);
|
||||
glVertex3f(w2, -h2 - radius, 0);
|
||||
glVertex3f(w2, h2 + radius, 0);
|
||||
glVertex3f(-w2, h2 + radius, 0);
|
||||
|
||||
// left
|
||||
// left
|
||||
glVertex3f(-w2 - radius, -h2, 0);
|
||||
glVertex3f(-w2, -h2, 0);
|
||||
glVertex3f(-w2, h2, 0);
|
||||
glVertex3f(-w2 - radius, h2, 0);
|
||||
|
||||
// right
|
||||
// right
|
||||
glVertex3f(w2 + radius, -h2, 0);
|
||||
glVertex3f(w2, -h2, 0);
|
||||
glVertex3f(w2, h2, 0);
|
||||
|
@ -167,7 +167,7 @@ void RoundedRect::onRender()
|
|||
|
||||
glEnd();
|
||||
|
||||
//glEnable(GL_CULL_FACE);
|
||||
|
||||
}
|
||||
|
||||
void RoundedRect::show()
|
||||
|
@ -195,7 +195,7 @@ void RoundedRect::hide()
|
|||
|
||||
RoundButton::RoundButton(const std::string &labelText, TTFFont *font) : RenderObject()
|
||||
{
|
||||
//label = new
|
||||
|
||||
label = new TTFText(font);
|
||||
label->setAlign(ALIGN_CENTER);
|
||||
label->offset += Vector(0, 3);
|
||||
|
@ -214,7 +214,7 @@ void RoundButton::setWidthHeight(int w, int h, int radius)
|
|||
width = w;
|
||||
height = h;
|
||||
}
|
||||
|
||||
|
||||
void RoundButton::onUpdate(float dt)
|
||||
{
|
||||
if (noNested && core->isNested()) return;
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
int getHeight() { return height; }
|
||||
int getRadius() { return radius; }
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
void onUpdate(float dt);
|
||||
void onRender();
|
||||
|
|
|
@ -34,7 +34,7 @@ void ScreenTransition::createTexture()
|
|||
{
|
||||
width = core->getVirtualWidth();
|
||||
height = core->getVirtualHeight();
|
||||
|
||||
|
||||
windowWidth = core->getWindowWidth();
|
||||
windowHeight = core->getWindowHeight();
|
||||
|
||||
|
@ -44,15 +44,8 @@ void ScreenTransition::createTexture()
|
|||
sizePowerOf2Texture(textureWidth);
|
||||
sizePowerOf2Texture(textureHeight);
|
||||
|
||||
/*
|
||||
if (windowWidth>1024)
|
||||
{
|
||||
textureWidth = 2048;
|
||||
textureHeight = 1024;
|
||||
}
|
||||
*/
|
||||
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
|
||||
//create our texture
|
||||
glGenTextures(1,&screen_texture);
|
||||
glBindTexture(GL_TEXTURE_2D, screen_texture);
|
||||
|
@ -63,23 +56,17 @@ void ScreenTransition::createTexture()
|
|||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR); //GL_NEAREST); //GL_NEAREST);
|
||||
glTexImage2D(GL_TEXTURE_2D,0,3, textureWidth, textureHeight, 0 , GL_RGB, GL_UNSIGNED_BYTE, NULL);
|
||||
glBindTexture(GL_TEXTURE_2D,0);
|
||||
#endif
|
||||
|
||||
/*
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
void ScreenTransition::destroyTexture()
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
if (screen_texture)
|
||||
{
|
||||
glDeleteTextures(1, &screen_texture);
|
||||
screen_texture = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ScreenTransition::unloadDevice()
|
||||
|
@ -95,23 +82,17 @@ void ScreenTransition::reloadDevice()
|
|||
}
|
||||
|
||||
void ScreenTransition::capture()
|
||||
{
|
||||
{
|
||||
core->render();
|
||||
|
||||
/*
|
||||
std::ostringstream os;
|
||||
os << "windowWidth [" << windowWidth << "] windowHeight [" << windowHeight << "]";
|
||||
errorLog(os.str());
|
||||
*/
|
||||
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
|
||||
|
||||
if (screen_texture)
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D,screen_texture);
|
||||
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, windowWidth, windowHeight);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
core->showBuffer();
|
||||
}
|
||||
|
@ -137,28 +118,18 @@ bool ScreenTransition::isGoing()
|
|||
void ScreenTransition::onRender()
|
||||
{
|
||||
if (alpha.x == 0) return;
|
||||
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
|
||||
float width2 = float(width)/2;
|
||||
float height2 = float(height)/2;
|
||||
|
||||
|
||||
const float pw = float(windowWidth)/float(textureWidth);
|
||||
const float ph = float(windowHeight)/float(textureHeight);
|
||||
|
||||
/*
|
||||
std::ostringstream os;
|
||||
os << "wh(" << width2 << ", " << height2 << ") p(" << pw << ", " << ph << ")";
|
||||
debugLog(os.str());
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, screen_texture);
|
||||
//glBindTexture(GL_TEXTURE_2D, 0);
|
||||
// 16/10 = 1.6
|
||||
// 16/9 = 1.77777
|
||||
// 4/3 = 1.33333
|
||||
|
||||
// fix slight offset in 16/10 resolution
|
||||
// only on mac?
|
||||
|
||||
|
||||
|
||||
#if 0 //def BBGE_BUILD_MACOSX
|
||||
float aspect = float(core->width) / float(core->height);
|
||||
|
@ -170,8 +141,8 @@ void ScreenTransition::onRender()
|
|||
#endif
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
//glNormal3f( 0.0f, 0.0f, 1.0f);
|
||||
//glColor4f(color.x, color.y, color.z, alpha.getValue());
|
||||
|
||||
|
||||
glTexCoord2d(0, 0);
|
||||
glVertex3f(-width2, height2, 0.0);
|
||||
glTexCoord2d(pw, 0);
|
||||
|
@ -183,8 +154,7 @@ void ScreenTransition::onRender()
|
|||
glEnd();
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
|
||||
RenderObject::lastTextureApplied = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -40,11 +40,9 @@ protected:
|
|||
int windowWidth, windowHeight;
|
||||
void onRender();
|
||||
float width, height;
|
||||
//void onUpdate(float dt);
|
||||
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
|
||||
GLuint screen_texture;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -25,25 +25,25 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#ifdef BBGE_BUILD_SHADERS
|
||||
// GL_ARB_shader_objects
|
||||
PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObjectARB = NULL;
|
||||
PFNGLDELETEOBJECTARBPROC glDeleteObjectARB = NULL;
|
||||
PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB = NULL;
|
||||
PFNGLDELETEOBJECTARBPROC glDeleteObjectARB = NULL;
|
||||
PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB = NULL;
|
||||
PFNGLCREATESHADEROBJECTARBPROC glCreateShaderObjectARB = NULL;
|
||||
PFNGLSHADERSOURCEARBPROC glShaderSourceARB = NULL;
|
||||
PFNGLCOMPILESHADERARBPROC glCompileShaderARB = NULL;
|
||||
PFNGLSHADERSOURCEARBPROC glShaderSourceARB = NULL;
|
||||
PFNGLCOMPILESHADERARBPROC glCompileShaderARB = NULL;
|
||||
PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameterivARB = NULL;
|
||||
PFNGLATTACHOBJECTARBPROC glAttachObjectARB = NULL;
|
||||
PFNGLGETINFOLOGARBPROC glGetInfoLogARB = NULL;
|
||||
PFNGLLINKPROGRAMARBPROC glLinkProgramARB = NULL;
|
||||
PFNGLATTACHOBJECTARBPROC glAttachObjectARB = NULL;
|
||||
PFNGLGETINFOLOGARBPROC glGetInfoLogARB = NULL;
|
||||
PFNGLLINKPROGRAMARBPROC glLinkProgramARB = NULL;
|
||||
PFNGLGETUNIFORMLOCATIONARBPROC glGetUniformLocationARB = NULL;
|
||||
PFNGLGETACTIVEUNIFORMARBPROC glGetActiveUniformARB = NULL;
|
||||
PFNGLUNIFORM1FVARBPROC glUniform1fvARB = NULL;
|
||||
PFNGLUNIFORM2FVARBPROC glUniform2fvARB = NULL;
|
||||
PFNGLUNIFORM3FVARBPROC glUniform3fvARB = NULL;
|
||||
PFNGLUNIFORM4FVARBPROC glUniform4fvARB = NULL;
|
||||
PFNGLUNIFORM1IVARBPROC glUniform1ivARB = NULL;
|
||||
PFNGLUNIFORM2IVARBPROC glUniform2ivARB = NULL;
|
||||
PFNGLUNIFORM3IVARBPROC glUniform3ivARB = NULL;
|
||||
PFNGLUNIFORM4IVARBPROC glUniform4ivARB = NULL;
|
||||
PFNGLGETACTIVEUNIFORMARBPROC glGetActiveUniformARB = NULL;
|
||||
PFNGLUNIFORM1FVARBPROC glUniform1fvARB = NULL;
|
||||
PFNGLUNIFORM2FVARBPROC glUniform2fvARB = NULL;
|
||||
PFNGLUNIFORM3FVARBPROC glUniform3fvARB = NULL;
|
||||
PFNGLUNIFORM4FVARBPROC glUniform4fvARB = NULL;
|
||||
PFNGLUNIFORM1IVARBPROC glUniform1ivARB = NULL;
|
||||
PFNGLUNIFORM2IVARBPROC glUniform2ivARB = NULL;
|
||||
PFNGLUNIFORM3IVARBPROC glUniform3ivARB = NULL;
|
||||
PFNGLUNIFORM4IVARBPROC glUniform4ivARB = NULL;
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -66,10 +66,7 @@ void Shader::staticInit()
|
|||
//This extension string indicates that the OpenGL Shading Language,
|
||||
// version 1.00, is supported.
|
||||
debugLog("GL_ARB_shading_language_100 extension was not found");
|
||||
/*
|
||||
MessageBox(NULL,"GL_ARB_shading_language_100 extension was not found",
|
||||
"ERROR",MB_OK|MB_ICONEXCLAMATION);
|
||||
*/
|
||||
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
@ -80,7 +77,6 @@ void Shader::staticInit()
|
|||
}
|
||||
else
|
||||
{
|
||||
#ifdef BBGE_BUILD_SDL
|
||||
glCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC)SDL_GL_GetProcAddress("glCreateProgramObjectARB");
|
||||
glDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC)SDL_GL_GetProcAddress("glDeleteObjectARB");
|
||||
glUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC)SDL_GL_GetProcAddress("glUseProgramObjectARB");
|
||||
|
@ -101,11 +97,10 @@ void Shader::staticInit()
|
|||
glUniform2ivARB = (PFNGLUNIFORM2IVARBPROC)SDL_GL_GetProcAddress("glUniform2ivARB");
|
||||
glUniform3ivARB = (PFNGLUNIFORM3IVARBPROC)SDL_GL_GetProcAddress("glUniform3ivARB");
|
||||
glUniform4ivARB = (PFNGLUNIFORM4IVARBPROC)SDL_GL_GetProcAddress("glUniform4ivARB");
|
||||
#endif
|
||||
|
||||
if( !glCreateProgramObjectARB || !glDeleteObjectARB || !glUseProgramObjectARB ||
|
||||
!glCreateShaderObjectARB || !glCreateShaderObjectARB || !glCompileShaderARB ||
|
||||
!glGetObjectParameterivARB || !glAttachObjectARB || !glGetInfoLogARB ||
|
||||
!glCreateShaderObjectARB || !glCreateShaderObjectARB || !glCompileShaderARB ||
|
||||
!glGetObjectParameterivARB || !glAttachObjectARB || !glGetInfoLogARB ||
|
||||
!glLinkProgramARB || !glGetUniformLocationARB || !glGetActiveUniformARB ||
|
||||
!glUniform1fvARB || !glUniform2fvARB || !glUniform3fvARB || !glUniform4fvARB ||
|
||||
!glUniform1ivARB || !glUniform2ivARB || !glUniform3ivARB || !glUniform4ivARB)
|
||||
|
@ -119,9 +114,9 @@ void Shader::staticInit()
|
|||
// everything fine when we are here
|
||||
_useShaders = true;
|
||||
|
||||
#endif
|
||||
|
||||
end:
|
||||
end:
|
||||
#endif
|
||||
|
||||
if (_useShaders)
|
||||
debugLog("Shader support enabled.");
|
||||
|
@ -134,9 +129,7 @@ Shader::Shader()
|
|||
numUniforms = -1;
|
||||
uniformsDirty = false;
|
||||
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
g_programObj = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
Shader::~Shader()
|
||||
|
@ -235,7 +228,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);
|
||||
|
@ -336,14 +329,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;
|
||||
}
|
||||
|
@ -403,7 +396,7 @@ void Shader::_queryUniforms()
|
|||
memset(&u.data, 0, sizeof(u.data));
|
||||
u.dirty = true;
|
||||
u.type = type;
|
||||
|
||||
|
||||
if(add)
|
||||
uniforms.push_back(u);
|
||||
else
|
||||
|
@ -439,10 +432,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
|
||||
|
@ -457,10 +450,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
|
||||
|
|
|
@ -45,10 +45,8 @@ public:
|
|||
protected:
|
||||
std::string vertFile, fragFile;
|
||||
std::string vertSrc, fragSrc;
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
GLuint g_programObj;
|
||||
int numUniforms;
|
||||
#endif
|
||||
|
||||
private:
|
||||
static void staticInit();
|
||||
|
@ -64,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];
|
||||
|
||||
|
|
|
@ -78,14 +78,10 @@ Bone::Bone() : Quad()
|
|||
|
||||
minDist = maxDist = 128;
|
||||
reverse = false;
|
||||
selectable = true;
|
||||
originalRenderPass = 0;
|
||||
}
|
||||
/*
|
||||
void Bone::createStrip(bool vert, int num)
|
||||
{
|
||||
Quad::createStrip(vert, num);
|
||||
changeStrip.resize(num);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
void Bone::destroy()
|
||||
{
|
||||
|
@ -141,7 +137,7 @@ Quad* Bone::addFrame(const std::string &gfx)
|
|||
|
||||
void Bone::showFrame(int idx)
|
||||
{
|
||||
//float t = 0.1;
|
||||
|
||||
int c = 0;
|
||||
for (Children::iterator i = children.begin(); i != children.end(); i++)
|
||||
{
|
||||
|
@ -179,11 +175,7 @@ void Bone::showFrame(int idx)
|
|||
|
||||
void Bone::setAnimated(int b)
|
||||
{
|
||||
/*
|
||||
std::ostringstream os;
|
||||
os << "setting animated: " << b;
|
||||
debugLog(os.str());
|
||||
*/
|
||||
|
||||
|
||||
animated = b;
|
||||
}
|
||||
|
@ -198,10 +190,7 @@ void Bone::setSegmentProps(int minDist, int maxDist, bool reverse)
|
|||
|
||||
void Bone::updateSegment(Bone *b, const Vector &diff)
|
||||
{
|
||||
/*
|
||||
int maxDist, minDist;
|
||||
maxDist = minDist = 128;
|
||||
*/
|
||||
|
||||
|
||||
float angle = -1;
|
||||
if (diff.getSquaredLength2D() > sqr(maxDist))
|
||||
|
@ -213,21 +202,17 @@ void Bone::updateSegment(Bone *b, const Vector &diff)
|
|||
|
||||
MathFunctions::calculateAngleBetweenVectorsInDegrees(Vector(0,0,0), diff, angle);
|
||||
}
|
||||
else if (diff.getSquaredLength2D() > sqr(minDist)) // 6.3
|
||||
else if (diff.getSquaredLength2D() > sqr(minDist))
|
||||
{
|
||||
b->position += diff*0.05f;
|
||||
|
||||
MathFunctions::calculateAngleBetweenVectorsInDegrees(Vector(0,0,0), diff, angle);
|
||||
|
||||
//b->rotation.interpolateTo(Vector(0,0,angle),0.2);
|
||||
|
||||
}
|
||||
if (angle != -1)
|
||||
{
|
||||
/*
|
||||
std::ostringstream os;
|
||||
os << "rotz: " << b->rotation.z << " angle: " << angle;
|
||||
debugLog(os.str());
|
||||
*/
|
||||
|
||||
|
||||
if (b->rotation.z >= 270 && angle < 90)
|
||||
{
|
||||
|
@ -244,35 +229,15 @@ void Bone::updateSegment(Bone *b, const Vector &diff)
|
|||
|
||||
b->rotation.interpolateTo(Vector(0,0,angle),0.2);
|
||||
}
|
||||
/*
|
||||
else
|
||||
{
|
||||
float angle;
|
||||
MathFunctions::calculateAngleBetweenVectorsInDegrees(Vector(0,0,0), diff, angle);
|
||||
b->rotation.interpolateTo(Vector(0,0,angle),0);
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
void Bone::updateSegments()
|
||||
{
|
||||
if (segmentChain>0 && !segments.empty())
|
||||
{
|
||||
//bool reverse = true;
|
||||
|
||||
/*
|
||||
std::vector<Bone*> segments;
|
||||
Bone *child = (Bone*)(this->children.front());
|
||||
while (child)
|
||||
{
|
||||
segments.push_back(child);
|
||||
|
||||
if (child->children.empty())
|
||||
child = 0;
|
||||
else
|
||||
child = (Bone*)(child->children.front());
|
||||
}
|
||||
*/
|
||||
|
||||
if (!reverse)
|
||||
{
|
||||
|
@ -310,7 +275,7 @@ void Bone::updateSegments()
|
|||
}
|
||||
}
|
||||
|
||||
void BoneCommand::parse(Bone *b, SimpleIStringStream &is)
|
||||
bool BoneCommand::parse(Bone *b, SimpleIStringStream &is)
|
||||
{
|
||||
std::string type;
|
||||
is >> type;
|
||||
|
@ -334,35 +299,38 @@ void BoneCommand::parse(Bone *b, SimpleIStringStream &is)
|
|||
{
|
||||
command = AC_PRT_START;
|
||||
is >> slot;
|
||||
/*
|
||||
Emitter *e = b->emitters[slot];
|
||||
if (e)
|
||||
{
|
||||
e->start();
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
else if (type=="AC_PRT_STOP")
|
||||
{
|
||||
command = AC_PRT_STOP;
|
||||
is >> slot;
|
||||
/*
|
||||
Emitter *e = b->emitters[slot];
|
||||
if (e)
|
||||
{
|
||||
e->stop();
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
else if (type=="AC_SEGS_START")
|
||||
command = AC_SEGS_START;
|
||||
else if (type=="AC_SEGS_STOP")
|
||||
command = AC_SEGS_STOP;
|
||||
else if (type == "AC_SET_PASS")
|
||||
{
|
||||
command = AC_SET_PASS;
|
||||
is >> slot;
|
||||
}
|
||||
else if(type == "AC_RESET_PASS")
|
||||
command = AC_RESET_PASS;
|
||||
else // fail
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << "Failed to parse bone command string: invalid command: " << type;
|
||||
errorLog(os.str());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void BoneCommand::run()
|
||||
{
|
||||
//debugLog("running CMD");
|
||||
|
||||
switch(command)
|
||||
{
|
||||
case AC_SND_PLAY:
|
||||
|
@ -398,6 +366,15 @@ void BoneCommand::run()
|
|||
e->stop();
|
||||
}
|
||||
break;
|
||||
case AC_SET_PASS:
|
||||
b->setRenderPass(slot);
|
||||
break;
|
||||
case AC_RESET_PASS:
|
||||
b->setRenderPass(b->originalRenderPass);
|
||||
break;
|
||||
case AC_SEGS_START:
|
||||
case AC_SEGS_STOP:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -406,7 +383,7 @@ AnimationLayer::AnimationLayer()
|
|||
{
|
||||
lastNewKey = 0;
|
||||
fallThru= 0;
|
||||
//index = -1;
|
||||
|
||||
timer = 0;
|
||||
loop = 0;
|
||||
enqueuedAnimationLoop = 0;
|
||||
|
@ -430,8 +407,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++)
|
||||
|
@ -459,7 +436,7 @@ void AnimationLayer::playAnimation(int idx, int loop)
|
|||
fallThruSpeed = 10;
|
||||
}
|
||||
timeMultiplier = 1;
|
||||
//currentKeyframe = 0;
|
||||
|
||||
currentAnimation = idx;
|
||||
timer = 0;
|
||||
animating = true;
|
||||
|
@ -467,7 +444,7 @@ void AnimationLayer::playAnimation(int idx, int loop)
|
|||
this->loop = loop;
|
||||
|
||||
animationLength = getCurrentAnimation()->getAnimationLength();
|
||||
//doNextKeyframe();
|
||||
|
||||
}
|
||||
|
||||
void AnimationLayer::enqueueAnimation(const std::string& anim, int loop)
|
||||
|
@ -479,7 +456,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))
|
||||
{
|
||||
|
@ -524,7 +501,7 @@ Animation* AnimationLayer::getCurrentAnimation()
|
|||
|
||||
bool AnimationLayer::createTransitionAnimation(const std::string& anim, float time)
|
||||
{
|
||||
//Animation *a = getCurrentAnimation();
|
||||
|
||||
Animation *to = s->getAnimation(anim);
|
||||
if (!to) return false;
|
||||
blendAnimation.keyframes.clear();
|
||||
|
@ -558,6 +535,8 @@ bool AnimationLayer::createTransitionAnimation(const std::string& anim, float ti
|
|||
|
||||
void AnimationLayer::stopAnimation()
|
||||
{
|
||||
if(s->loaded && getCurrentAnimation()->resetPassOnEnd)
|
||||
resetPass();
|
||||
animating = false;
|
||||
if (!enqueuedAnimation.empty())
|
||||
{
|
||||
|
@ -577,6 +556,11 @@ float AnimationLayer::getAnimationLength()
|
|||
return animationLength;
|
||||
}
|
||||
|
||||
Animation::Animation()
|
||||
: resetPassOnEnd(false)
|
||||
{
|
||||
}
|
||||
|
||||
int Animation::getNumKeyframes()
|
||||
{
|
||||
return keyframes.size();
|
||||
|
@ -623,10 +607,7 @@ SkeletalKeyframe *Animation::getFirstKeyframe()
|
|||
|
||||
void Animation::reorderKeyframes()
|
||||
{
|
||||
/*
|
||||
std::vector<SkeletalKeyframe> copy = this->keyframes;
|
||||
keyframes.clear();
|
||||
*/
|
||||
|
||||
for (int i = 0; i < keyframes.size(); i++)
|
||||
{
|
||||
for (int j = 0; j < keyframes.size()-1; j++)
|
||||
|
@ -717,7 +698,7 @@ SkeletalKeyframe *Animation::getNextKeyframe(float t)
|
|||
break;
|
||||
}
|
||||
}
|
||||
// kf++;
|
||||
|
||||
if (kf == -1)
|
||||
return 0;
|
||||
if (kf >= keyframes.size())
|
||||
|
@ -801,17 +782,12 @@ void SkeletalSprite::onUpdate(float dt)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
for (int i = 0; i < bones.size(); i++)
|
||||
{
|
||||
bones[i]->update(dt);
|
||||
}
|
||||
*/
|
||||
|
||||
for (i = 0; i < animLayers.size(); i++)
|
||||
{
|
||||
animLayers[i].update(dt);
|
||||
}
|
||||
//updateBones();
|
||||
|
||||
}
|
||||
|
||||
void AnimationLayer::update(float dt)
|
||||
|
@ -922,26 +898,14 @@ bool SkeletalSprite::saveSkeletal(const std::string &fn)
|
|||
{
|
||||
bone->SetAttribute("rq", this->bones[i]->fileRenderQuad);
|
||||
}
|
||||
if (!this->bones[i]->collisionRects.empty())
|
||||
if (!this->bones[i]->selectable)
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << this->bones[i]->collisionRects.size() << " ";
|
||||
for (int j = 0; j < this->bones[i]->collisionRects.size(); j++)
|
||||
{
|
||||
RectShape *r = &this->bones[i]->collisionRects[j];
|
||||
int x, y, w, h;
|
||||
r->getCWH(&x, &y, &w, &h);
|
||||
os << x << " " << y << " " << w << " " << h << " ";
|
||||
}
|
||||
bone->SetAttribute("crects", os.str().c_str());
|
||||
bone->SetAttribute("sel", this->bones[i]->selectable);
|
||||
}
|
||||
std::ostringstream os;
|
||||
os << this->bones[i]->collidePosition.x << " " << this->bones[i]->collidePosition.y;
|
||||
bone->SetAttribute("cp", os.str().c_str());
|
||||
if (this->bones[i]->rbp)
|
||||
bone->SetAttribute("rbp", this->bones[i]->rbp);
|
||||
if (this->bones[i]->getRenderPass())
|
||||
bone->SetAttribute("pass", this->bones[i]->getRenderPass());
|
||||
if (this->bones[i]->originalRenderPass)
|
||||
bone->SetAttribute("pass", this->bones[i]->originalRenderPass);
|
||||
if (this->bones[i]->offset.x)
|
||||
bone->SetAttribute("offx", this->bones[i]->offset.x);
|
||||
if (this->bones[i]->offset.y)
|
||||
|
@ -970,14 +934,7 @@ bool SkeletalSprite::saveSkeletal(const std::string &fn)
|
|||
os << this->bones[i]->originalScale.x << " " << this->bones[i]->originalScale.y;
|
||||
bone->SetAttribute("sz", os.str().c_str());
|
||||
}
|
||||
/*
|
||||
if (this->bones[i]->color.x != 1 || this->bones[i]->color.y != 1 || this->bones[i]->color.z != 1)
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << this->bones[i]->color.x << " " << this->bones[i]->color.y << " " << this->bones[i]->color.z;
|
||||
bone->SetAttribute("color", os.str().c_str());
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
for (Children::iterator j = this->bones[i]->children.begin(); j != this->bones[i]->children.end(); j++)
|
||||
{
|
||||
|
@ -1005,6 +962,8 @@ bool SkeletalSprite::saveSkeletal(const std::string &fn)
|
|||
Animation *a = &this->animations[i];
|
||||
XMLElement *animation = xml->NewElement("Animation");
|
||||
animation->SetAttribute("name", a->name.c_str());
|
||||
if(a->resetPassOnEnd)
|
||||
animation->SetAttribute("resetPassOnEnd", a->resetPassOnEnd);
|
||||
for (int j = 0; j < a->keyframes.size(); j++)
|
||||
{
|
||||
XMLElement *key = xml->NewElement("Key");
|
||||
|
@ -1093,7 +1052,7 @@ Bone *SkeletalSprite::getBoneByIdx(int idx)
|
|||
return 0;
|
||||
}
|
||||
|
||||
Bone *SkeletalSprite::initBone(int idx, std::string gfx, int pidx, int rbp, std::string name, float cr, bool fh, bool fv, const Vector &cp)
|
||||
Bone *SkeletalSprite::initBone(int idx, std::string gfx, int pidx, int rbp, std::string name, float cr, bool fh, bool fv)
|
||||
{
|
||||
Bone *b = new Bone;
|
||||
b->boneIdx = idx;
|
||||
|
@ -1104,9 +1063,8 @@ Bone *SkeletalSprite::initBone(int idx, std::string gfx, int pidx, int rbp, std:
|
|||
b->renderBeforeParent = rbp;
|
||||
b->pidx = pidx;
|
||||
b->collideRadius = cr;
|
||||
b->collidePosition = cp;
|
||||
b->name = name;
|
||||
//core->generateCollisionMask(b);
|
||||
|
||||
if (fh)
|
||||
b->flipHorizontal();
|
||||
if (fv)
|
||||
|
@ -1150,7 +1108,6 @@ void SkeletalSprite::deleteBones()
|
|||
{
|
||||
(*it)->safeKill();
|
||||
}
|
||||
bones.clear();
|
||||
}
|
||||
|
||||
Animation *SkeletalSprite::getAnimation(const std::string& anim)
|
||||
|
@ -1237,25 +1194,8 @@ void SkeletalSprite::loadSkin(const std::string &fn)
|
|||
b->flipVertical();
|
||||
}
|
||||
|
||||
/*
|
||||
if (boneXml->Attribute("a"))
|
||||
{
|
||||
float alpha = 0;
|
||||
boneXml->Attribute("a", &alpha);
|
||||
b->alpha = alpha;
|
||||
}
|
||||
*/
|
||||
/*
|
||||
// this is for SKINS
|
||||
if (boneXml->Attribute("sz"))
|
||||
{
|
||||
float v1, v2;
|
||||
SimpleIStringStream is(boneXml->Attribute("sz"));
|
||||
is >> v1 >> v2;
|
||||
b->scale = Vector(v1,v2);
|
||||
b->originalScale = b->scale;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1345,7 +1285,6 @@ void SkeletalSprite::loadSkeletal(const std::string &fn)
|
|||
int pidx = -1, rbp=0, cr=0, fh=0, fv=0;
|
||||
|
||||
std::string name;
|
||||
Vector cp;
|
||||
if (bone->Attribute("pidx"))
|
||||
pidx = atoi(bone->Attribute("pidx"));
|
||||
if (bone->Attribute("rbp"))
|
||||
|
@ -1359,39 +1298,14 @@ void SkeletalSprite::loadSkeletal(const std::string &fn)
|
|||
fh = atoi(bone->Attribute("fh"));
|
||||
if (bone->Attribute("fv"))
|
||||
fv = atoi(bone->Attribute("fv"));
|
||||
if (bone->Attribute("cp"))
|
||||
{
|
||||
SimpleIStringStream is(bone->Attribute("cp"));
|
||||
is >> cp.x >> cp.y;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
std::string gfx = bone->Attribute("gfx");
|
||||
Bone *newb = initBone(idx, gfx, pidx, rbp, name, cr, fh, fv, cp);
|
||||
Bone *newb = initBone(idx, gfx, pidx, rbp, name, cr, fh, fv);
|
||||
if (bone->Attribute("offx"))
|
||||
newb->offset.x = atoi(bone->Attribute("offx"));
|
||||
if (bone->Attribute("offy"))
|
||||
newb->offset.y = atoi(bone->Attribute("offy"));
|
||||
|
||||
if (bone->Attribute("crects"))
|
||||
{
|
||||
SimpleIStringStream is(bone->Attribute("crects"));
|
||||
int num = 0;
|
||||
is >> num;
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
RectShape r;
|
||||
int x, y, w, h;
|
||||
is >> x >> y >> w >> h;
|
||||
r.setCWH(x, y, w, h);
|
||||
|
||||
newb->collisionRects.push_back(r);
|
||||
}
|
||||
}
|
||||
|
||||
if (bone->Attribute("prt"))
|
||||
{
|
||||
newb->prt = bone->Attribute("prt");
|
||||
|
@ -1438,7 +1352,9 @@ void SkeletalSprite::loadSkeletal(const std::string &fn)
|
|||
}
|
||||
if (bone->Attribute("pass"))
|
||||
{
|
||||
newb->setRenderPass(atoi(bone->Attribute("pass")));
|
||||
int pass = atoi(bone->Attribute("pass"));
|
||||
newb->originalRenderPass = pass;
|
||||
newb->setRenderPass(pass);
|
||||
}
|
||||
if (bone->Attribute("gc"))
|
||||
{
|
||||
|
@ -1512,6 +1428,10 @@ void SkeletalSprite::loadSkeletal(const std::string &fn)
|
|||
SimpleIStringStream in(bone->Attribute("color"));
|
||||
in >> newb->color.x >> newb->color.y >> newb->color.z;
|
||||
}
|
||||
if (bone->Attribute("sel"))
|
||||
{
|
||||
newb->selectable = bone->BoolAttribute("sel");
|
||||
}
|
||||
bone = bone->NextSiblingElement("Bone");
|
||||
}
|
||||
// attach bones
|
||||
|
@ -1582,6 +1502,7 @@ void SkeletalSprite::loadSkeletal(const std::string &fn)
|
|||
{
|
||||
Animation newAnimation;
|
||||
newAnimation.name = animation->Attribute("name");
|
||||
newAnimation.resetPassOnEnd = animation->BoolAttribute("resetPassOnEnd");
|
||||
stringToLower(newAnimation.name);
|
||||
|
||||
XMLElement *key = animation->FirstChildElement("Key");
|
||||
|
@ -1617,7 +1538,7 @@ void SkeletalSprite::loadSkeletal(const std::string &fn)
|
|||
for (int i = 0; i < b.strip.size(); i++)
|
||||
{
|
||||
is >> b.strip[i].x >> b.strip[i].y;
|
||||
//b.strip[i].y *= 10;
|
||||
|
||||
}
|
||||
}
|
||||
if (key->Attribute("sz"))
|
||||
|
@ -1675,9 +1596,16 @@ void SkeletalSprite::loadSkeletal(const std::string &fn)
|
|||
if (b)
|
||||
{
|
||||
BoneCommand bcmd;
|
||||
bcmd.parse(b, is);
|
||||
if(!bcmd.parse(b, is))
|
||||
break;
|
||||
newSkeletalKeyframe.commands.push_back(bcmd);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << "SkeletalSprite::loadSkeletal: File " << fn << " anim " << newAnimation.name << " specifies non-existing bone idx " << bidx;
|
||||
errorLog(os.str());
|
||||
}
|
||||
}
|
||||
}
|
||||
// generate empty bone keys
|
||||
|
@ -1713,6 +1641,36 @@ void SkeletalSprite::setTime(float time, int layer)
|
|||
animLayers[layer].timer = time;
|
||||
}
|
||||
|
||||
void AnimationLayer::resetPass()
|
||||
{
|
||||
for (int i = 0; i < s->bones.size(); i++)
|
||||
{
|
||||
Bone *b = s->bones[i];
|
||||
if (contains(b))
|
||||
b->setRenderPass(b->originalRenderPass);
|
||||
}
|
||||
}
|
||||
|
||||
bool AnimationLayer::contains(const Bone *b) const
|
||||
{
|
||||
const int idx = b->boneIdx;
|
||||
if (!ignoreBones.empty())
|
||||
{
|
||||
for (int j = 0; j < ignoreBones.size(); j++)
|
||||
if (idx == ignoreBones[j])
|
||||
return false;
|
||||
}
|
||||
else if (!includeBones.empty())
|
||||
{
|
||||
for (int j = 0; j < includeBones.size(); j++)
|
||||
if (idx == includeBones[j])
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void AnimationLayer::updateBones()
|
||||
{
|
||||
if (!animating && !(&s->animLayers[0] == this) && fallThru == 0) return;
|
||||
|
@ -1723,10 +1681,7 @@ void AnimationLayer::updateBones()
|
|||
float t1 = key1->t;
|
||||
float t2 = key2->t;
|
||||
|
||||
/*
|
||||
if (key1 == key2)
|
||||
stopAnimation();
|
||||
*/
|
||||
|
||||
|
||||
float diff = t2-t1;
|
||||
float dt;
|
||||
|
@ -1755,10 +1710,8 @@ void AnimationLayer::updateBones()
|
|||
}
|
||||
lastNewKey = key2;
|
||||
|
||||
bool c = 0;
|
||||
for (int i = 0; i < s->bones.size(); i++)
|
||||
{
|
||||
int idx = s->bones[i]->boneIdx;
|
||||
Bone *b = s->bones[i];
|
||||
|
||||
if (b->segmentChain == 1)
|
||||
|
@ -1767,31 +1720,9 @@ void AnimationLayer::updateBones()
|
|||
}
|
||||
if (b->segmentChain < 2)
|
||||
{
|
||||
c=0;
|
||||
if (!ignoreBones.empty())
|
||||
if (b->animated != Bone::ANIM_NONE && contains(b))
|
||||
{
|
||||
for (int j = 0; j < ignoreBones.size(); j++)
|
||||
{
|
||||
if (idx == ignoreBones[j])
|
||||
{ c=1; break; }
|
||||
}
|
||||
}
|
||||
else if (!includeBones.empty())
|
||||
{
|
||||
c = 1;
|
||||
for (int j = 0; j < includeBones.size(); j++)
|
||||
{
|
||||
if (idx == includeBones[j])
|
||||
{ c=0; break; }
|
||||
}
|
||||
}
|
||||
if (b->animated==Bone::ANIM_NONE)
|
||||
{
|
||||
c = 1;
|
||||
}
|
||||
if (!c)
|
||||
{
|
||||
|
||||
int idx = b->boneIdx;
|
||||
BoneKeyframe *bkey1 = key1->getBoneKeyframe(idx);
|
||||
BoneKeyframe *bkey2 = key2->getBoneKeyframe(idx);
|
||||
if (bkey1 && bkey2)
|
||||
|
@ -1858,16 +1789,7 @@ void SkeletalSprite::updateBones()
|
|||
animLayers[i].updateBones();
|
||||
}
|
||||
}
|
||||
/*
|
||||
for (int i = animLayers.size()-1; i >= 0; i--)
|
||||
{
|
||||
if (animLayers[i].animating)
|
||||
{
|
||||
animLayers[i].updateBones();
|
||||
return;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -1894,7 +1816,7 @@ Bone* SkeletalSprite::getSelectedBone(bool mouseBased)
|
|||
if (bones[i]->renderQuad || core->getShiftState())
|
||||
{
|
||||
bones[i]->color = Vector(1,1,1);
|
||||
if (bones[i]->renderQuad && bones[i]->isCoordinateInsideWorld(p))
|
||||
if (bones[i]->selectable && bones[i]->renderQuad && bones[i]->isCoordinateInsideWorld(p))
|
||||
{
|
||||
float dist = (bones[i]->getWorldPosition() - p).getSquaredLength2D();
|
||||
if (dist <= closestDist)
|
||||
|
@ -1939,17 +1861,31 @@ void SkeletalSprite::setSelectedBone(int b)
|
|||
|
||||
void SkeletalSprite::selectPrevBone()
|
||||
{
|
||||
selectedBone++;
|
||||
if (selectedBone >= bones.size())
|
||||
selectedBone = 0;
|
||||
const int oldsel = selectedBone;
|
||||
do
|
||||
{
|
||||
selectedBone++;
|
||||
if(selectedBone == oldsel)
|
||||
break;
|
||||
if (selectedBone >= bones.size())
|
||||
selectedBone = 0;
|
||||
}
|
||||
while (!bones[selectedBone]->selectable);
|
||||
updateSelectedBoneColor();
|
||||
}
|
||||
|
||||
void SkeletalSprite::selectNextBone()
|
||||
{
|
||||
selectedBone--;
|
||||
if (selectedBone < 0)
|
||||
selectedBone = bones.size()-1;
|
||||
const int oldsel = selectedBone;
|
||||
do
|
||||
{
|
||||
selectedBone--;
|
||||
if(selectedBone == oldsel)
|
||||
break;
|
||||
if (selectedBone < 0)
|
||||
selectedBone = bones.size()-1;
|
||||
}
|
||||
while (!bones[selectedBone]->selectable);
|
||||
updateSelectedBoneColor();
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,9 @@ enum AnimationCommand
|
|||
AC_SEGS_START ,
|
||||
AC_FRM_SHOW ,
|
||||
AC_SND_PLAY ,
|
||||
AC_SEGS_STOP
|
||||
AC_SEGS_STOP,
|
||||
AC_SET_PASS,
|
||||
AC_RESET_PASS,
|
||||
};
|
||||
|
||||
class ParticleEffect;
|
||||
|
@ -61,7 +63,7 @@ public:
|
|||
std::map<int, ParticleEffect*> emitters;
|
||||
std::string prt;
|
||||
std::vector<Vector> changeStrip;
|
||||
|
||||
|
||||
bool generateCollisionMask;
|
||||
int animated;
|
||||
Vector originalScale;
|
||||
|
@ -75,12 +77,13 @@ public:
|
|||
|
||||
SkeletalSprite *skeleton;
|
||||
|
||||
|
||||
|
||||
void setSegmentProps(int minDist, int maxDist, bool reverse);
|
||||
Vector segmentOffset;
|
||||
|
||||
bool fileRenderQuad;
|
||||
|
||||
bool selectable;
|
||||
int originalRenderPass; // stores the render pass originally set in the XML file. For AC_RESET_PASS.
|
||||
|
||||
protected:
|
||||
int minDist, maxDist, reverse;
|
||||
|
@ -90,7 +93,7 @@ protected:
|
|||
class BoneCommand
|
||||
{
|
||||
public:
|
||||
void parse(Bone *b, SimpleIStringStream &is);
|
||||
bool parse(Bone *b, SimpleIStringStream &is);
|
||||
void run();
|
||||
AnimationCommand command;
|
||||
Bone *b;
|
||||
|
@ -102,7 +105,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;
|
||||
|
@ -131,6 +134,7 @@ public:
|
|||
class Animation
|
||||
{
|
||||
public:
|
||||
Animation();
|
||||
std::string name;
|
||||
typedef std::vector <SkeletalKeyframe> Keyframes;
|
||||
Keyframes keyframes;
|
||||
|
@ -138,7 +142,7 @@ public:
|
|||
SkeletalKeyframe *getLastKeyframe();
|
||||
SkeletalKeyframe *getFirstKeyframe();
|
||||
SkeletalKeyframe *getPrevKeyframe(float t);
|
||||
SkeletalKeyframe *getNextKeyframe(float t);
|
||||
SkeletalKeyframe *getNextKeyframe(float t);
|
||||
void cloneKey(int key, float toffset);
|
||||
void deleteKey(int key);
|
||||
void reorderKeyframes();
|
||||
|
@ -146,6 +150,7 @@ public:
|
|||
int getSkeletalKeyframeIndex(SkeletalKeyframe *skey);
|
||||
int getNumKeyframes();
|
||||
void reverse();
|
||||
bool resetPassOnEnd;
|
||||
};
|
||||
|
||||
class SkeletalSprite;
|
||||
|
@ -153,10 +158,10 @@ class SkeletalSprite;
|
|||
class AnimationLayer
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
//----
|
||||
AnimationLayer();
|
||||
void setSkeletalSprite(SkeletalSprite *s);
|
||||
void setSkeletalSprite(SkeletalSprite *s);
|
||||
Animation *getCurrentAnimation();
|
||||
void animate(const std::string &animation, int loop);
|
||||
void update(float dt);
|
||||
|
@ -170,8 +175,9 @@ public:
|
|||
float transitionAnimate(std::string anim, float time, int loop);
|
||||
void setTimeMultiplier(float t);
|
||||
bool isAnimating();
|
||||
//float lerp(float v1, float v2, float dt, int lerpType);
|
||||
|
||||
bool contains(const Bone *b) const;
|
||||
void resetPass();
|
||||
|
||||
//----
|
||||
float fallThru;
|
||||
float fallThruSpeed;
|
||||
|
@ -181,7 +187,7 @@ public:
|
|||
SkeletalSprite *s;
|
||||
|
||||
SkeletalKeyframe *lastNewKey;
|
||||
//int index;
|
||||
|
||||
float timer;
|
||||
int loop;
|
||||
Animation blendAnimation;
|
||||
|
@ -194,13 +200,13 @@ public:
|
|||
int currentAnimation;
|
||||
bool animating;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
class SkeletalSprite : public RenderObject
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
SkeletalSprite();
|
||||
void loadSkeletal(const std::string &fn);
|
||||
bool saveSkeletal(const std::string &fn);
|
||||
|
@ -209,9 +215,9 @@ public:
|
|||
Bone *getBoneByIdx(int idx);
|
||||
Bone *getBoneByName(const std::string &name);
|
||||
void animate(const std::string &animation, int loop = 0, int layer=0);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void setTime(float time, int layer=0);
|
||||
|
||||
void updateBones();
|
||||
|
@ -223,12 +229,12 @@ public:
|
|||
|
||||
bool isAnimating(int layer=0);
|
||||
|
||||
void setTimeMultiplier(float t, int layer=0);
|
||||
void setTimeMultiplier(float t, int layer=0);
|
||||
|
||||
Bone* getSelectedBone(bool mouseBased = true);
|
||||
Animation *getCurrentAnimation(int layer=0);
|
||||
|
||||
|
||||
|
||||
void nextAnimation();
|
||||
void prevAnimation();
|
||||
void lastAnimation();
|
||||
|
@ -237,9 +243,9 @@ public:
|
|||
|
||||
|
||||
void setFreeze(bool f);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Animation *getAnimation(const std::string& anim);
|
||||
|
||||
std::vector<Animation> animations;
|
||||
|
@ -263,7 +269,7 @@ public:
|
|||
|
||||
static std::string animationPath, skinPath, secondaryAnimationPath;
|
||||
static void clearCache();
|
||||
|
||||
|
||||
protected:
|
||||
bool frozen;
|
||||
RenderObject *animKeyNotify;
|
||||
|
@ -271,7 +277,7 @@ protected:
|
|||
int selectedBone;
|
||||
friend class AnimationLayer;
|
||||
std::vector<AnimationLayer> animLayers;
|
||||
Bone* initBone(int idx, std::string gfx, int pidx, int rbp=0, std::string name="", float cr=0, bool fh=false, bool fv=false, const Vector &cp=Vector(0,0,0));
|
||||
Bone* initBone(int idx, std::string gfx, int pidx, int rbp=0, std::string name="", float cr=0, bool fh=false, bool fv=false);
|
||||
void deleteBones();
|
||||
void onUpdate(float dt);
|
||||
};
|
||||
|
|
|
@ -69,8 +69,8 @@ void Slider::onUpdate(float dt)
|
|||
{
|
||||
RenderObject::onUpdate(dt);
|
||||
|
||||
if (alpha.x != 1) return;
|
||||
|
||||
if (alpha.x != 1) return;
|
||||
|
||||
bool b = (core->mouse.buttons.left || core->mouse.buttons.right) && fabsf(core->mouse.position.y-position.y) < grabRadius;
|
||||
if (!b && inSlider)
|
||||
inSlider = false;
|
||||
|
@ -111,7 +111,7 @@ void Slider::onUpdate(float dt)
|
|||
if (inSlider)
|
||||
{
|
||||
slider.position.x = core->mouse.position.x - position.x + off;
|
||||
//slider.position.interpolateTo(Vector(core->mouse.position.x - position.x), dt*2);
|
||||
|
||||
int w2 = sliderLength/2;
|
||||
if (slider.position.x > w2)
|
||||
{
|
||||
|
@ -177,7 +177,7 @@ void CheckBox::onUpdate(float dt)
|
|||
{
|
||||
if (!wasDown)
|
||||
{
|
||||
//debugLog("setting wasDown");
|
||||
|
||||
wasDown = true;
|
||||
}
|
||||
}
|
||||
|
@ -185,9 +185,9 @@ void CheckBox::onUpdate(float dt)
|
|||
{
|
||||
if (wasDown)
|
||||
{
|
||||
//debugLog("changing value");
|
||||
|
||||
wasDown = false;
|
||||
if (value !=0)
|
||||
if (value !=0)
|
||||
{ value = 0; }
|
||||
else
|
||||
{ value= 1; }
|
||||
|
|
|
@ -22,22 +22,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include "Core.h"
|
||||
#include "SoundManager.h"
|
||||
#include "Base.h"
|
||||
#include "PackRead.h"
|
||||
|
||||
#if defined(BBGE_BUILD_FMODEX)
|
||||
#ifdef BBGE_BUILD_FMOD_OPENAL_BRIDGE
|
||||
#ifdef BBGE_BUILD_FMOD_OPENAL_BRIDGE
|
||||
#include "FmodOpenALBridge.h"
|
||||
#else
|
||||
#else
|
||||
#include <fmod.h>
|
||||
#include <fmod.hpp>
|
||||
#ifdef BBGE_BUILD_WINDOWS
|
||||
#pragma comment(lib, "fmodex_vc.lib")
|
||||
#endif
|
||||
#pragma comment(lib, "fmodex_vc.lib")
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
#endif
|
||||
|
||||
SoundManager *sound = 0;
|
||||
|
||||
|
@ -49,7 +44,6 @@ std::string fileType = ".ogg";
|
|||
|
||||
namespace SoundCore
|
||||
{
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
|
||||
typedef std::map<std::string, FMOD::Sound*> SoundMap;
|
||||
SoundMap soundMap;
|
||||
|
@ -78,7 +72,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;
|
||||
|
@ -111,24 +105,23 @@ namespace SoundCore
|
|||
}
|
||||
fadeChs.push_back(fadeCh);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
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.
|
||||
|
||||
*/
|
||||
|
||||
|
@ -201,7 +194,6 @@ FMOD_RESULT F_CALLBACK myseek(void *handle, unsigned int pos, void *userdata)
|
|||
|
||||
void SoundManager::pause()
|
||||
{
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
debugLog("SoundManager::pause");
|
||||
|
||||
debugLog("mus");
|
||||
|
@ -223,14 +215,12 @@ void SoundManager::pause()
|
|||
debugLog("update");
|
||||
result = SoundCore::system->update();
|
||||
checkError();
|
||||
|
||||
|
||||
debugLog("done");
|
||||
#endif
|
||||
}
|
||||
|
||||
void SoundManager::resume()
|
||||
{
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
debugLog("SoundManager::resume");
|
||||
|
||||
debugLog("mus");
|
||||
|
@ -254,7 +244,6 @@ void SoundManager::resume()
|
|||
checkError();
|
||||
|
||||
debugLog("done");
|
||||
#endif
|
||||
}
|
||||
|
||||
Buffer SoundManager::getBuffer(const std::string &name)
|
||||
|
@ -286,91 +275,67 @@ SoundManager::SoundManager(const std::string &defaultDevice)
|
|||
|
||||
loadProgressCallback = NULL;
|
||||
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
|
||||
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;
|
||||
|
||||
debugLog("getVersion");
|
||||
result = SoundCore::system->getVersion(&version);
|
||||
if (checkError()) goto get_out;
|
||||
if (checkError()) goto get_out;
|
||||
|
||||
if (version < FMOD_VERSION)
|
||||
{
|
||||
debugLog("getVersion");
|
||||
result = SoundCore::system->getVersion(&version);
|
||||
if (checkError()) goto get_out;
|
||||
|
||||
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;
|
||||
|
||||
debugLog("init 2");
|
||||
result = SoundCore::system->init(channels, FMOD_INIT_NORMAL, 0); /* Replace with whatever channel count and flags you use! */
|
||||
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! */
|
||||
if (checkError()) goto get_out;
|
||||
}
|
||||
|
||||
#ifdef BBGE_BUILD_FMOD_OPENAL_BRIDGE
|
||||
SoundCore::system->getNumChannels(&channels);
|
||||
#endif
|
||||
|
||||
//FMOD::Debug_SetLevel(FMOD_DEBUG_LEVEL_ALL);
|
||||
|
||||
/*
|
||||
result = FMOD::System_Create(&SoundCore::system); // Create the main system object.
|
||||
if (checkError())
|
||||
{
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
result = SoundCore::system->init(64, FMOD_INIT_NORMAL, 0); // Initialize FMOD.
|
||||
if (result == FMOD_ERR_OUTPUT_CREATEBUFFER)
|
||||
{
|
||||
debugLog("FMOD_ERR_OUTPUT_CREATEBUFFER, setting stereo speaker mode");
|
||||
SoundCore::system->setSpeakerMode(FMOD_SPEAKERMODE_STEREO);
|
||||
result = SoundCore::system->init(64, FMOD_INIT_NORMAL, 0);
|
||||
if (checkError())
|
||||
exit(-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (checkError())
|
||||
exit(-1);
|
||||
}
|
||||
*/
|
||||
|
||||
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);
|
||||
|
@ -397,12 +362,6 @@ SoundManager::SoundManager(const std::string &defaultDevice)
|
|||
if (checkError()) { dspReverb = 0; }
|
||||
|
||||
|
||||
//dspReverb->setParameter(FMOD_DSP_REVERB_ROOMSIZE, 0.5);
|
||||
//dspReverb->setParameter(FMOD_DSP_REVERB_DAMP, 0.5);
|
||||
//dspReverb->setParameter(FMOD_DSP_REVERB_WETMIX, 0.33);
|
||||
//dspReverb->setParameter(FMOD_DSP_REVERB_DRYMIX, 0.66);
|
||||
//dspReverb->setParameter(FMOD_DSP_REVERB_WIDTH, 1.0);
|
||||
//dspReverb->setParameter(FMOD_DSP_REVERB_MODE, 0); // 0 or 1
|
||||
|
||||
if (dspReverb)
|
||||
{
|
||||
|
@ -415,7 +374,6 @@ SoundManager::SoundManager(const std::string &defaultDevice)
|
|||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
enabled = true;
|
||||
|
||||
|
@ -439,7 +397,6 @@ void SoundManager::toggleEffectMusic(SoundEffectType effect, bool on)
|
|||
{
|
||||
if (!enabled) return;
|
||||
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
|
||||
bool active = false;
|
||||
|
||||
|
@ -453,9 +410,11 @@ void SoundManager::toggleEffectMusic(SoundEffectType effect, bool on)
|
|||
dspFlange->remove();
|
||||
}
|
||||
break;
|
||||
case SFX_NONE:
|
||||
case SFX_MAX:
|
||||
break;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -509,25 +468,14 @@ void SoundManager::setMusicFader(float v, float t)
|
|||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
std::ostringstream os;
|
||||
os << "musicFader " << v << " over " << t;
|
||||
debugLog(os.str());
|
||||
*/
|
||||
|
||||
|
||||
musVol.interpolateTo(Vector(musVol.x, v, musVol.z), t);
|
||||
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
/*
|
||||
result = group_mus->setVolume(musVol.x*musVol.y*v);
|
||||
checkError();
|
||||
*/
|
||||
#endif
|
||||
}
|
||||
|
||||
void SoundManager::error(const std::string &errMsg)
|
||||
{
|
||||
//std::cout << errMsg << std::endl;
|
||||
|
||||
errorLog(errMsg);
|
||||
}
|
||||
|
||||
|
@ -550,17 +498,13 @@ SoundManager::~SoundManager()
|
|||
}
|
||||
soundMap.clear();
|
||||
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
SoundCore::system->release();
|
||||
#endif
|
||||
}
|
||||
|
||||
void SoundManager::stopAllSfx()
|
||||
{
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
if (group_sfx)
|
||||
group_sfx->stop();
|
||||
#endif
|
||||
}
|
||||
|
||||
void SoundManager::stopAll()
|
||||
|
@ -569,36 +513,35 @@ void SoundManager::stopAll()
|
|||
|
||||
void SoundManager::onVoiceEnded()
|
||||
{
|
||||
//debugLog("Voice Ended!");
|
||||
|
||||
event_stopVoice.call();
|
||||
//debugLog("checking vox queue");
|
||||
|
||||
|
||||
if (dspReverb)
|
||||
dspReverb->remove();
|
||||
|
||||
if (!voxQueue.empty())
|
||||
{
|
||||
//debugLog("calling playVoice");
|
||||
|
||||
|
||||
|
||||
std::string vox = voxQueue.front();
|
||||
|
||||
//debugLog("popping voxQueue");
|
||||
|
||||
|
||||
if (!voxQueue.empty())
|
||||
voxQueue.pop();
|
||||
|
||||
//debugLog("calling playVoice");
|
||||
|
||||
|
||||
playVoice(vox, SVT_INTERRUPT);
|
||||
}
|
||||
else
|
||||
{
|
||||
//debugLog("setting music fader");
|
||||
|
||||
setMusicFader(1, 1);
|
||||
sfxFader = 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//debugLog("done onVoiceEnded");
|
||||
}
|
||||
|
||||
|
||||
|
@ -608,19 +551,16 @@ bool SoundManager::isPaused()
|
|||
|
||||
if (!enabled) return paused;
|
||||
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
|
||||
result = masterChannelGroup->getPaused(&paused);
|
||||
checkError();
|
||||
|
||||
#endif
|
||||
|
||||
return paused;
|
||||
}
|
||||
|
||||
void SoundManager::clearFadingSfx()
|
||||
{
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
|
||||
SoundCore::FadeChs::iterator i = fadeChs.begin();
|
||||
for (; i != fadeChs.end(); i++)
|
||||
|
@ -634,7 +574,6 @@ void SoundManager::clearFadingSfx()
|
|||
}
|
||||
SoundCore::fadeChs.clear();
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
@ -648,7 +587,6 @@ void SoundManager::update(float dt)
|
|||
musVol.update(dt);
|
||||
|
||||
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
|
||||
if (musicChannel)
|
||||
{
|
||||
|
@ -669,10 +607,10 @@ void SoundManager::update(float dt)
|
|||
if (musicChannel)
|
||||
{
|
||||
// fader value
|
||||
|
||||
|
||||
result = musicChannel->setVolume(musVol.y*1.0f);
|
||||
checkError();
|
||||
|
||||
|
||||
|
||||
if (musVol.y <= 0 && stopMusicOnFadeOut)
|
||||
{
|
||||
|
@ -741,7 +679,7 @@ void SoundManager::update(float dt)
|
|||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (f->c)
|
||||
{
|
||||
f->c->setVolume(f->v);
|
||||
|
@ -754,15 +692,12 @@ void SoundManager::update(float dt)
|
|||
|
||||
SoundCore::system->update();
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(BBGE_BUILD_BASS20) || defined(BBGE_BUILD_FMODEX) || defined(BBGE_BUILD_SDLMIXER)
|
||||
if (wasPlayingVoice && !isPlayingVoice())
|
||||
{
|
||||
wasPlayingVoice = false;
|
||||
onVoiceEnded();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void SoundManager::fadeMusic(SoundFadeType sft, float t)
|
||||
|
@ -771,7 +706,6 @@ void SoundManager::fadeMusic(SoundFadeType sft, float t)
|
|||
{
|
||||
case SFT_CROSS:
|
||||
{
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
if (musicChannel2)
|
||||
{
|
||||
musicChannel2->stop();
|
||||
|
@ -790,16 +724,13 @@ void SoundManager::fadeMusic(SoundFadeType sft, float t)
|
|||
musicFader2Volume = musVol.y;
|
||||
musicFader2Time = musicFader2Timer = t;
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
break;
|
||||
case SFT_OUT:
|
||||
setMusicFader(0, t);
|
||||
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
stopMusicOnFadeOut = true;
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
//setMusMul(0, t);
|
||||
|
@ -809,7 +740,6 @@ void SoundManager::fadeMusic(SoundFadeType sft, float t)
|
|||
|
||||
bool SoundManager::isPlayingMusic()
|
||||
{
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
|
||||
if (musicChannel)
|
||||
{
|
||||
|
@ -818,13 +748,7 @@ bool SoundManager::isPlayingMusic()
|
|||
return b;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef BBGE_BUILD_BASS20
|
||||
|
||||
return musicStream != 0;
|
||||
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -833,12 +757,10 @@ void SoundManager::setMusicVolume(float v)
|
|||
{
|
||||
musVol.x = v;
|
||||
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
|
||||
result = group_mus->setVolume(v);
|
||||
checkError();
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
void SoundManager::setSfxVolume(float v)
|
||||
|
@ -855,15 +777,12 @@ void SoundManager::setVoiceVolume(float v)
|
|||
{
|
||||
voxVol.x = v;
|
||||
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
result = group_vox->setVolume(v);
|
||||
checkError();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool SoundManager::isPlayingVoice()
|
||||
{
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
|
||||
if (voiceChannel)
|
||||
{
|
||||
|
@ -883,7 +802,6 @@ bool SoundManager::isPlayingVoice()
|
|||
return b;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -901,7 +819,7 @@ bool SoundManager::playVoice(const std::string &name, SoundVoiceType svt, float
|
|||
|
||||
n = name;
|
||||
stringToLower(n);
|
||||
|
||||
|
||||
if (!voicePath2.empty())
|
||||
{
|
||||
fn = voicePath2 + name + fileType;
|
||||
|
@ -952,12 +870,10 @@ bool SoundManager::playVoice(const std::string &name, SoundVoiceType svt, float
|
|||
|
||||
if (playNow)
|
||||
{
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
if (voiceStream)
|
||||
{
|
||||
stopVoice();
|
||||
}
|
||||
#endif
|
||||
|
||||
debugLog("play now");
|
||||
|
||||
|
@ -978,7 +894,6 @@ bool SoundManager::playVoice(const std::string &name, SoundVoiceType svt, float
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
|
||||
|
||||
// FMOD_DEFAULT uses the defaults. These are the same as FMOD_LOOP_OFF | FMOD_2D | FMOD_HARDWARE.
|
||||
|
@ -993,7 +908,7 @@ bool SoundManager::playVoice(const std::string &name, SoundVoiceType svt, float
|
|||
}
|
||||
|
||||
if (voiceStream)
|
||||
{
|
||||
{
|
||||
|
||||
if (!reverbKeyword.empty())
|
||||
{
|
||||
|
@ -1002,7 +917,7 @@ bool SoundManager::playVoice(const std::string &name, SoundVoiceType svt, float
|
|||
if (dspReverb)
|
||||
{
|
||||
bool active = false;
|
||||
|
||||
|
||||
result = dspReverb->getActive(&active);
|
||||
checkError();
|
||||
|
||||
|
@ -1032,7 +947,7 @@ bool SoundManager::playVoice(const std::string &name, SoundVoiceType svt, float
|
|||
|
||||
result = voiceChannel->setChannelGroup(group_vox);
|
||||
checkError();
|
||||
|
||||
|
||||
if (vmod != -1)
|
||||
{
|
||||
result = voiceChannel->setVolume(vmod);
|
||||
|
@ -1042,10 +957,7 @@ bool SoundManager::playVoice(const std::string &name, SoundVoiceType svt, float
|
|||
result = voiceChannel->setPriority(1);
|
||||
checkError();
|
||||
|
||||
/*
|
||||
result = dspReverb->remove();
|
||||
checkError();
|
||||
*/
|
||||
|
||||
|
||||
voiceChannel->setFrequency(1);
|
||||
voiceChannel->setCallback(NULL);
|
||||
|
@ -1060,7 +972,6 @@ bool SoundManager::playVoice(const std::string &name, SoundVoiceType svt, float
|
|||
wasPlayingVoice = true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
lastVoice = n;
|
||||
event_playVoice.call();
|
||||
|
@ -1076,7 +987,6 @@ void SoundManager::updateChannelVolume(void *ch, float v)
|
|||
|
||||
float SoundManager::getVoiceTime()
|
||||
{
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
|
||||
if (isPlayingVoice())
|
||||
{
|
||||
|
@ -1085,7 +995,6 @@ float SoundManager::getVoiceTime()
|
|||
return float(position) * 0.001f;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1094,11 +1003,10 @@ void *SoundManager::playSfx(const PlaySfx &play)
|
|||
{
|
||||
if (!enabled) return 0;
|
||||
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
|
||||
FMOD::Channel *channel = 0;
|
||||
FMOD::Sound *sound = 0;
|
||||
|
||||
|
||||
|
||||
if (play.handle)
|
||||
sound = (FMOD::Sound*)play.handle;
|
||||
|
@ -1167,7 +1075,6 @@ void *SoundManager::playSfx(const PlaySfx &play)
|
|||
checkError();
|
||||
|
||||
return channel;
|
||||
#endif
|
||||
|
||||
|
||||
return 0;
|
||||
|
@ -1193,11 +1100,7 @@ bool SoundManager::isPlayingMusic(const std::string &name)
|
|||
std::string test = name;
|
||||
stringToLower(test);
|
||||
|
||||
/*
|
||||
std::ostringstream os;
|
||||
os << "checking lastMusic: " << lastMusic << " test: " << test;
|
||||
debugLog(os.str());
|
||||
*/
|
||||
|
||||
|
||||
if (test == lastMusic)
|
||||
return true;
|
||||
|
@ -1247,7 +1150,6 @@ bool SoundManager::playMusic(const std::string &name, SoundLoopType slt, SoundFa
|
|||
lastMusic = name;
|
||||
stringToLower(lastMusic);
|
||||
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
|
||||
if (sft == SFT_CROSS)
|
||||
{
|
||||
|
@ -1299,7 +1201,7 @@ bool SoundManager::playMusic(const std::string &name, SoundLoopType slt, SoundFa
|
|||
|
||||
if (musicStream)
|
||||
{
|
||||
|
||||
|
||||
|
||||
result = SoundCore::system->playSound(FMOD_CHANNEL_FREE, musicStream, true, &musicChannel);
|
||||
checkError();
|
||||
|
@ -1341,7 +1243,6 @@ bool SoundManager::playMusic(const std::string &name, SoundLoopType slt, SoundFa
|
|||
{
|
||||
debugLog("Failed to create music stream: " + fn);
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1349,7 +1250,6 @@ bool SoundManager::playMusic(const std::string &name, SoundLoopType slt, SoundFa
|
|||
|
||||
void SoundManager::stopMusic()
|
||||
{
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
if (musicChannel)
|
||||
{
|
||||
musicChannel->stop();
|
||||
|
@ -1362,14 +1262,12 @@ void SoundManager::stopMusic()
|
|||
musicStream = 0;
|
||||
musicChannel = 0;
|
||||
}
|
||||
#endif
|
||||
playingMusicOnce = false;
|
||||
lastMusic = "";
|
||||
}
|
||||
|
||||
void SoundManager::stopSfx(void *channel)
|
||||
{
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
if (!channel) return;
|
||||
FMOD::Channel *ch = (FMOD::Channel*)channel;
|
||||
if (ch)
|
||||
|
@ -1378,12 +1276,10 @@ void SoundManager::stopSfx(void *channel)
|
|||
checkError();
|
||||
ch = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void SoundManager::fadeSfx(void *channel, SoundFadeType sft, float t)
|
||||
{
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
if (!channel) return;
|
||||
if (sft == SFT_OUT)
|
||||
{
|
||||
|
@ -1399,13 +1295,11 @@ void SoundManager::fadeSfx(void *channel, SoundFadeType sft, float t)
|
|||
SoundCore::addFadeCh(f);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void SoundManager::stopVoice()
|
||||
{
|
||||
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
if (voiceChannel)
|
||||
{
|
||||
bool playing = false;
|
||||
|
@ -1426,7 +1320,6 @@ void SoundManager::stopVoice()
|
|||
voiceStream = 0;
|
||||
}
|
||||
onVoiceEnded();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
@ -1442,7 +1335,7 @@ void loadCacheSoundsCallback (const std::string &filename, intptr_t param)
|
|||
sm = (SoundManager*)param;
|
||||
if (!sm->enabled)
|
||||
{
|
||||
//sm->erorr();
|
||||
|
||||
debugLog("Disabled: Won't Load Sample ["+filename+"]");
|
||||
return;
|
||||
}
|
||||
|
@ -1509,7 +1402,6 @@ Buffer SoundManager::loadSoundIntoBank(const std::string &filename, const std::s
|
|||
|
||||
stringToLower(name);
|
||||
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
|
||||
FMOD::Sound * sound = SoundCore::soundMap[name];
|
||||
|
||||
|
@ -1536,11 +1428,8 @@ Buffer SoundManager::loadSoundIntoBank(const std::string &filename, const std::s
|
|||
}
|
||||
|
||||
return sound;
|
||||
#endif
|
||||
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
|
||||
#endif
|
||||
|
||||
return Buffer();
|
||||
}
|
||||
|
@ -1563,7 +1452,6 @@ void SoundManager::setModSpeed(float speed)
|
|||
|
||||
void SoundManager::clearLocalSounds()
|
||||
{
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
for (LocalSounds::iterator i = localSounds.begin(); i != localSounds.end(); i++)
|
||||
{
|
||||
std::string snd = (*i);
|
||||
|
@ -1573,12 +1461,10 @@ void SoundManager::clearLocalSounds()
|
|||
soundMap[snd] = 0;
|
||||
}
|
||||
localSounds.clear();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool SoundManager::checkError()
|
||||
{
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
std::ostringstream os;
|
||||
|
@ -1620,7 +1506,6 @@ bool SoundManager::checkError()
|
|||
debugLog(os.str());
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,8 +28,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include <set>
|
||||
#include "Vector.h"
|
||||
|
||||
#define BBGE_BUILD_FMODEX
|
||||
|
||||
|
||||
#define BBGE_AUDIO_NOCHANNEL NULL
|
||||
|
||||
|
@ -86,9 +84,8 @@ enum SoundLoadType
|
|||
|
||||
struct PlaySfx
|
||||
{
|
||||
PlaySfx() : priority(0.5), handle(0), vol(1), fade(SFT_NONE),
|
||||
time(0), freq(1), loops(0),
|
||||
maxdist(0), x(0), y(0), relative(true), positional(false) {}
|
||||
PlaySfx() : handle(0), 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;
|
||||
intptr_t handle;
|
||||
|
@ -185,19 +182,6 @@ public:
|
|||
void pause();
|
||||
void resume();
|
||||
|
||||
/*
|
||||
void setMusVol(float v, float t=0);
|
||||
void setSfxVol(float v, float t=0);
|
||||
void setVoxVol(float v, float t=0);
|
||||
|
||||
void setMusMul(float v, float t=0);
|
||||
void setSfxMul(float v, float t=0);
|
||||
void setVoxMul(float v, float t=0);
|
||||
|
||||
float getTotalSfxVol();
|
||||
float getTotalMusVol();
|
||||
float getTotalVoxVol();
|
||||
*/
|
||||
|
||||
|
||||
float getVoiceTime();
|
||||
|
@ -261,6 +245,4 @@ extern SoundManager *sound;
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -62,7 +62,7 @@ SpawnParticleData::SpawnParticleData()
|
|||
spawnArea = SPAWN_CIRCLE;
|
||||
randomVelocityMagnitude = 0;
|
||||
randomVelocityRange = 360;
|
||||
//updateMultiplier = 1;
|
||||
|
||||
copyParentRotation = 0;
|
||||
justOne = didOne = false;
|
||||
flipH = flipV = 0;
|
||||
|
|
|
@ -44,7 +44,7 @@ int StateMachine::getPrevState()
|
|||
{
|
||||
return prevState;
|
||||
}
|
||||
|
||||
|
||||
void StateMachine::perform(int state, float time)
|
||||
{
|
||||
//debugLog("in perform");
|
||||
|
@ -52,7 +52,7 @@ void StateMachine::perform(int state, float time)
|
|||
prevState = currentState;
|
||||
nextState = state;
|
||||
//debugLog("onExitState");
|
||||
|
||||
|
||||
// do this to prevent scripts from repeating endlessly when running main loops
|
||||
enqueuedState = STATE_NONE;
|
||||
|
||||
|
@ -63,9 +63,9 @@ void StateMachine::perform(int state, float time)
|
|||
nextState = STATE_NONE;
|
||||
//debugLog("onActionInit");
|
||||
onEnterState(currentState);
|
||||
|
||||
|
||||
//debugLog("done");
|
||||
}
|
||||
}
|
||||
|
||||
void StateMachine::setState(int state, float time, bool force)
|
||||
{
|
||||
|
@ -95,7 +95,7 @@ void StateMachine::onEnterState(int state)
|
|||
void StateMachine::onExitState(int state)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void StateMachine::stopState(int state)
|
||||
{
|
||||
onExitState(state);
|
||||
|
|
|
@ -28,7 +28,7 @@ class StateMachine
|
|||
public:
|
||||
StateMachine ();
|
||||
virtual ~StateMachine() {}
|
||||
|
||||
|
||||
void setState(int state, float time = -1, bool force = false);
|
||||
void stopState(int state);
|
||||
bool isState(int state);
|
||||
|
@ -41,7 +41,7 @@ public:
|
|||
enum
|
||||
{
|
||||
STATE_NONE = -1
|
||||
};
|
||||
};
|
||||
virtual bool canSetState(int state);
|
||||
|
||||
protected:
|
||||
|
@ -51,14 +51,14 @@ protected:
|
|||
|
||||
int currentState, nextState, prevState, enqueuedState;
|
||||
float stateTime, enqueuedTime, stateExtraDT;
|
||||
|
||||
|
||||
void onUpdate (float dt);
|
||||
void resetStateCounter()
|
||||
{ stateCounter = 0; }
|
||||
|
||||
private:
|
||||
float stateCounter;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -41,7 +41,7 @@ void StateObject::removeState()
|
|||
{
|
||||
clearActions();
|
||||
clearCreatedEvents();
|
||||
//stateManager->getState(name)->eraseRenderObjects();
|
||||
|
||||
}
|
||||
|
||||
void StateObject::addRenderObject(RenderObject *renderObject, int layer)
|
||||
|
@ -71,11 +71,7 @@ StateData::StateData()
|
|||
|
||||
StateData::~StateData()
|
||||
{
|
||||
/*
|
||||
std::ostringstream os;
|
||||
os << "removing " << renderObjects.size() << " render Objects";
|
||||
MessageBox(0,os.str().c_str(),"",MB_OK);
|
||||
*/
|
||||
|
||||
for (int i = 0; i < renderObjects.size(); i++)
|
||||
{
|
||||
removeRenderObject (renderObjects[i]);
|
||||
|
@ -114,7 +110,7 @@ void StateData::removeRenderObjectFromList(RenderObject *renderObject)
|
|||
}
|
||||
|
||||
// assume this only happens on render state end
|
||||
void StateData::eraseRenderObjects()
|
||||
void StateData::eraseRenderObjects()
|
||||
{
|
||||
// why clear garbage here?
|
||||
//core->clearGarbage();
|
||||
|
@ -219,7 +215,7 @@ void StateManager::pushState(const std::string &s)
|
|||
s->stateObject = stateObjects[state];
|
||||
stateObjects[state]->applyState();
|
||||
}
|
||||
|
||||
|
||||
stateChangeFlag = true;
|
||||
}
|
||||
}
|
||||
|
@ -252,31 +248,18 @@ void StateManager::popState()
|
|||
|
||||
std::string StateManager::getNameFromDerivedClassTypeName(const std::string &typeidName)
|
||||
{
|
||||
/*
|
||||
int loc = typeidName.find_last_of("class ");
|
||||
if (loc != std::string::npos)
|
||||
{
|
||||
std::string tmp = typeidName.substr(6, typeidName.length());
|
||||
int loc2 = tmp.find_last_of("::");
|
||||
if (loc2 != std::string::npos)
|
||||
return tmp.substr(loc2+1, tmp.size());
|
||||
else
|
||||
return tmp;
|
||||
}
|
||||
else
|
||||
return typeidName;
|
||||
*/
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
void StateManager::registerStateObject(StateObject *stateObject, const std::string &name)
|
||||
{
|
||||
//const char *c = typeid(*stateObject).name();
|
||||
|
||||
|
||||
stateObject->name = name;
|
||||
stringToLower(stateObject->name);
|
||||
|
||||
//getNameFromDerivedClassTypeName(c);
|
||||
|
||||
if (stateObject->name.empty())
|
||||
{
|
||||
exit_error("StateManager::registerStateObject - Empty name.");
|
||||
|
@ -284,10 +267,7 @@ void StateManager::registerStateObject(StateObject *stateObject, const std::stri
|
|||
|
||||
if (!stateObjects[stateObject->name])
|
||||
stateObjects[stateObject->name] = stateObject;
|
||||
/*
|
||||
if (c)
|
||||
free((void*)c);
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
StateObject *StateManager::addStateInstance(StateObject *s)
|
||||
|
|
|
@ -55,7 +55,7 @@ public:
|
|||
StateObject();
|
||||
virtual ~StateObject();
|
||||
void action(int id, int state);
|
||||
|
||||
|
||||
virtual void applyState(){}
|
||||
virtual void removeState();
|
||||
virtual void update(float dt);
|
||||
|
@ -75,19 +75,19 @@ public:
|
|||
StateManager();
|
||||
~StateManager();
|
||||
|
||||
|
||||
|
||||
void clearStateObjects();
|
||||
|
||||
virtual void applyState (const std::string &state) {}
|
||||
virtual void removeState (std::string state);
|
||||
|
||||
|
||||
|
||||
void enqueueJumpState (const std::string &state, bool force = false, bool staged = false);
|
||||
bool isStateJumpPending();
|
||||
void pushState(const std::string &state);
|
||||
void popState();
|
||||
void popAllStates();
|
||||
|
||||
|
||||
|
||||
StateData *getState(const std::string &state);
|
||||
StateData *getTopStateData();
|
||||
|
@ -120,7 +120,7 @@ protected:
|
|||
typedef std::map<std::string, StateObject*> StateObjectMap;
|
||||
StateObjectMap stateObjects;
|
||||
|
||||
|
||||
|
||||
private:
|
||||
void jumpState (const std::string &state); // call enqueueJumpState
|
||||
};
|
||||
|
|
|
@ -159,9 +159,9 @@ std::string getInputCodeToUserString(int key)
|
|||
use = "Right Mouse Button";
|
||||
if (use == "MOUSE_BUTTON_MIDDLE")
|
||||
use = "Middle Mouse Button";
|
||||
|
||||
|
||||
return use;
|
||||
//return (*i).first;
|
||||
|
||||
}
|
||||
}
|
||||
return "";
|
||||
|
|
|
@ -233,15 +233,7 @@ int TTFText::findLine(const std::string &label)
|
|||
|
||||
void TTFText::onRender()
|
||||
{
|
||||
/*
|
||||
glColor4f(0,0,0,0.5);
|
||||
glBegin(GL_QUADS);
|
||||
glVertex2f(-hw, h/2);
|
||||
glVertex2f(hw, h/2);
|
||||
glVertex2f(hw, -h/2);
|
||||
glVertex2f(-hw, -h/2);
|
||||
glEnd();
|
||||
*/
|
||||
|
||||
|
||||
for (int i = 0; i < text.size(); i++)
|
||||
{
|
||||
|
@ -268,12 +260,5 @@ void TTFText::onRender()
|
|||
RenderObject::lastTextureApplied = 0;
|
||||
|
||||
|
||||
/*
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
glLineWidth(2);
|
||||
glBegin(GL_LINES);
|
||||
glVertex2f(-hw, 5);
|
||||
glVertex2f(hw, 5);
|
||||
glEnd();
|
||||
*/
|
||||
|
||||
}
|
||||
|
|
108
BBGE/Texture.cpp
108
BBGE/Texture.cpp
|
@ -29,46 +29,26 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
//#include "pngLoad.h"
|
||||
//#include "jpeg/jpeglib.h"
|
||||
/*
|
||||
#include <il/il.h>
|
||||
#include <il/ilu.h>
|
||||
#include <il/ilut.h>
|
||||
*/
|
||||
#ifdef Z2D_J2K
|
||||
//..\j2k-codec\j2k-codec.lib
|
||||
#include "..\j2k-codec\j2k-codec.h"
|
||||
#endif
|
||||
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
|
||||
|
||||
GLint Texture::filter = GL_LINEAR;
|
||||
|
||||
GLint Texture::format = 0;
|
||||
#endif
|
||||
bool Texture::useMipMaps = true;
|
||||
|
||||
/*
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
#include "glext/glext.h"
|
||||
#endif
|
||||
*/
|
||||
|
||||
|
||||
Texture::Texture()
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
textures[0] = 0;
|
||||
#endif
|
||||
#ifdef BBGE_BUILD_DIRECTX
|
||||
d3dTexture = 0;
|
||||
#endif
|
||||
width = height = 0;
|
||||
|
||||
repeat = false;
|
||||
repeating = false;
|
||||
pngSetStandardOrientation(0);
|
||||
ow = oh = -1;
|
||||
loadResult = TEX_FAILED;
|
||||
}
|
||||
|
||||
Texture::~Texture()
|
||||
|
@ -78,7 +58,6 @@ Texture::~Texture()
|
|||
|
||||
void Texture::read(int tx, int ty, int w, int h, unsigned char *pixels)
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
if (tx == 0 && ty == 0 && w == this->width && h == this->height)
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, textures[0]);
|
||||
|
@ -93,12 +72,10 @@ void Texture::read(int tx, int ty, int w, int h, unsigned char *pixels)
|
|||
<< tx << "," << ty << "+" << w << "x" << h << ")";
|
||||
debugLog(os.str());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Texture::write(int tx, int ty, int w, int h, const unsigned char *pixels)
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
glBindTexture(GL_TEXTURE_2D, textures[0]);
|
||||
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0,
|
||||
|
@ -144,12 +121,10 @@ void Texture::write(int tx, int ty, int w, int h, const unsigned char *pixels)
|
|||
|
||||
pixels Specifies a pointer to the image data in memory.
|
||||
*/
|
||||
#endif
|
||||
}
|
||||
|
||||
void Texture::unload()
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
if (textures[0])
|
||||
{
|
||||
ow = width;
|
||||
|
@ -164,28 +139,17 @@ void Texture::unload()
|
|||
glDeleteTextures(1, &textures[0]);
|
||||
textures[0] = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Texture::destroy()
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
unload();
|
||||
#endif
|
||||
#ifdef BBGE_BUILD_DIRECTX
|
||||
if (d3dTexture)
|
||||
{
|
||||
d3dTexture->Release();
|
||||
d3dTexture = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
core->removeTexture(this);
|
||||
}
|
||||
|
||||
int Texture::getPixelWidth()
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
int w = 0, h = 0;
|
||||
unsigned int size = 0;
|
||||
unsigned char *data = getBufferAndSize(&w, &h, &size);
|
||||
|
@ -209,14 +173,10 @@ int Texture::getPixelWidth()
|
|||
}
|
||||
free(data);
|
||||
return largestx - smallestx;
|
||||
#elif defined(BBGE_BUILD_DIRECTX)
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int Texture::getPixelHeight()
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
int w = 0, h = 0;
|
||||
unsigned int size = 0;
|
||||
unsigned char *data = getBufferAndSize(&w, &h, &size);
|
||||
|
@ -240,9 +200,6 @@ int Texture::getPixelHeight()
|
|||
}
|
||||
free(data);
|
||||
return largesty - smallesty;
|
||||
#elif defined(BBGE_BUILD_DIRECTX)
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void Texture::reload()
|
||||
|
@ -252,16 +209,13 @@ void Texture::reload()
|
|||
unload();
|
||||
load(loadName);
|
||||
|
||||
/*if (ow != -1 && oh != -1)
|
||||
{
|
||||
width = ow;
|
||||
height = oh;
|
||||
}*/
|
||||
|
||||
debugLog("DONE");
|
||||
}
|
||||
|
||||
bool Texture::load(std::string file)
|
||||
{
|
||||
loadResult = TEX_FAILED;
|
||||
if (file.size()<4)
|
||||
{
|
||||
errorLog("Texture Name is Empty or Too Short");
|
||||
|
@ -276,7 +230,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();
|
||||
|
@ -285,12 +239,7 @@ bool Texture::load(std::string file)
|
|||
pos = std::string::npos;
|
||||
}
|
||||
|
||||
/*if (core->debugLogTextures)
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << "pos [" << pos << "], file :" << file;
|
||||
debugLog(os.str());
|
||||
}*/
|
||||
|
||||
|
||||
bool found = exists(file);
|
||||
|
||||
|
@ -308,35 +257,14 @@ bool Texture::load(std::string file)
|
|||
file = localisePathInternalModpath(file);
|
||||
file = core->adjustFilenameCase(file);
|
||||
|
||||
/*
|
||||
std::ostringstream os;
|
||||
os << "Loading texture [" << file << "]";
|
||||
debugLog(os.str());
|
||||
*/
|
||||
|
||||
std::string post = file.substr(file.size()-3, 3);
|
||||
stringToLower(post);
|
||||
if (post == "png")
|
||||
{
|
||||
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
return loadPNG(file);
|
||||
#endif
|
||||
|
||||
#ifdef BBGE_BUILD_DIRECTX
|
||||
D3DXCreateTextureFromFile(core->getD3DDevice(), file.c_str(), &this->d3dTexture);
|
||||
if (!d3dTexture)
|
||||
{
|
||||
errorLog ("failed to load texture");
|
||||
}
|
||||
else
|
||||
{
|
||||
D3DSURFACE_DESC desc;
|
||||
this->d3dTexture->GetLevelDesc(0,&desc);
|
||||
|
||||
width = desc.Width;
|
||||
height = desc.Height;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if (post == "zga")
|
||||
{
|
||||
|
@ -362,7 +290,6 @@ bool Texture::load(std::string file)
|
|||
|
||||
void Texture::apply(bool repeatOverride)
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
glBindTexture(GL_TEXTURE_2D, textures[0]);
|
||||
if (repeat || repeatOverride)
|
||||
{
|
||||
|
@ -382,11 +309,6 @@ void Texture::apply(bool repeatOverride)
|
|||
repeating = false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef BBGE_BUILD_DIRECTX
|
||||
core->getD3DDevice()->SetTexture(0, d3dTexture);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
void Texture::unbind()
|
||||
|
@ -398,13 +320,12 @@ bool Texture::loadPNG(const std::string &file)
|
|||
if (file.empty()) return false;
|
||||
bool good = false;
|
||||
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
|
||||
|
||||
pngInfo info;
|
||||
|
||||
int pngType = PNG_ALPHA;
|
||||
|
||||
|
||||
if (format != 0)
|
||||
{
|
||||
if (format == GL_LUMINANCE_ALPHA)
|
||||
|
@ -430,6 +351,7 @@ bool Texture::loadPNG(const std::string &file)
|
|||
width = info.Width;
|
||||
height = info.Height;
|
||||
good = true;
|
||||
loadResult = TEX_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -441,7 +363,6 @@ bool Texture::loadPNG(const std::string &file)
|
|||
if(memptr)
|
||||
delete [] memptr;
|
||||
|
||||
#endif
|
||||
return good;
|
||||
}
|
||||
|
||||
|
@ -486,6 +407,7 @@ bool Texture::loadTGA(ImageTGA *imageTGA)
|
|||
delete[] (imageTGA->data);
|
||||
free (imageTGA);
|
||||
|
||||
loadResult = TEX_SUCCESS;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -604,8 +526,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;
|
||||
}
|
||||
}
|
||||
|
@ -757,8 +679,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;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue