mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-10-04 05:13:19 +00:00
Merge branch 'experimental' into moreclean
Conflicts: Aquaria/Avatar.cpp Aquaria/BoxElement.cpp Aquaria/BubbleRender.cpp Aquaria/FFTNotes.cpp Aquaria/StarRenderer.cpp Aquaria/WaterFont.cpp Aquaria/resource.h BBGE/AnimatedSprite.cpp BBGE/AnimatedSprite.h BBGE/BloomEffect.cpp BBGE/CShim.cpp BBGE/Collision.cpp BBGE/Collision.h BBGE/Core.cpp BBGE/Core.h BBGE/Cube.cpp BBGE/Cutscene.cpp BBGE/DFSprite.cpp BBGE/DFSprite.h BBGE/Datafile.cpp BBGE/Datafile.h BBGE/Flags.h BBGE/Interpolator.cpp BBGE/Light.cpp BBGE/Light.h BBGE/LightCone.cpp BBGE/Model.cpp BBGE/Model.h BBGE/OggStream.cpp BBGE/PackRead.cpp BBGE/PointSprites.cpp BBGE/RenderObject.cpp BBGE/SkeletalSprite.cpp
This commit is contained in:
commit
d6dc3a8a09
145 changed files with 1977 additions and 8889 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();
|
||||
}
|
||||
}
|
||||
|
@ -296,7 +293,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 +305,7 @@ void AfterEffectManager::renderGrid()
|
|||
glTexCoord2d(0.0f, percentY);
|
||||
glVertex3f(offx, offy, 0.0f);
|
||||
glEnd();
|
||||
|
||||
|
||||
activeShader->unbind();
|
||||
}
|
||||
}
|
||||
|
@ -322,8 +319,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 +330,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 +349,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 +369,6 @@ void AfterEffectManager::renderGridPoints()
|
|||
glEnd();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void AfterEffectManager::unloadDevice()
|
||||
|
@ -438,31 +432,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 +449,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 +463,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 +476,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 +506,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 +516,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;
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ public:
|
|||
this->timeMultiplier = timeMultiplier;
|
||||
}
|
||||
float timeMultiplier;
|
||||
//void go();
|
||||
|
||||
void update(float dt, Vector ** drawGrid, int xDivs, int yDivs);
|
||||
|
||||
float waveLength;
|
||||
|
|
137
BBGE/Base.cpp
137
BBGE/Base.cpp
|
@ -160,7 +160,6 @@ unsigned hash(const std::string &string)
|
|||
return hash;
|
||||
}
|
||||
|
||||
/* hash * 33 + c */
|
||||
|
||||
|
||||
static unsigned char lowerToUpperTable[256];
|
||||
|
@ -351,8 +350,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);
|
||||
{
|
||||
|
@ -363,8 +361,7 @@ void drawCircle(float radius, int stepSize)
|
|||
}
|
||||
glEnd();
|
||||
|
||||
//glEnable(GL_CULL_FACE);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void exit_error(const std::string &message)
|
||||
|
@ -385,9 +382,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)
|
||||
|
@ -404,68 +399,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)
|
||||
{
|
||||
|
@ -561,29 +495,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)
|
||||
{
|
||||
|
@ -592,9 +504,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)
|
||||
{
|
||||
|
@ -725,9 +637,7 @@ 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);
|
||||
|
@ -736,7 +646,7 @@ void forEachFile(std::string path, std::string type, void callback(const std::st
|
|||
hList = FindFirstFile(szDir, &FileData);
|
||||
if (hList == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
//printf("No files found\n\n");
|
||||
|
||||
debugLog("No files of type " + type + " found in path " + path);
|
||||
}
|
||||
else
|
||||
|
@ -748,13 +658,13 @@ void forEachFile(std::string path, std::string type, void callback(const std::st
|
|||
// 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);
|
||||
|
@ -764,12 +674,7 @@ 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;
|
||||
}
|
||||
}
|
||||
|
@ -810,19 +715,14 @@ std::vector<std::string> getFileList(std::string path, std::string type, int par
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
@ -883,18 +783,7 @@ 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)
|
||||
{
|
||||
|
@ -930,14 +819,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
|
||||
|
||||
|
|
65
BBGE/Base.h
65
BBGE/Base.h
|
@ -39,67 +39,25 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#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"
|
||||
|
||||
|
|
1792
BBGE/Core.cpp
1792
BBGE/Core.cpp
File diff suppressed because it is too large
Load diff
669
BBGE/Core.h
669
BBGE/Core.h
|
@ -40,11 +40,7 @@ BUILD_LINUX
|
|||
|
||||
#include "DarkLayer.h"
|
||||
|
||||
/*
|
||||
#ifdef BBGE_BUILD_WINDOWS
|
||||
#include "Joystick.h"
|
||||
#endif
|
||||
*/
|
||||
|
||||
|
||||
#include "FrameBuffer.h"
|
||||
#include "Shader.h"
|
||||
|
@ -102,183 +98,10 @@ class Texture;
|
|||
const int baseVirtualWidth = 800;
|
||||
const int baseVirtualHeight = 600;
|
||||
|
||||
#if (defined(BBGE_BUILD_WINDOWS)) && !defined(BBGE_BUILD_SDL)
|
||||
enum GameKeys
|
||||
{
|
||||
KEY_BACKSPACE = DIK_BACKSPACE,
|
||||
KEY_CAPSLOCK = DIK_CAPSLOCK,
|
||||
KEY_CIRCUMFLEX = DIK_CIRCUMFLEX,
|
||||
KEY_DOWNARROW = DIK_DOWNARROW,
|
||||
KEY_LALT = DIK_LALT,
|
||||
KEY_LEFTARROW = DIK_LEFTARROW,
|
||||
KEY_NUMPADMINUS = DIK_NUMPADMINUS,
|
||||
KEY_NUMPADPERIOD = DIK_NUMPADPERIOD,
|
||||
KEY_NUMPADPLUS = DIK_NUMPADPLUS,
|
||||
KEY_NUMPADSLASH = DIK_NUMPADSLASH,
|
||||
KEY_NUMPADSTAR = DIK_NUMPADSTAR,
|
||||
KEY_PGDN = DIK_PGDN,
|
||||
KEY_PGUP = DIK_PGUP,
|
||||
KEY_RALT = DIK_RALT,
|
||||
KEY_RIGHTARROW = DIK_RIGHTARROW,
|
||||
KEY_UPARROW = DIK_UPARROW,
|
||||
KEY_TILDE = DIK_GRAVE,
|
||||
KEY_0 = DIK_0,
|
||||
KEY_1 = DIK_1,
|
||||
KEY_2 = DIK_2,
|
||||
KEY_3 = DIK_3,
|
||||
KEY_4 = DIK_4,
|
||||
KEY_5 = DIK_5,
|
||||
KEY_6 = DIK_6,
|
||||
KEY_7 = DIK_7,
|
||||
KEY_8 = DIK_8,
|
||||
KEY_9 = DIK_9,
|
||||
KEY_A = DIK_A,
|
||||
KEY_ABNT_C1 = DIK_ABNT_C1,
|
||||
KEY_ABNT_C2 = DIK_ABNT_C2,
|
||||
KEY_ADD = DIK_ADD,
|
||||
KEY_APOSTROPHE = DIK_APOSTROPHE,
|
||||
KEY_APPS = DIK_APPS,
|
||||
KEY_AT = DIK_AT,
|
||||
KEY_AX = DIK_AX,
|
||||
KEY_B = DIK_B,
|
||||
KEY_BACK = DIK_BACK,
|
||||
KEY_BACKSLASH = DIK_BACKSLASH,
|
||||
KEY_C = DIK_C,
|
||||
KEY_CALCULATOR = DIK_CALCULATOR,
|
||||
KEY_CAPITAL = DIK_CAPITAL,
|
||||
KEY_COLON = DIK_COLON,
|
||||
KEY_COMMA = DIK_COMMA,
|
||||
KEY_CONVERT = DIK_CONVERT,
|
||||
KEY_D = DIK_D,
|
||||
KEY_DECIMAL = DIK_DECIMAL,
|
||||
KEY_DELETE = DIK_DELETE,
|
||||
KEY_DIVIDE = DIK_DIVIDE,
|
||||
KEY_DOWN = DIK_DOWN,
|
||||
KEY_E = DIK_E,
|
||||
KEY_END = DIK_END,
|
||||
KEY_EQUALS = DIK_EQUALS,
|
||||
KEY_ESCAPE = DIK_ESCAPE,
|
||||
KEY_F = DIK_F,
|
||||
KEY_F1 = DIK_F1,
|
||||
KEY_F2 = DIK_F2,
|
||||
KEY_F3 = DIK_F3,
|
||||
KEY_F4 = DIK_F4,
|
||||
KEY_F5 = DIK_F5,
|
||||
KEY_F6 = DIK_F6,
|
||||
KEY_F7 = DIK_F7,
|
||||
KEY_F8 = DIK_F8,
|
||||
KEY_F9 = DIK_F9,
|
||||
KEY_F10 = DIK_F10,
|
||||
KEY_F11 = DIK_F11,
|
||||
KEY_F12 = DIK_F12,
|
||||
KEY_F13 = DIK_F13,
|
||||
KEY_F14 = DIK_F14,
|
||||
KEY_F15 = DIK_F15,
|
||||
KEY_G = DIK_G,
|
||||
KEY_GRAVE = DIK_GRAVE,
|
||||
KEY_H = DIK_H,
|
||||
KEY_HOME = DIK_HOME,
|
||||
KEY_I = DIK_I,
|
||||
KEY_INSERT = DIK_INSERT,
|
||||
KEY_J = DIK_J,
|
||||
KEY_K = DIK_K,
|
||||
KEY_KANA = DIK_KANA,
|
||||
KEY_KANJI = DIK_KANJI,
|
||||
KEY_L = DIK_L,
|
||||
KEY_LBRACKET = DIK_LBRACKET,
|
||||
KEY_LCONTROL = DIK_LCONTROL,
|
||||
KEY_LEFT = DIK_LEFT,
|
||||
KEY_LMENU = DIK_LMENU,
|
||||
KEY_LSHIFT = DIK_LSHIFT,
|
||||
KEY_LMETA = DIK_LWIN,
|
||||
KEY_M = DIK_M,
|
||||
KEY_MAIL = DIK_MAIL,
|
||||
KEY_MEDIASELECT = DIK_MEDIASELECT,
|
||||
KEY_MEDIASTOP = DIK_MEDIASTOP,
|
||||
KEY_MINUS = DIK_MINUS,
|
||||
KEY_MULTIPLY = DIK_MULTIPLY,
|
||||
KEY_MUTE = DIK_MUTE,
|
||||
KEY_MYCOMPUTER = DIK_MYCOMPUTER,
|
||||
KEY_N = DIK_N,
|
||||
KEY_NEXT = DIK_NEXT,
|
||||
KEY_NEXTTRACK = DIK_NEXTTRACK,
|
||||
KEY_NOCONVERT = DIK_NOCONVERT,
|
||||
KEY_NUMLOCK = DIK_NUMLOCK,
|
||||
KEY_NUMPAD0 = DIK_NUMPAD0,
|
||||
KEY_NUMPAD1 = DIK_NUMPAD1,
|
||||
KEY_NUMPAD2 = DIK_NUMPAD2,
|
||||
KEY_NUMPAD3 = DIK_NUMPAD3,
|
||||
KEY_NUMPAD4 = DIK_NUMPAD4,
|
||||
KEY_NUMPAD5 = DIK_NUMPAD5,
|
||||
KEY_NUMPAD6 = DIK_NUMPAD6,
|
||||
KEY_NUMPAD7 = DIK_NUMPAD7,
|
||||
KEY_NUMPAD8 = DIK_NUMPAD8,
|
||||
KEY_NUMPAD9 = DIK_NUMPAD9,
|
||||
KEY_NUMPADCOMMA = DIK_NUMPADCOMMA,
|
||||
KEY_NUMPADENTER = DIK_NUMPADENTER,
|
||||
KEY_NUMPADEQUALS = DIK_NUMPADEQUALS,
|
||||
KEY_O = DIK_O,
|
||||
KEY_OEM_102 = DIK_OEM_102,
|
||||
KEY_P = DIK_P,
|
||||
KEY_PAUSE = DIK_PAUSE,
|
||||
KEY_PERIOD = DIK_PERIOD,
|
||||
KEY_PLAYPAUSE = DIK_PLAYPAUSE,
|
||||
KEY_POWER = DIK_POWER,
|
||||
KEY_PREVTRACK = DIK_PREVTRACK,
|
||||
KEY_PRIOR = DIK_PRIOR,
|
||||
KEY_Q = DIK_Q,
|
||||
KEY_R = DIK_R,
|
||||
KEY_RBRACKET = DIK_RBRACKET,
|
||||
KEY_RCONTROL = DIK_RCONTROL,
|
||||
KEY_RETURN = DIK_RETURN,
|
||||
KEY_RIGHT = DIK_RIGHT,
|
||||
KEY_RMENU = DIK_RMENU,
|
||||
KEY_RSHIFT = DIK_RSHIFT,
|
||||
KEY_RMETA = DIK_RWIN,
|
||||
KEY_S = DIK_S,
|
||||
KEY_SCROLL = DIK_SCROLL,
|
||||
KEY_SEMICOLON = DIK_SEMICOLON,
|
||||
KEY_SLASH = DIK_SLASH,
|
||||
KEY_SLEEP = DIK_SLEEP,
|
||||
KEY_SPACE = DIK_SPACE,
|
||||
KEY_STOP = DIK_STOP,
|
||||
KEY_SUBTRACT = DIK_SUBTRACT,
|
||||
KEY_SYSRQ = DIK_SYSRQ,
|
||||
KEY_T = DIK_T,
|
||||
KEY_TAB = DIK_TAB,
|
||||
KEY_U = DIK_U,
|
||||
KEY_UNDERLINE = DIK_UNDERLINE,
|
||||
KEY_UNLABELED = DIK_UNLABELED,
|
||||
KEY_UP = DIK_UP,
|
||||
KEY_V = DIK_V,
|
||||
KEY_VOLUMEDOWN = DIK_VOLUMEDOWN,
|
||||
KEY_VOLUMEUP = DIK_VOLUMEUP,
|
||||
KEY_W = DIK_W,
|
||||
KEY_WAKE = DIK_WAKE,
|
||||
KEY_WEBBACK = DIK_WEBBACK,
|
||||
KEY_WEBFAVORITES = DIK_WEBFAVORITES,
|
||||
KEY_WEBFORWARD = DIK_WEBFORWARD,
|
||||
KEY_WEBHOME = DIK_WEBHOME,
|
||||
KEY_WEBREFRESH = DIK_WEBREFRESH,
|
||||
KEY_WEBSEARCH = DIK_WEBSEARCH,
|
||||
KEY_WEBSTOP = DIK_WEBSTOP,
|
||||
KEY_X = DIK_X,
|
||||
KEY_Y = DIK_Y,
|
||||
KEY_YEN = DIK_YEN,
|
||||
KEY_Z = DIK_Z,
|
||||
KEY_ANYKEY = 4059,
|
||||
KEY_MAXARRAY = 256
|
||||
};
|
||||
#elif defined(BBGE_BUILD_SDL)
|
||||
enum GameKeys
|
||||
{
|
||||
// replace with GLFW equivalent
|
||||
/*
|
||||
KEY_DOWNARROW = GLFW_KEY_DOWN,
|
||||
KEY_RIGHTARROW = GLFW_KEY_RIGHT,
|
||||
KEY_UPARROW = GLFW_KEY_UP,
|
||||
KEY_LEFTARROW = GLFW_KEY_LEFT,
|
||||
*/
|
||||
|
||||
|
||||
|
||||
KEY_LSUPER,
|
||||
KEY_RSUPER,
|
||||
|
@ -287,8 +110,8 @@ enum GameKeys
|
|||
KEY_BACKSPACE,
|
||||
KEY_PRINTSCREEN,
|
||||
|
||||
//KEY_CAPSLOCK,
|
||||
//KEY_CIRCUMFLEX,
|
||||
|
||||
|
||||
KEY_LALT,
|
||||
KEY_RALT,
|
||||
KEY_LSHIFT,
|
||||
|
@ -307,7 +130,7 @@ enum GameKeys
|
|||
KEY_SEMICOLON,
|
||||
KEY_LBRACKET,
|
||||
KEY_RBRACKET,
|
||||
//KEY_RALT,
|
||||
|
||||
KEY_TILDE,
|
||||
KEY_0,
|
||||
KEY_1,
|
||||
|
@ -390,353 +213,6 @@ enum GameKeys
|
|||
KEY_ANYKEY,
|
||||
KEY_MAXARRAY
|
||||
};
|
||||
#elif defined(BBGE_BUILD_XINPUT)
|
||||
enum GameKeys
|
||||
{
|
||||
KEY_LSUPER = 0,
|
||||
KEY_RSUPER = 0,
|
||||
KEY_LMETA = 0,
|
||||
KEY_RMETA = 0,
|
||||
KEY_BACKSPACE = 0,
|
||||
KEY_PRINTSCREEN = 0,
|
||||
KEY_LALT = 0,
|
||||
KEY_RALT = 0,
|
||||
KEY_LSHIFT = 0,
|
||||
KEY_RSHIFT = 0,
|
||||
KEY_LCONTROL = 0,
|
||||
KEY_RCONTROL = 0,
|
||||
KEY_NUMPADMINUS = 0,
|
||||
KEY_NUMPADPERIOD = 0,
|
||||
KEY_NUMPADPLUS = 0,
|
||||
KEY_NUMPADSLASH = 0,
|
||||
KEY_NUMPADSTAR = 0,
|
||||
KEY_PGDN = 0,
|
||||
KEY_PGUP = 0,
|
||||
KEY_TILDE = 0,
|
||||
KEY_0 = 0,
|
||||
KEY_1 = 0,
|
||||
KEY_2 = 0,
|
||||
KEY_3 = 0,
|
||||
KEY_4 = 0,
|
||||
KEY_5 = 0,
|
||||
KEY_6 = 0,
|
||||
KEY_7 = 0,
|
||||
KEY_8 = 0,
|
||||
KEY_9 = 0,
|
||||
KEY_A = 0,
|
||||
KEY_B = 0,
|
||||
KEY_C = 0,
|
||||
KEY_D = 0,
|
||||
KEY_E = 0,
|
||||
KEY_F = 0,
|
||||
KEY_G = 0,
|
||||
KEY_H = 0,
|
||||
KEY_I = 0,
|
||||
KEY_J = 0,
|
||||
KEY_K = 0,
|
||||
KEY_L = 0,
|
||||
KEY_M = 0,
|
||||
KEY_N = 0,
|
||||
KEY_O = 0,
|
||||
KEY_P = 0,
|
||||
KEY_Q = 0,
|
||||
KEY_R = 0,
|
||||
KEY_S = 0,
|
||||
KEY_T = 0,
|
||||
KEY_U = 0,
|
||||
KEY_V = 0,
|
||||
KEY_W = 0,
|
||||
KEY_X = 0,
|
||||
KEY_Y = 0,
|
||||
KEY_Z = 0,
|
||||
|
||||
KEY_LEFT = 0,
|
||||
KEY_RIGHT = 0,
|
||||
KEY_UP = 0,
|
||||
KEY_DOWN = 0,
|
||||
|
||||
KEY_NUMPAD1 = 0,
|
||||
KEY_NUMPAD2 = 0,
|
||||
KEY_NUMPAD3 = 0,
|
||||
KEY_NUMPAD4 = 0,
|
||||
KEY_NUMPAD5 = 0,
|
||||
KEY_NUMPAD6 = 0,
|
||||
KEY_NUMPAD7 = 0,
|
||||
KEY_NUMPAD8 = 0,
|
||||
KEY_NUMPAD9 = 0,
|
||||
KEY_NUMPAD0 = 0,
|
||||
|
||||
KEY_DELETE = 0,
|
||||
KEY_SPACE = 0,
|
||||
KEY_RETURN = 0,
|
||||
KEY_PERIOD = 0,
|
||||
KEY_MINUS = 0,
|
||||
KEY_CAPSLOCK = 0,
|
||||
KEY_SYSRQ = 0,
|
||||
KEY_TAB = 0,
|
||||
KEY_HOME = 0,
|
||||
KEY_END = 0,
|
||||
KEY_COMMA = 0,
|
||||
KEY_SLASH = 0,
|
||||
|
||||
KEY_F1 = 0,
|
||||
KEY_F2 = 0,
|
||||
KEY_F3 = 0,
|
||||
KEY_F4 = 0,
|
||||
KEY_F5 = 0,
|
||||
KEY_F6 = 0,
|
||||
KEY_F7 = 0,
|
||||
KEY_F8 = 0,
|
||||
KEY_F9 = 0,
|
||||
KEY_F10 = 0,
|
||||
KEY_F11 = 0,
|
||||
KEY_F12 = 0,
|
||||
KEY_F13 = 0,
|
||||
KEY_F14 = 0,
|
||||
KEY_F15 = 0,
|
||||
|
||||
KEY_ESCAPE = 0,
|
||||
KEY_ANYKEY = 4059,
|
||||
KEY_MAXARRAY = 256
|
||||
};
|
||||
#elif defined(BBGE_BUILD_GLFW)
|
||||
enum GameKeys
|
||||
{
|
||||
// replace with GLFW equivalent
|
||||
/*
|
||||
KEY_DOWNARROW = GLFW_KEY_DOWN,
|
||||
KEY_RIGHTARROW = GLFW_KEY_RIGHT,
|
||||
KEY_UPARROW = GLFW_KEY_UP,
|
||||
KEY_LEFTARROW = GLFW_KEY_LEFT,
|
||||
*/
|
||||
|
||||
|
||||
KEY_BACKSPACE = GLFW_KEY_BACKSPACE,
|
||||
//KEY_CAPSLOCK = DIK_CAPSLOCK,
|
||||
//KEY_CIRCUMFLEX = DIK_CIRCUMFLEX,
|
||||
KEY_LALT = GLFW_KEY_LALT,
|
||||
KEY_RALT = GLFW_KEY_RALT,
|
||||
KEY_LSHIFT = GLFW_KEY_LSHIFT,
|
||||
KEY_RSHIFT = GLFW_KEY_RSHIFT,
|
||||
KEY_LCONTROL = GLFW_KEY_LCTRL,
|
||||
KEY_RCONTROL = GLFW_KEY_RCTRL,
|
||||
KEY_NUMPADMINUS = GLFW_KEY_KP_SUBTRACT,
|
||||
KEY_NUMPADPERIOD = GLFW_KEY_KP_DECIMAL,
|
||||
KEY_NUMPADPLUS = GLFW_KEY_KP_ADD,
|
||||
KEY_NUMPADSLASH = GLFW_KEY_KP_DIVIDE,
|
||||
KEY_NUMPADSTAR = GLFW_KEY_KP_MULTIPLY,
|
||||
KEY_PGDN = GLFW_KEY_PAGEDOWN,
|
||||
KEY_PGUP = GLFW_KEY_PAGEUP,
|
||||
//KEY_RALT = GLFW_KEY_RALT,
|
||||
KEY_TILDE = '`',
|
||||
KEY_0 = '0',
|
||||
KEY_1 = '1',
|
||||
KEY_2 = '2',
|
||||
KEY_3 = '3',
|
||||
KEY_4 = '4',
|
||||
KEY_5 = '5',
|
||||
KEY_6 = '6',
|
||||
KEY_7 = '7',
|
||||
KEY_8 = '8',
|
||||
KEY_9 = '9',
|
||||
KEY_A = 'A',
|
||||
KEY_B = 'B',
|
||||
KEY_C = 'C',
|
||||
KEY_D = 'D',
|
||||
KEY_E = 'E',
|
||||
KEY_F = 'F',
|
||||
KEY_G = 'G',
|
||||
KEY_H = 'H',
|
||||
KEY_I = 'I',
|
||||
KEY_J = 'J',
|
||||
KEY_K = 'K',
|
||||
KEY_L = 'L',
|
||||
KEY_M = 'M',
|
||||
KEY_N = 'N',
|
||||
KEY_O = 'O',
|
||||
KEY_P = 'P',
|
||||
KEY_Q = 'Q',
|
||||
KEY_R = 'R',
|
||||
KEY_S = 'S',
|
||||
KEY_T = 'T',
|
||||
KEY_U = 'U',
|
||||
KEY_V = 'V',
|
||||
KEY_W = 'W',
|
||||
KEY_X = 'X',
|
||||
KEY_Y = 'Y',
|
||||
KEY_Z = 'Z',
|
||||
|
||||
KEY_LEFT = GLFW_KEY_LEFT,
|
||||
KEY_RIGHT = GLFW_KEY_RIGHT,
|
||||
KEY_UP = GLFW_KEY_UP,
|
||||
KEY_DOWN = GLFW_KEY_DOWN,
|
||||
|
||||
KEY_NUMPAD1 = GLFW_KEY_KP_1,
|
||||
KEY_NUMPAD2 = GLFW_KEY_KP_2,
|
||||
KEY_NUMPAD3 = GLFW_KEY_KP_3,
|
||||
KEY_NUMPAD4 = GLFW_KEY_KP_4,
|
||||
KEY_NUMPAD5 = GLFW_KEY_KP_5,
|
||||
KEY_NUMPAD6 = GLFW_KEY_KP_6,
|
||||
KEY_NUMPAD7 = GLFW_KEY_KP_7,
|
||||
KEY_NUMPAD8 = GLFW_KEY_KP_8,
|
||||
KEY_NUMPAD9 = GLFW_KEY_KP_9,
|
||||
KEY_NUMPAD0 = GLFW_KEY_KP_0,
|
||||
|
||||
KEY_DELETE = GLFW_KEY_DEL,
|
||||
KEY_SPACE = GLFW_KEY_SPACE,
|
||||
// mac os x
|
||||
KEY_RETURN = 13,
|
||||
KEY_PERIOD = '.',
|
||||
KEY_MINUS = '-',
|
||||
KEY_CAPSLOCK = -1,
|
||||
KEY_SYSRQ = '`',
|
||||
KEY_TAB = GLFW_KEY_TAB,
|
||||
KEY_HOME = GLFW_KEY_HOME,
|
||||
KEY_END = GLFW_KEY_END,
|
||||
KEY_COMMA = ',',
|
||||
KEY_SLASH = '/',
|
||||
//KEY_ABNT_C1 = DIK_ABNT_C1,
|
||||
//KEY_ABNT_C2 = DIK_ABNT_C2,
|
||||
/*
|
||||
KEY_ADD = DIK_ADD,
|
||||
KEY_APOSTROPHE = DIK_APOSTROPHE,
|
||||
KEY_APPS = DIK_APPS,
|
||||
KEY_AT = DIK_AT,
|
||||
KEY_AX = DIK_AX,
|
||||
*/
|
||||
/*
|
||||
KEY_B = 'B',
|
||||
KEY_BACK = DIK_BACK,
|
||||
KEY_BACKSLASH = DIK_BACKSLASH,
|
||||
KEY_C = DIK_C,
|
||||
KEY_CALCULATOR = DIK_CALCULATOR,
|
||||
KEY_CAPITAL = DIK_CAPITAL,
|
||||
KEY_COLON = DIK_COLON,
|
||||
KEY_COMMA = DIK_COMMA,
|
||||
KEY_CONVERT = DIK_CONVERT,
|
||||
KEY_D = DIK_D,
|
||||
KEY_DECIMAL = DIK_DECIMAL,
|
||||
KEY_DELETE = DIK_DELETE,
|
||||
KEY_DIVIDE = DIK_DIVIDE,
|
||||
KEY_DOWN = DIK_DOWN,
|
||||
KEY_E = DIK_E,
|
||||
KEY_END = DIK_END,
|
||||
KEY_EQUALS = DIK_EQUALS,
|
||||
KEY_ESCAPE = DIK_ESCAPE,
|
||||
KEY_F = DIK_F,
|
||||
*/
|
||||
KEY_F1 = GLFW_KEY_F1,
|
||||
KEY_F2 = GLFW_KEY_F2,
|
||||
KEY_F3 = GLFW_KEY_F3,
|
||||
KEY_F4 = GLFW_KEY_F4,
|
||||
KEY_F5 = GLFW_KEY_F5,
|
||||
KEY_F6 = GLFW_KEY_F6,
|
||||
KEY_F7 = GLFW_KEY_F7,
|
||||
KEY_F8 = GLFW_KEY_F8,
|
||||
KEY_F9 = GLFW_KEY_F9,
|
||||
KEY_F10 = GLFW_KEY_F10,
|
||||
KEY_F11 = GLFW_KEY_F11,
|
||||
KEY_F12 = GLFW_KEY_F12,
|
||||
KEY_F13 = GLFW_KEY_F13,
|
||||
KEY_F14 = GLFW_KEY_F14,
|
||||
KEY_F15 = GLFW_KEY_F15,
|
||||
/*
|
||||
KEY_G = DIK_G,
|
||||
KEY_GRAVE = DIK_GRAVE,
|
||||
KEY_H = DIK_H,
|
||||
KEY_HOME = DIK_HOME,
|
||||
KEY_I = DIK_I,
|
||||
KEY_INSERT = DIK_INSERT,
|
||||
KEY_J = DIK_J,
|
||||
KEY_K = DIK_K,
|
||||
KEY_KANA = DIK_KANA,
|
||||
KEY_KANJI = DIK_KANJI,
|
||||
KEY_L = DIK_L,
|
||||
KEY_LBRACKET = DIK_LBRACKET,
|
||||
KEY_LCONTROL = DIK_LCONTROL,
|
||||
KEY_LEFT = DIK_LEFT,
|
||||
KEY_LMENU = DIK_LMENU,
|
||||
KEY_LWIN = DIK_LWIN,
|
||||
KEY_M = DIK_M,
|
||||
KEY_MAIL = DIK_MAIL,
|
||||
KEY_MEDIASELECT = DIK_MEDIASELECT,
|
||||
KEY_MEDIASTOP = DIK_MEDIASTOP,
|
||||
KEY_MINUS = DIK_MINUS,
|
||||
KEY_MULTIPLY = DIK_MULTIPLY,
|
||||
KEY_MUTE = DIK_MUTE,
|
||||
KEY_MYCOMPUTER = DIK_MYCOMPUTER,
|
||||
KEY_N = DIK_N,
|
||||
KEY_NEXT = DIK_NEXT,
|
||||
KEY_NEXTTRACK = DIK_NEXTTRACK,
|
||||
KEY_NOCONVERT = DIK_NOCONVERT,
|
||||
KEY_NUMLOCK = DIK_NUMLOCK,
|
||||
KEY_NUMPAD0 = DIK_NUMPAD0,
|
||||
KEY_NUMPAD1 = DIK_NUMPAD1,
|
||||
KEY_NUMPAD2 = DIK_NUMPAD2,
|
||||
KEY_NUMPAD3 = DIK_NUMPAD3,
|
||||
KEY_NUMPAD4 = DIK_NUMPAD4,
|
||||
KEY_NUMPAD5 = DIK_NUMPAD5,
|
||||
KEY_NUMPAD6 = DIK_NUMPAD6,
|
||||
KEY_NUMPAD7 = DIK_NUMPAD7,
|
||||
KEY_NUMPAD8 = DIK_NUMPAD8,
|
||||
KEY_NUMPAD9 = DIK_NUMPAD9,
|
||||
KEY_NUMPADCOMMA = DIK_NUMPADCOMMA,
|
||||
KEY_NUMPADENTER = DIK_NUMPADENTER,
|
||||
KEY_NUMPADEQUALS = DIK_NUMPADEQUALS,
|
||||
KEY_O = DIK_O,
|
||||
KEY_OEM_102 = DIK_OEM_102,
|
||||
KEY_P = DIK_P,
|
||||
KEY_PAUSE = DIK_PAUSE,
|
||||
KEY_PERIOD = DIK_PERIOD,
|
||||
KEY_PLAYPAUSE = DIK_PLAYPAUSE,
|
||||
KEY_POWER = DIK_POWER,
|
||||
KEY_PREVTRACK = DIK_PREVTRACK,
|
||||
KEY_PRIOR = DIK_PRIOR,
|
||||
KEY_Q = DIK_Q,
|
||||
KEY_R = DIK_R,
|
||||
KEY_RBRACKET = DIK_RBRACKET,
|
||||
KEY_RCONTROL = DIK_RCONTROL,
|
||||
KEY_RETURN = DIK_RETURN,
|
||||
KEY_RIGHT = DIK_RIGHT,
|
||||
KEY_RMENU = DIK_RMENU,
|
||||
|
||||
KEY_RWIN = DIK_RWIN,
|
||||
KEY_S = DIK_S,
|
||||
KEY_SCROLL = DIK_SCROLL,
|
||||
KEY_SEMICOLON = DIK_SEMICOLON,
|
||||
KEY_SLASH = DIK_SLASH,
|
||||
KEY_SLEEP = DIK_SLEEP,
|
||||
KEY_SPACE = DIK_SPACE,
|
||||
KEY_STOP = DIK_STOP,
|
||||
KEY_SUBTRACT = DIK_SUBTRACT,
|
||||
KEY_SYSRQ = DIK_SYSRQ,
|
||||
KEY_T = DIK_T,
|
||||
KEY_TAB = DIK_TAB,
|
||||
KEY_U = DIK_U,
|
||||
KEY_UNDERLINE = DIK_UNDERLINE,
|
||||
KEY_UNLABELED = DIK_UNLABELED,
|
||||
KEY_UP = DIK_UP,
|
||||
KEY_V = DIK_V,
|
||||
KEY_VOLUMEDOWN = DIK_VOLUMEDOWN,
|
||||
KEY_VOLUMEUP = DIK_VOLUMEUP,
|
||||
KEY_W = DIK_W,
|
||||
KEY_WAKE = DIK_WAKE,
|
||||
KEY_WEBBACK = DIK_WEBBACK,
|
||||
KEY_WEBFAVORITES = DIK_WEBFAVORITES,
|
||||
KEY_WEBFORWARD = DIK_WEBFORWARD,
|
||||
KEY_WEBHOME = DIK_WEBHOME,
|
||||
KEY_WEBREFRESH = DIK_WEBREFRESH,
|
||||
KEY_WEBSEARCH = DIK_WEBSEARCH,
|
||||
KEY_WEBSTOP = DIK_WEBSTOP,
|
||||
KEY_X = DIK_X,
|
||||
KEY_Y = DIK_Y,
|
||||
KEY_YEN = DIK_YEN,
|
||||
KEY_Z = DIK_Z,
|
||||
*/
|
||||
KEY_ESCAPE = GLFW_KEY_ESC,
|
||||
KEY_ANYKEY = 4059
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
enum ButtonState { UP = 0, DOWN };
|
||||
|
@ -749,7 +225,7 @@ struct MouseButtons
|
|||
right = UP;
|
||||
middle = UP;
|
||||
}
|
||||
|
||||
|
||||
ButtonState left, right, middle;
|
||||
};
|
||||
|
||||
|
@ -797,13 +273,11 @@ public:
|
|||
Vector rightStick;
|
||||
bool inited, xinited;
|
||||
bool anyButton();
|
||||
#ifdef BBGE_BUILD_SDL
|
||||
# ifdef BBGE_BUILD_SDL2
|
||||
SDL_GameController *sdl_controller;
|
||||
SDL_Haptic *sdl_haptic;
|
||||
# endif
|
||||
SDL_Joystick *sdl_joy;
|
||||
#endif
|
||||
#if defined(__LINUX__) && !defined(BBGE_BUILD_SDL2)
|
||||
int eventfd;
|
||||
int16_t effectid;
|
||||
|
@ -820,10 +294,10 @@ enum FollowCameraLock
|
|||
FCL_VERT = 2
|
||||
};
|
||||
|
||||
//RenderObject Layer Type (enable only one)
|
||||
//#define RLT_DYNAMIC // Dynamic list
|
||||
#define RLT_FIXED // Static array
|
||||
//#define RLT_MAP // Mapping
|
||||
|
||||
|
||||
#define RLT_FIXED
|
||||
|
||||
|
||||
typedef std::vector <RenderObject*> RenderObjects;
|
||||
typedef std::list <RenderObject*> RenderObjectList;
|
||||
|
@ -846,48 +320,17 @@ public:
|
|||
|
||||
inline bool empty()
|
||||
{
|
||||
#ifdef RLT_FIXED
|
||||
return objectCount == 0;
|
||||
#endif
|
||||
#ifdef RLT_DYNAMIC
|
||||
return renderObjectList.empty();
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
inline RenderObject *getFirst()
|
||||
{
|
||||
#ifdef RLT_DYNAMIC
|
||||
if (renderObjectList.empty()) return 0;
|
||||
iter = renderObjectList.begin();
|
||||
return *iter;
|
||||
#endif
|
||||
#ifdef RLT_MAP
|
||||
if (renderObjectMap.empty()) return 0;
|
||||
iter = renderObjectMap.begin();
|
||||
return (*iter).second;
|
||||
#endif
|
||||
#ifdef RLT_FIXED
|
||||
iter = 0;
|
||||
return getNext();
|
||||
#endif
|
||||
}
|
||||
|
||||
RenderObject *getNext()
|
||||
{
|
||||
#ifdef RLT_DYNAMIC
|
||||
if (iter == renderObjectList.end()) return 0;
|
||||
iter++;
|
||||
if (iter == renderObjectList.end()) return 0;
|
||||
return *iter;
|
||||
#endif
|
||||
#ifdef RLT_MAP
|
||||
if (iter == renderObjectMap.end()) return 0;
|
||||
iter++;
|
||||
if (iter == renderObjectMap.end()) return 0;
|
||||
return (*iter).second;
|
||||
#endif
|
||||
#ifdef RLT_FIXED
|
||||
const int size = renderObjects.size();
|
||||
int i;
|
||||
for (i = iter; i < size; i++)
|
||||
|
@ -905,7 +348,6 @@ public:
|
|||
iter = i;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -941,20 +383,10 @@ protected:
|
|||
};
|
||||
std::vector<DisplayListElement> displayList;
|
||||
|
||||
#ifdef RLT_DYNAMIC
|
||||
RenderObjectList renderObjectList;
|
||||
RenderObjectList::iterator iter;
|
||||
#endif
|
||||
#ifdef RLT_MAP
|
||||
RenderObjectMap renderObjectMap;
|
||||
RenderObjectMap::iterator iter;
|
||||
#endif
|
||||
#ifdef RLT_FIXED
|
||||
RenderObjects renderObjects;
|
||||
int objectCount;
|
||||
int firstFreeIdx;
|
||||
int iter;
|
||||
#endif
|
||||
};
|
||||
|
||||
class Core : public ActionMapper, public StateManager
|
||||
|
@ -971,10 +403,10 @@ public:
|
|||
void initRenderObjectLayers(int num);
|
||||
|
||||
void applyState(const std::string &state);
|
||||
//bool createGlWindow(char* title, int width, int height, int bits, bool fullscreenflag);
|
||||
|
||||
bool createWindow(int width, int height, int bits, bool fullscreen, std::string windowTitle="");
|
||||
//void setWindowTitle(const std::string &title); // func not yet written
|
||||
void clearBuffers();
|
||||
|
||||
void clearBuffers();
|
||||
void render(int startLayer=-1, int endLayer=-1, bool useFrameBufferIfAvail=true);
|
||||
void showBuffer();
|
||||
void quit();
|
||||
|
@ -989,7 +421,7 @@ public:
|
|||
|
||||
void reloadResources();
|
||||
void unloadResources();
|
||||
|
||||
|
||||
std::string getPreferencesFolder();
|
||||
std::string getUserDataFolder();
|
||||
|
||||
|
@ -1000,9 +432,9 @@ public:
|
|||
|
||||
virtual void shutdown();
|
||||
|
||||
void main(float runTime = -1); // can use main
|
||||
void main(float runTime = -1); // can use main
|
||||
|
||||
|
||||
//void adjustWindowPosition(int x, int y);
|
||||
|
||||
// state functions
|
||||
|
||||
|
@ -1029,9 +461,9 @@ public:
|
|||
|
||||
void setMouseConstraint(bool on);
|
||||
void setMouseConstraintCircle(const Vector& pos, float mouseCircle);
|
||||
|
||||
|
||||
void setReentryInputGrab(int on);
|
||||
|
||||
|
||||
void action(int id, int state){}
|
||||
|
||||
bool exists(const std::string &file);
|
||||
|
@ -1059,15 +491,7 @@ public:
|
|||
|
||||
void resetGraphics(int w, int h, int fullscreen=-1, int vsync=-1, int bpp=-1);
|
||||
|
||||
/*
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
void getWindowHeight(int *height)
|
||||
{glfwGetWindowSize(0, height);}
|
||||
|
||||
void getWindowWidth(int *width)
|
||||
{glfwGetWindowSize(width, 0);}
|
||||
#endif
|
||||
*/
|
||||
|
||||
void setDockIcon(const std::string &ident);
|
||||
|
||||
|
@ -1097,7 +521,7 @@ public:
|
|||
|
||||
RenderObjectLayer *getRenderObjectLayer(int i);
|
||||
std::vector <int> renderObjectLayerOrder;
|
||||
//typedef std::list<RenderObject*> RenderObjects;
|
||||
|
||||
typedef std::vector<RenderObjectLayer> RenderObjectLayers;
|
||||
RenderObjectLayers renderObjectLayers;
|
||||
|
||||
|
@ -1130,7 +554,6 @@ public:
|
|||
|
||||
ParticleManager *particleManager;
|
||||
|
||||
//Scripting::Script script;
|
||||
|
||||
|
||||
void setBaseTextureDirectory(const std::string &baseTextureDirectory)
|
||||
|
@ -1177,29 +600,18 @@ public:
|
|||
|
||||
void applyMatrixStackToWorld();
|
||||
void translateMatrixStack(float x, float y, float z=0);
|
||||
//void translateMatrixStackRelative(float x, float y, float z=0);
|
||||
|
||||
void rotateMatrixStack(float x, float y, float z);
|
||||
void scaleMatrixStack(float x, float y, float z=1);
|
||||
void rotateMatrixStack(float z);
|
||||
void setColor(float r, float g, float b, float a);
|
||||
|
||||
void bindTexture(int stage, unsigned int handle);
|
||||
|
||||
#ifdef BBGE_BUILD_DIRECTX
|
||||
|
||||
void blitD3DVerts(IDirect3DTexture9 *texture, float v1x, float v1y, float v2x, float v2y, float v3x, float v3y, float v4x, float v4y);
|
||||
void blitD3D (IDirect3DTexture9 *texture, int width, int height);
|
||||
void blitD3DPreTrans (IDirect3DTexture9 *texture, float x, float y, int absWidth, int absHeight);
|
||||
void blitD3DEx (IDirect3DTexture9 *texture, int width, int height, float u1=0, float v1=0, float u2=1, float v2=1);
|
||||
void blitD3DGradient(D3DCOLOR ulc0, D3DCOLOR ulc1, D3DCOLOR ulc2, D3DCOLOR ulc3);
|
||||
LPDIRECT3DDEVICE9 getD3DDevice();
|
||||
LPD3DXSPRITE getD3DSprite();
|
||||
LPD3DXMATRIXSTACK getD3DMatrixStack();
|
||||
#endif
|
||||
|
||||
|
||||
bool getKeyState(int k);
|
||||
bool getMouseButtonState(int m);
|
||||
|
||||
|
||||
int currentLayerPass;
|
||||
int keys[KEY_MAXARRAY];
|
||||
virtual void debugLog(const std::string &s);
|
||||
|
@ -1219,20 +631,16 @@ public:
|
|||
void setupRenderPositionAndScale();
|
||||
void setupGlobalResolutionScale();
|
||||
|
||||
|
||||
|
||||
int particlesPaused;
|
||||
|
||||
//JoystickData joystickData[4];
|
||||
|
||||
bool joystickEnabled;
|
||||
bool joystickOverrideMouse;
|
||||
/*
|
||||
int numJoysticks;
|
||||
DIJOYSTATE2 joystate;
|
||||
Joystick* joysticks[4];
|
||||
*/
|
||||
|
||||
|
||||
bool debugLogTextures;
|
||||
|
||||
|
||||
|
||||
Joystick joystick;
|
||||
void setClearColor(const Vector &c);
|
||||
|
@ -1248,7 +656,7 @@ public:
|
|||
bool frameOutputMode;
|
||||
|
||||
int overrideStartLayer, overrideEndLayer;
|
||||
|
||||
|
||||
void setWindowCaption(const std::string &caption, const std::string &icon);
|
||||
|
||||
ParticleEffect* createParticleEffect(const std::string &name, const Vector &position, int layer, float rotz=0);
|
||||
|
@ -1281,7 +689,7 @@ public:
|
|||
Vector center;
|
||||
|
||||
void enable2DWide(int rx, int ry);
|
||||
|
||||
|
||||
void enumerateScreenModes();
|
||||
|
||||
std::vector<ScreenMode> screenModes;
|
||||
|
@ -1319,13 +727,13 @@ protected:
|
|||
|
||||
float old_dt;
|
||||
float current_dt;
|
||||
|
||||
|
||||
std::string debugLogPath;
|
||||
|
||||
virtual void onReloadResources();
|
||||
|
||||
CountedPtr<Texture> doTextureAdd(const std::string &texture, const std::string &name, std::string internalTextureName);
|
||||
|
||||
|
||||
void deleteRenderObjectMemory(RenderObject *r);
|
||||
bool _hasFocus;
|
||||
bool lib_graphics, lib_sound, lib_input;
|
||||
|
@ -1338,9 +746,9 @@ protected:
|
|||
bool mouseConstraint;
|
||||
float mouseCircle;
|
||||
Vector mouseConstraintCenter;
|
||||
|
||||
|
||||
bool doMouseConstraint();
|
||||
|
||||
|
||||
virtual void onMouseInput(){}
|
||||
bool doScreenshot;
|
||||
float baseCullRadius;
|
||||
|
@ -1361,10 +769,10 @@ protected:
|
|||
bool sortFlag;
|
||||
virtual void modifyDt(float &dt){}
|
||||
void setPixelScale(int pixelScaleX, int pixelScaleY);
|
||||
|
||||
|
||||
|
||||
int virtualHeight, virtualWidth;
|
||||
|
||||
|
||||
bool shuttingDown;
|
||||
bool quitNestedMainFlag;
|
||||
bool clearedGarbageFlag;
|
||||
|
@ -1376,10 +784,8 @@ protected:
|
|||
|
||||
std::ofstream _logOut;
|
||||
|
||||
#ifdef BBGE_BUILD_SDL
|
||||
int nowTicks, thenTicks;
|
||||
#endif
|
||||
|
||||
|
||||
int _vsync, _bpp;
|
||||
bool _fullscreen;
|
||||
|
||||
|
@ -1387,9 +793,8 @@ protected:
|
|||
|
||||
CountedPtr<Texture> texError;
|
||||
|
||||
//unsigned int windowWidth, windowHeight;
|
||||
|
||||
|
||||
|
||||
int tgaSaveSeries(char *filename, short int width, short int height, unsigned char pixelDepth, unsigned char *imageData);
|
||||
virtual void onUpdate(float dt);
|
||||
virtual void onRender(){}
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -58,7 +58,7 @@ public:
|
|||
EventPtr event;
|
||||
bool quitMain;
|
||||
int buttonID;
|
||||
|
||||
|
||||
protected:
|
||||
void onUpdate(float dt);
|
||||
Quad *highlight;
|
||||
|
|
|
@ -76,7 +76,6 @@ void PostProcessingFX::render()
|
|||
{
|
||||
if (enabled[i])
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
glPushMatrix();
|
||||
FXTypes type = (FXTypes)i;
|
||||
switch(type)
|
||||
|
@ -153,97 +152,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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ enum EventManage
|
|||
{
|
||||
EVM_NONE = 0,
|
||||
EVM_CLEANUP = 1,
|
||||
EVM_MAX
|
||||
EVM_MAX
|
||||
};
|
||||
|
||||
class ActionMapper;
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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++)
|
||||
|
|
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -231,7 +231,7 @@ public:
|
|||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
std::vector<Vector> suckPositions;
|
||||
int numActive;
|
||||
|
|
|
@ -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,7 +137,7 @@ 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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
195
BBGE/Quad.cpp
195
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;
|
||||
|
@ -197,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()
|
||||
|
@ -311,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)
|
||||
|
@ -347,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);
|
||||
|
||||
|
@ -373,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;
|
||||
|
@ -391,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);
|
||||
}
|
||||
}
|
||||
|
@ -438,7 +424,6 @@ void Quad::renderGrid()
|
|||
if (texture)
|
||||
glBindTexture(GL_TEXTURE_2D, texture->textures[0]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Quad::repeatTextureToFill(bool on)
|
||||
|
@ -453,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);
|
||||
|
||||
|
@ -479,7 +463,7 @@ void Quad::onRender()
|
|||
}
|
||||
glEnd();
|
||||
|
||||
//glEnable(GL_CULL_FACE);
|
||||
|
||||
glBindTexture( GL_TEXTURE_2D, 0 );
|
||||
glColor4f(1,0,0,1);
|
||||
glPointSize(64);
|
||||
|
@ -547,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
|
||||
}
|
||||
|
||||
|
||||
|
|
25
BBGE/Quad.h
25
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);
|
||||
|
@ -57,8 +57,8 @@ public:
|
|||
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 repeatTextureToFill(bool on);
|
||||
void refreshRepeatTextureToFill();
|
||||
|
@ -69,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
|
||||
{
|
||||
|
@ -88,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;
|
||||
|
@ -106,7 +105,7 @@ protected:
|
|||
void resetGrid();
|
||||
void updateGrid(float dt);
|
||||
void renderGrid();
|
||||
|
||||
|
||||
|
||||
float drawGridOffsetX;
|
||||
float drawGridOffsetY;
|
||||
|
@ -114,9 +113,9 @@ protected:
|
|||
float drawGridModY;
|
||||
float drawGridTimeMultiplier;
|
||||
bool drawGridOut;
|
||||
|
||||
|
||||
static Vector renderBorderColor;
|
||||
|
||||
|
||||
void onSetTexture();
|
||||
void onRender();
|
||||
void onUpdate(float dt);
|
||||
|
@ -131,7 +130,7 @@ public:
|
|||
PauseQuad();
|
||||
int pauseLevel;
|
||||
protected:
|
||||
|
||||
|
||||
void onUpdate(float dt);
|
||||
};
|
||||
|
||||
|
|
|
@ -58,8 +58,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 +113,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
|
||||
|
||||
|
@ -369,7 +323,6 @@ Vector RenderObject::getWorldCollidePosition(const Vector &vec)
|
|||
|
||||
return Vector(transformMatrix[3][0], transformMatrix[3][1], 0);
|
||||
#else
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
||||
|
@ -939,20 +771,15 @@ void RenderObject::renderCollision()
|
|||
{
|
||||
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);
|
||||
|
@ -962,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)
|
||||
{
|
||||
|
@ -992,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);
|
||||
|
@ -1037,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;
|
||||
|
@ -1054,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)
|
||||
|
@ -1071,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;
|
||||
|
@ -1125,7 +930,7 @@ void RenderObject::update(float dt)
|
|||
}
|
||||
if (!isDead())
|
||||
{
|
||||
//dt *= updateMultiplier;
|
||||
|
||||
onUpdate(dt);
|
||||
|
||||
if (isHidden())
|
||||
|
@ -1171,19 +976,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
|
||||
{
|
||||
|
@ -1207,12 +1009,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;
|
||||
}
|
||||
|
||||
|
@ -1229,7 +1026,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
|
||||
|
@ -1261,7 +1058,7 @@ void RenderObject::onUpdate(float dt)
|
|||
(*i)->update(dt);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!childGarbage.empty())
|
||||
{
|
||||
for (Children::iterator i = childGarbage.begin(); i != childGarbage.end(); i++)
|
||||
|
@ -1298,7 +1095,7 @@ void RenderObject::onUpdate(float dt)
|
|||
}
|
||||
}
|
||||
|
||||
// updateCullVariables();
|
||||
|
||||
}
|
||||
|
||||
void RenderObject::unloadDevice()
|
||||
|
@ -1323,7 +1120,10 @@ bool RenderObject::setTexture(const std::string &n)
|
|||
stringToLowerUserData(name);
|
||||
|
||||
if (name.empty())
|
||||
{
|
||||
setTexturePointer(NULL);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(texture && texture->getLoadResult() == TEX_SUCCESS && name == texture->name)
|
||||
return true; // no texture change
|
||||
|
@ -1384,6 +1184,6 @@ void RenderObject::setOverrideCullRadius(float ovr)
|
|||
bool RenderObject::isCoordinateInRadius(const Vector &pos, float r)
|
||||
{
|
||||
Vector d = pos-getRealPosition();
|
||||
|
||||
|
||||
return (d.getSquaredLength2D() < r*r);
|
||||
}
|
||||
|
|
|
@ -120,7 +120,7 @@ public:
|
|||
blendType = bt;
|
||||
}
|
||||
|
||||
//enum DestroyType { RANDOM=0, REMOVE_STATE };
|
||||
|
||||
virtual void destroy();
|
||||
|
||||
virtual void flipHorizontal();
|
||||
|
@ -180,7 +180,7 @@ public:
|
|||
const RenderObject &operator=(const RenderObject &r);
|
||||
|
||||
void toggleCull(bool value);
|
||||
|
||||
|
||||
void safeKill();
|
||||
|
||||
void enqueueChildDeletion(RenderObject *r);
|
||||
|
@ -242,18 +242,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()
|
||||
|
@ -268,16 +264,11 @@ 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;
|
||||
std::vector<Vector> collisionMask;
|
||||
|
@ -289,7 +280,7 @@ public:
|
|||
|
||||
bool ignoreUpdate;
|
||||
bool useOldDT;
|
||||
|
||||
|
||||
protected:
|
||||
virtual void onFH(){}
|
||||
virtual void onFV(){}
|
||||
|
@ -312,7 +303,7 @@ protected:
|
|||
}
|
||||
if (fadeAlphaWithLife && !alpha.isInterpolating())
|
||||
{
|
||||
//alpha = ((life*lifeAlphaFadeMultiplier)/maxLife);
|
||||
|
||||
alpha = life/maxLife;
|
||||
}
|
||||
}
|
||||
|
@ -324,7 +315,6 @@ protected:
|
|||
void renderCollision();
|
||||
|
||||
bool repeatTexture;
|
||||
//ParentManaged pm;
|
||||
unsigned char pm; // unsigned char to save space
|
||||
typedef std::list<RenderObject*> RenderObjectList;
|
||||
RenderObjectList deathNotifications;
|
||||
|
@ -340,7 +330,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,19 +62,12 @@ 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;
|
||||
|
@ -141,15 +128,10 @@ void RenderObjectLayer::sort()
|
|||
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 +148,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 +170,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 +233,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 +301,6 @@ void RenderObjectLayer::moveToBack(RenderObject *r)
|
|||
break;
|
||||
}
|
||||
}
|
||||
#endif // RLT_FIXED
|
||||
#ifdef RLT_DYNAMIC
|
||||
renderObjectList.remove(r);
|
||||
renderObjectList.push_front(r);
|
||||
#endif
|
||||
|
||||
clearDisplayList();
|
||||
}
|
||||
|
@ -364,9 +319,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 +383,6 @@ void RenderObjectLayer::generateDisplayList()
|
|||
}
|
||||
else
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
int listID = glGenLists(1);
|
||||
if (listID != 0)
|
||||
{
|
||||
|
@ -450,16 +402,13 @@ void RenderObjectLayer::generateDisplayList()
|
|||
}
|
||||
else
|
||||
debugLog("glGenLists failed");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (lastWasStatic)
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
glEndList();
|
||||
#endif
|
||||
lastWasStatic = false;
|
||||
}
|
||||
}
|
||||
|
@ -477,9 +426,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
|
||||
|
|
|
@ -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)
|
||||
|
@ -134,9 +129,7 @@ Shader::Shader()
|
|||
numUniforms = -1;
|
||||
uniformsDirty = false;
|
||||
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
g_programObj = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
Shader::~Shader()
|
||||
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -81,13 +81,7 @@ Bone::Bone() : Quad()
|
|||
selectable = true;
|
||||
originalRenderPass = 0;
|
||||
}
|
||||
/*
|
||||
void Bone::createStrip(bool vert, int num)
|
||||
{
|
||||
Quad::createStrip(vert, num);
|
||||
changeStrip.resize(num);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
void Bone::destroy()
|
||||
{
|
||||
|
@ -143,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++)
|
||||
{
|
||||
|
@ -181,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;
|
||||
}
|
||||
|
@ -200,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))
|
||||
|
@ -215,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)
|
||||
{
|
||||
|
@ -246,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)
|
||||
{
|
||||
|
@ -336,25 +299,13 @@ bool 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;
|
||||
|
@ -379,7 +330,7 @@ bool BoneCommand::parse(Bone *b, SimpleIStringStream &is)
|
|||
|
||||
void BoneCommand::run()
|
||||
{
|
||||
//debugLog("running CMD");
|
||||
|
||||
switch(command)
|
||||
{
|
||||
case AC_SND_PLAY:
|
||||
|
@ -429,7 +380,7 @@ AnimationLayer::AnimationLayer()
|
|||
{
|
||||
lastNewKey = 0;
|
||||
fallThru= 0;
|
||||
//index = -1;
|
||||
|
||||
timer = 0;
|
||||
loop = 0;
|
||||
enqueuedAnimationLoop = 0;
|
||||
|
@ -482,7 +433,7 @@ void AnimationLayer::playAnimation(int idx, int loop)
|
|||
fallThruSpeed = 10;
|
||||
}
|
||||
timeMultiplier = 1;
|
||||
//currentKeyframe = 0;
|
||||
|
||||
currentAnimation = idx;
|
||||
timer = 0;
|
||||
animating = true;
|
||||
|
@ -490,7 +441,7 @@ void AnimationLayer::playAnimation(int idx, int loop)
|
|||
this->loop = loop;
|
||||
|
||||
animationLength = getCurrentAnimation()->getAnimationLength();
|
||||
//doNextKeyframe();
|
||||
|
||||
}
|
||||
|
||||
void AnimationLayer::enqueueAnimation(const std::string& anim, int loop)
|
||||
|
@ -547,7 +498,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();
|
||||
|
@ -653,10 +604,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++)
|
||||
|
@ -747,7 +695,7 @@ SkeletalKeyframe *Animation::getNextKeyframe(float t)
|
|||
break;
|
||||
}
|
||||
}
|
||||
// kf++;
|
||||
|
||||
if (kf == -1)
|
||||
return 0;
|
||||
if (kf >= keyframes.size())
|
||||
|
@ -831,17 +779,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)
|
||||
|
@ -988,14 +931,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++)
|
||||
{
|
||||
|
@ -1125,7 +1061,7 @@ Bone *SkeletalSprite::initBone(int idx, std::string gfx, int pidx, int rbp, std:
|
|||
b->pidx = pidx;
|
||||
b->collideRadius = cr;
|
||||
b->name = name;
|
||||
//core->generateCollisionMask(b);
|
||||
|
||||
if (fh)
|
||||
b->flipHorizontal();
|
||||
if (fv)
|
||||
|
@ -1256,25 +1192,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
|
||||
{
|
||||
|
@ -1617,7 +1536,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"))
|
||||
|
@ -1760,10 +1679,7 @@ void AnimationLayer::updateBones()
|
|||
float t1 = key1->t;
|
||||
float t2 = key2->t;
|
||||
|
||||
/*
|
||||
if (key1 == key2)
|
||||
stopAnimation();
|
||||
*/
|
||||
|
||||
|
||||
float diff = t2-t1;
|
||||
float dt;
|
||||
|
@ -1871,16 +1787,7 @@ void SkeletalSprite::updateBones()
|
|||
animLayers[i].updateBones();
|
||||
}
|
||||
}
|
||||
/*
|
||||
for (int i = animLayers.size()-1; i >= 0; i--)
|
||||
{
|
||||
if (animLayers[i].animating)
|
||||
{
|
||||
animLayers[i].updateBones();
|
||||
return;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ public:
|
|||
std::map<int, ParticleEffect*> emitters;
|
||||
std::string prt;
|
||||
std::vector<Vector> changeStrip;
|
||||
|
||||
|
||||
bool generateCollisionMask;
|
||||
int animated;
|
||||
Vector originalScale;
|
||||
|
@ -77,7 +77,7 @@ public:
|
|||
|
||||
SkeletalSprite *skeleton;
|
||||
|
||||
|
||||
|
||||
void setSegmentProps(int minDist, int maxDist, bool reverse);
|
||||
Vector segmentOffset;
|
||||
|
||||
|
@ -142,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();
|
||||
|
@ -158,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);
|
||||
|
@ -177,8 +177,7 @@ public:
|
|||
bool isAnimating();
|
||||
bool contains(const Bone *b) const;
|
||||
void resetPass();
|
||||
//float lerp(float v1, float v2, float dt, int lerpType);
|
||||
|
||||
|
||||
//----
|
||||
float fallThru;
|
||||
float fallThruSpeed;
|
||||
|
@ -188,7 +187,7 @@ public:
|
|||
SkeletalSprite *s;
|
||||
|
||||
SkeletalKeyframe *lastNewKey;
|
||||
//int index;
|
||||
|
||||
float timer;
|
||||
int loop;
|
||||
Animation blendAnimation;
|
||||
|
@ -201,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);
|
||||
|
@ -216,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();
|
||||
|
@ -230,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();
|
||||
|
@ -244,9 +243,9 @@ public:
|
|||
|
||||
|
||||
void setFreeze(bool f);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Animation *getAnimation(const std::string& anim);
|
||||
|
||||
std::vector<Animation> animations;
|
||||
|
@ -270,7 +269,7 @@ public:
|
|||
|
||||
static std::string animationPath, skinPath, secondaryAnimationPath;
|
||||
static void clearCache();
|
||||
|
||||
|
||||
protected:
|
||||
bool frozen;
|
||||
RenderObject *animKeyNotify;
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -23,20 +23,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include "SoundManager.h"
|
||||
#include "Base.h"
|
||||
|
||||
#if defined(BBGE_BUILD_FMODEX)
|
||||
#ifdef BBGE_BUILD_FMOD_OPENAL_BRIDGE
|
||||
#include "FmodOpenALBridge.h"
|
||||
#else
|
||||
#include <fmod.h>
|
||||
#include <fmod.hpp>
|
||||
#ifdef BBGE_BUILD_WINDOWS
|
||||
#pragma comment(lib, "fmodex_vc.lib")
|
||||
#endif
|
||||
#endif
|
||||
#ifdef BBGE_BUILD_FMOD_OPENAL_BRIDGE
|
||||
#include "FmodOpenALBridge.h"
|
||||
#else
|
||||
#include <fmod.h>
|
||||
#include <fmod.hpp>
|
||||
#ifdef BBGE_BUILD_WINDOWS
|
||||
#pragma comment(lib, "fmodex_vc.lib")
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
#endif
|
||||
|
||||
SoundManager *sound = 0;
|
||||
|
||||
|
@ -48,7 +44,6 @@ std::string fileType = ".ogg";
|
|||
|
||||
namespace SoundCore
|
||||
{
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
|
||||
typedef std::map<std::string, FMOD::Sound*> SoundMap;
|
||||
SoundMap soundMap;
|
||||
|
@ -110,7 +105,6 @@ namespace SoundCore
|
|||
}
|
||||
fadeChs.push_back(fadeCh);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
using namespace SoundCore;
|
||||
|
@ -121,12 +115,12 @@ using namespace SoundCore;
|
|||
|
||||
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
|
||||
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:
|
||||
|
||||
1. Why does fmod seek to the end and read? Because it is looking for ID3V1 tags.
|
||||
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.
|
||||
|
||||
*/
|
||||
|
@ -200,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");
|
||||
|
@ -222,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");
|
||||
|
@ -253,7 +244,6 @@ void SoundManager::resume()
|
|||
checkError();
|
||||
|
||||
debugLog("done");
|
||||
#endif
|
||||
}
|
||||
|
||||
Buffer SoundManager::getBuffer(const std::string &name)
|
||||
|
@ -285,7 +275,6 @@ SoundManager::SoundManager(const std::string &defaultDevice)
|
|||
|
||||
loadProgressCallback = NULL;
|
||||
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
|
||||
int channels = 128;
|
||||
|
||||
|
@ -296,7 +285,7 @@ SoundManager::SoundManager(const std::string &defaultDevice)
|
|||
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;
|
||||
|
@ -332,7 +321,7 @@ SoundManager::SoundManager(const std::string &defaultDevice)
|
|||
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;
|
||||
|
@ -342,30 +331,7 @@ SoundManager::SoundManager(const std::string &defaultDevice)
|
|||
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);
|
||||
|
@ -396,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)
|
||||
{
|
||||
|
@ -414,7 +374,6 @@ SoundManager::SoundManager(const std::string &defaultDevice)
|
|||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
enabled = true;
|
||||
|
||||
|
@ -438,7 +397,6 @@ void SoundManager::toggleEffectMusic(SoundEffectType effect, bool on)
|
|||
{
|
||||
if (!enabled) return;
|
||||
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
|
||||
bool active = false;
|
||||
|
||||
|
@ -454,7 +412,6 @@ void SoundManager::toggleEffectMusic(SoundEffectType effect, bool on)
|
|||
break;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -508,25 +465,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);
|
||||
}
|
||||
|
||||
|
@ -549,17 +495,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()
|
||||
|
@ -568,36 +510,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");
|
||||
}
|
||||
|
||||
|
||||
|
@ -607,19 +548,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++)
|
||||
|
@ -633,7 +571,6 @@ void SoundManager::clearFadingSfx()
|
|||
}
|
||||
SoundCore::fadeChs.clear();
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
@ -647,7 +584,6 @@ void SoundManager::update(float dt)
|
|||
musVol.update(dt);
|
||||
|
||||
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
|
||||
if (musicChannel)
|
||||
{
|
||||
|
@ -668,10 +604,10 @@ void SoundManager::update(float dt)
|
|||
if (musicChannel)
|
||||
{
|
||||
// fader value
|
||||
|
||||
|
||||
result = musicChannel->setVolume(musVol.y*1.0f);
|
||||
checkError();
|
||||
|
||||
|
||||
|
||||
if (musVol.y <= 0 && stopMusicOnFadeOut)
|
||||
{
|
||||
|
@ -740,7 +676,7 @@ void SoundManager::update(float dt)
|
|||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (f->c)
|
||||
{
|
||||
f->c->setVolume(f->v);
|
||||
|
@ -753,15 +689,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)
|
||||
|
@ -770,7 +703,6 @@ void SoundManager::fadeMusic(SoundFadeType sft, float t)
|
|||
{
|
||||
case SFT_CROSS:
|
||||
{
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
if (musicChannel2)
|
||||
{
|
||||
musicChannel2->stop();
|
||||
|
@ -789,16 +721,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);
|
||||
|
@ -808,7 +737,6 @@ void SoundManager::fadeMusic(SoundFadeType sft, float t)
|
|||
|
||||
bool SoundManager::isPlayingMusic()
|
||||
{
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
|
||||
if (musicChannel)
|
||||
{
|
||||
|
@ -817,13 +745,7 @@ bool SoundManager::isPlayingMusic()
|
|||
return b;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef BBGE_BUILD_BASS20
|
||||
|
||||
return musicStream != 0;
|
||||
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -832,12 +754,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)
|
||||
|
@ -854,15 +774,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)
|
||||
{
|
||||
|
@ -882,7 +799,6 @@ bool SoundManager::isPlayingVoice()
|
|||
return b;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -893,7 +809,7 @@ void SoundManager::setSfxChannelsVolume(float v)
|
|||
|
||||
bool SoundManager::playVoice(const std::string &name, SoundVoiceType svt, float vmod)
|
||||
{
|
||||
//debugLog("playVoice, masterSoundLock: " + name);
|
||||
|
||||
|
||||
if (!enabled) return false;
|
||||
|
||||
|
@ -902,7 +818,7 @@ bool SoundManager::playVoice(const std::string &name, SoundVoiceType svt, float
|
|||
|
||||
n = name;
|
||||
stringToLower(n);
|
||||
|
||||
|
||||
if (!voicePath2.empty())
|
||||
{
|
||||
fn = voicePath2 + name + fileType;
|
||||
|
@ -953,12 +869,10 @@ bool SoundManager::playVoice(const std::string &name, SoundVoiceType svt, float
|
|||
|
||||
if (playNow)
|
||||
{
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
if (voiceStream)
|
||||
{
|
||||
stopVoice();
|
||||
}
|
||||
#endif
|
||||
|
||||
debugLog("play now");
|
||||
|
||||
|
@ -979,7 +893,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.
|
||||
|
@ -994,7 +907,7 @@ bool SoundManager::playVoice(const std::string &name, SoundVoiceType svt, float
|
|||
}
|
||||
|
||||
if (voiceStream)
|
||||
{
|
||||
{
|
||||
|
||||
if (!reverbKeyword.empty())
|
||||
{
|
||||
|
@ -1003,7 +916,7 @@ bool SoundManager::playVoice(const std::string &name, SoundVoiceType svt, float
|
|||
if (dspReverb)
|
||||
{
|
||||
bool active = false;
|
||||
|
||||
|
||||
result = dspReverb->getActive(&active);
|
||||
checkError();
|
||||
|
||||
|
@ -1033,7 +946,7 @@ bool SoundManager::playVoice(const std::string &name, SoundVoiceType svt, float
|
|||
|
||||
result = voiceChannel->setChannelGroup(group_vox);
|
||||
checkError();
|
||||
|
||||
|
||||
if (vmod != -1)
|
||||
{
|
||||
result = voiceChannel->setVolume(vmod);
|
||||
|
@ -1043,10 +956,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);
|
||||
|
@ -1061,7 +971,6 @@ bool SoundManager::playVoice(const std::string &name, SoundVoiceType svt, float
|
|||
wasPlayingVoice = true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
lastVoice = n;
|
||||
event_playVoice.call();
|
||||
|
@ -1077,7 +986,6 @@ void SoundManager::updateChannelVolume(void *ch, float v)
|
|||
|
||||
float SoundManager::getVoiceTime()
|
||||
{
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
|
||||
if (isPlayingVoice())
|
||||
{
|
||||
|
@ -1086,7 +994,6 @@ float SoundManager::getVoiceTime()
|
|||
return float(position) * 0.001f;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1095,11 +1002,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;
|
||||
|
@ -1168,7 +1074,6 @@ void *SoundManager::playSfx(const PlaySfx &play)
|
|||
checkError();
|
||||
|
||||
return channel;
|
||||
#endif
|
||||
|
||||
|
||||
return 0;
|
||||
|
@ -1194,11 +1099,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;
|
||||
|
@ -1218,9 +1119,6 @@ bool SoundManager::playMusic(const std::string &name, SoundLoopType slt, SoundFa
|
|||
{
|
||||
if (isPlayingMusic(name))
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENALOGG
|
||||
if (masterSoundLock) SDL_mutexV(masterSoundLock);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1251,7 +1149,6 @@ bool SoundManager::playMusic(const std::string &name, SoundLoopType slt, SoundFa
|
|||
lastMusic = name;
|
||||
stringToLower(lastMusic);
|
||||
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
|
||||
if (sft == SFT_CROSS)
|
||||
{
|
||||
|
@ -1303,7 +1200,7 @@ bool SoundManager::playMusic(const std::string &name, SoundLoopType slt, SoundFa
|
|||
|
||||
if (musicStream)
|
||||
{
|
||||
|
||||
|
||||
|
||||
result = SoundCore::system->playSound(FMOD_CHANNEL_FREE, musicStream, true, &musicChannel);
|
||||
checkError();
|
||||
|
@ -1345,7 +1242,6 @@ bool SoundManager::playMusic(const std::string &name, SoundLoopType slt, SoundFa
|
|||
{
|
||||
debugLog("Failed to create music stream: " + fn);
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1353,7 +1249,6 @@ bool SoundManager::playMusic(const std::string &name, SoundLoopType slt, SoundFa
|
|||
|
||||
void SoundManager::stopMusic()
|
||||
{
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
if (musicChannel)
|
||||
{
|
||||
musicChannel->stop();
|
||||
|
@ -1366,14 +1261,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)
|
||||
|
@ -1382,12 +1275,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)
|
||||
{
|
||||
|
@ -1403,13 +1294,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;
|
||||
|
@ -1430,7 +1319,6 @@ void SoundManager::stopVoice()
|
|||
voiceStream = 0;
|
||||
}
|
||||
onVoiceEnded();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
@ -1446,7 +1334,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;
|
||||
}
|
||||
|
@ -1513,7 +1401,6 @@ Buffer SoundManager::loadSoundIntoBank(const std::string &filename, const std::s
|
|||
|
||||
stringToLower(name);
|
||||
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
|
||||
FMOD::Sound * sound = SoundCore::soundMap[name];
|
||||
|
||||
|
@ -1540,11 +1427,8 @@ Buffer SoundManager::loadSoundIntoBank(const std::string &filename, const std::s
|
|||
}
|
||||
|
||||
return sound;
|
||||
#endif
|
||||
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
|
||||
#endif
|
||||
|
||||
return Buffer();
|
||||
}
|
||||
|
@ -1553,24 +1437,14 @@ Buffer SoundManager::loadLocalSound(const std::string &filename)
|
|||
{
|
||||
Buffer b = loadSoundIntoBank(filename, localSoundPath, fileType, SFXLOAD_LOCAL);
|
||||
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
return b;
|
||||
#endif
|
||||
|
||||
return BBGE_AUDIO_NOCHANNEL;
|
||||
}
|
||||
|
||||
void SoundManager::setMusicSpeed(float speed)
|
||||
{
|
||||
/*
|
||||
FMOD_CAPS caps;
|
||||
FMOD_SPEAKERMODE speakerMode;
|
||||
int minf, maxf;
|
||||
SoundCore::system->getDriverCaps(0, &caps, &minf, &maxf, &speakerMode);
|
||||
std::ostringstream os;
|
||||
os << "minf: " << minf << " maxf: " << maxf;
|
||||
debugLog(os.str());
|
||||
*/
|
||||
|
||||
|
||||
musicChannel->setFrequency(speed);
|
||||
}
|
||||
|
@ -1583,7 +1457,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);
|
||||
|
@ -1593,12 +1466,10 @@ void SoundManager::clearLocalSounds()
|
|||
soundMap[snd] = 0;
|
||||
}
|
||||
localSounds.clear();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool SoundManager::checkError()
|
||||
{
|
||||
#ifdef BBGE_BUILD_FMODEX
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
std::ostringstream os;
|
||||
|
@ -1640,7 +1511,6 @@ bool SoundManager::checkError()
|
|||
debugLog(os.str());
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,36 +27,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include <set>
|
||||
#include "Vector.h"
|
||||
|
||||
// if using SDL_MIXER
|
||||
//const int BBGE_AUDIO_NOCHANNEL = -1;
|
||||
|
||||
|
||||
|
||||
#define BBGE_BUILD_FMODEX
|
||||
|
||||
//#define BBGE_BUILD_BASS20
|
||||
//#define BBGE_BUILD_SDLMIXER
|
||||
//#define BBGE_BUILD_IRRKLANG
|
||||
//#define BBGE_BUILD_OPENALOGG
|
||||
|
||||
|
||||
|
||||
#ifdef BBGE_BUILD_OPENALOGG
|
||||
const int BBGE_AUDIO_NOCHANNEL = -1;
|
||||
#elif defined(BBGE_BUILD_FMODEX)
|
||||
const int BBGE_AUDIO_NOCHANNEL = 0;
|
||||
#endif
|
||||
|
||||
const int BBGE_AUDIO_NOCHANNEL = 0;
|
||||
const int BBGE_AUDIO_LOOPINFINITE = -1;
|
||||
const int BBGE_AUDIO_LOOPNONE = 0;
|
||||
|
||||
namespace SoundCore
|
||||
{
|
||||
#if defined(BBGE_BUILD_OPENALOGG)
|
||||
//struct Buffer;
|
||||
#elif defined(BBGE_BUILD_FMODEX)
|
||||
typedef void *Buffer;
|
||||
#endif
|
||||
}
|
||||
|
||||
enum SoundEffectType
|
||||
|
@ -204,19 +183,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();
|
||||
|
@ -280,6 +246,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();
|
||||
*/
|
||||
|
||||
}
|
||||
|
|
|
@ -29,40 +29,19 @@ 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;
|
||||
|
@ -79,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]);
|
||||
|
@ -94,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,
|
||||
|
@ -145,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;
|
||||
|
@ -165,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);
|
||||
|
@ -210,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);
|
||||
|
@ -241,9 +200,6 @@ int Texture::getPixelHeight()
|
|||
}
|
||||
free(data);
|
||||
return largesty - smallesty;
|
||||
#elif defined(BBGE_BUILD_DIRECTX)
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void Texture::reload()
|
||||
|
@ -253,11 +209,7 @@ void Texture::reload()
|
|||
unload();
|
||||
load(loadName);
|
||||
|
||||
/*if (ow != -1 && oh != -1)
|
||||
{
|
||||
width = ow;
|
||||
height = oh;
|
||||
}*/
|
||||
|
||||
debugLog("DONE");
|
||||
}
|
||||
|
||||
|
@ -287,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);
|
||||
|
||||
|
@ -310,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")
|
||||
{
|
||||
|
@ -364,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)
|
||||
{
|
||||
|
@ -384,11 +309,6 @@ void Texture::apply(bool repeatOverride)
|
|||
repeating = false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef BBGE_BUILD_DIRECTX
|
||||
core->getD3DDevice()->SetTexture(0, d3dTexture);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
void Texture::unbind()
|
||||
|
@ -400,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)
|
||||
|
@ -444,7 +363,6 @@ bool Texture::loadPNG(const std::string &file)
|
|||
if(memptr)
|
||||
delete [] memptr;
|
||||
|
||||
#endif
|
||||
return good;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,26 +51,21 @@ public:
|
|||
|
||||
int getPixelWidth();
|
||||
int getPixelHeight();
|
||||
|
||||
|
||||
void destroy();
|
||||
|
||||
|
||||
|
||||
int width, height;
|
||||
|
||||
static ImageTGA *TGAload(const char* filename);
|
||||
static ImageTGA *TGAloadMem(void *mem, int size);
|
||||
|
||||
|
||||
static bool useMipMaps;
|
||||
bool repeat, repeating;
|
||||
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
static GLint filter;
|
||||
static GLint format;
|
||||
GLuint textures[1];
|
||||
#endif
|
||||
#ifdef BBGE_BUILD_DIRECTX
|
||||
LPDIRECT3DTEXTURE9 d3dTexture;
|
||||
#endif
|
||||
|
||||
void reload();
|
||||
|
||||
|
@ -94,7 +89,7 @@ protected:
|
|||
|
||||
int ow, oh;
|
||||
TextureLoadResult loadResult;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#define UNREFTEX(x) if (x) {x = NULL;}
|
||||
|
|
123
BBGE/Vector.cpp
123
BBGE/Vector.cpp
|
@ -39,7 +39,6 @@ void Vector::rotate2DRad(float rad)
|
|||
|
||||
Vector getRotatedVector(const Vector &vec, float rot)
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
|
||||
|
@ -59,9 +58,6 @@ Vector getRotatedVector(const Vector &vec, float rot)
|
|||
|
||||
glPopMatrix();
|
||||
return Vector(x,y,z);
|
||||
#elif defined(BBGE_BUILD_DIRECTX)
|
||||
return vec;
|
||||
#endif
|
||||
}
|
||||
|
||||
// note update this from float lerp
|
||||
|
@ -97,7 +93,7 @@ float Bias( float x, float biasAmt )
|
|||
static float lastExponent = 0;
|
||||
if( lastAmt != biasAmt )
|
||||
{
|
||||
lastExponent = logf( biasAmt ) * -1.4427f; // (-1.4427 = 1 / log(0.5))
|
||||
lastExponent = logf( biasAmt ) * -1.4427f;
|
||||
}
|
||||
return powf( x, lastExponent );
|
||||
}
|
||||
|
@ -304,7 +300,6 @@ Vector VectorPath::getValue(float usePercent)
|
|||
else if (from && !target)
|
||||
{
|
||||
// Should only happen at end
|
||||
// msg ("returning just a value");
|
||||
return from->value;
|
||||
}
|
||||
else if (from && target && from==target)
|
||||
|
@ -313,83 +308,22 @@ Vector VectorPath::getValue(float usePercent)
|
|||
}
|
||||
else if (from && target)
|
||||
{
|
||||
//bool smoothing = false;
|
||||
|
||||
Vector v;
|
||||
float perc=0;
|
||||
perc = ((usePercent - from->percent)/(target->percent-from->percent));
|
||||
//perc = Gain(perc, 0.8);
|
||||
|
||||
Vector targetValue = target->value;
|
||||
Vector fromValue = from->value;
|
||||
|
||||
/*
|
||||
int nexti = i + 1;
|
||||
int previ = i - 1;
|
||||
if (perc > 0.5f && nexti < pathNodes.size())
|
||||
{
|
||||
float scale = ((perc-0.5f)/0.5f) * 0.1f;
|
||||
targetValue = targetValue * (1.0f-scale) + pathNodes[nexti].value * scale;
|
||||
}
|
||||
else if (perc < 0.5f && previ > 0)
|
||||
{
|
||||
float scale = (1.0f-(perc/0.5f)) * 0.1f;
|
||||
targetValue = targetValue * (1.0f-scale) + pathNodes[previ].value * scale;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
v = (targetValue - fromValue) * (perc);
|
||||
v += fromValue;
|
||||
return v;
|
||||
/*
|
||||
int nexti = i + 1;
|
||||
int previ = i - 1;
|
||||
if (smoothing && perc >= 0.5f && nexti < pathNodes.size() && nexti >= 0)
|
||||
{
|
||||
VectorPathNode *next = &pathNodes[nexti];
|
||||
float nextPerc = perc - 0.5f;
|
||||
v = (target->value - from->value) * (perc-nextPerc);
|
||||
Vector v2 = (next->value - from->value) * nextPerc;
|
||||
v = v+v2;
|
||||
v += from->value;
|
||||
}
|
||||
else if (smoothing && perc <= 0.5f && previ < pathNodes.size() && previ >= 0)
|
||||
{
|
||||
VectorPathNode *prev = &pathNodes[previ];
|
||||
float prevPerc = perc + 0.5f;
|
||||
v = (target->value - from->value) * (perc-prevPerc);
|
||||
Vector v2 = (from->value - prev->value) * prevPerc;
|
||||
//v = (v + v2)/2.0f;
|
||||
v = v+v2;
|
||||
v += from->value;
|
||||
}
|
||||
else
|
||||
{
|
||||
v = (target->value - from->value) * (perc);
|
||||
v += from->value;
|
||||
}
|
||||
*/
|
||||
/*
|
||||
int nexti = i + 1;
|
||||
Vector perp;
|
||||
if (smoothing && nexti < pathNodes.size() && nexti >= 0)
|
||||
{
|
||||
VectorPathNode *next = &pathNodes[nexti];
|
||||
Vector perp = (next->value - from->value);
|
||||
perp = perp.getPerpendicularLeft();
|
||||
Vector p = getNearestPointOnLine(from->value, next->value, target->value);
|
||||
float dist = (target->value - p).getLength2D();
|
||||
if (dist > 0)
|
||||
{
|
||||
float bulge = sinf(perc * PI);
|
||||
perp |= dist;
|
||||
perp *= bulge;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
return Vector(0,0,0);
|
||||
}
|
||||
|
@ -410,21 +344,17 @@ float InterpolatedVector::interpolateTo(Vector vec, float timePeriod, int loopTy
|
|||
|
||||
data->ease = ease;
|
||||
data->timePassed = 0;
|
||||
//data->fakeTimePassed = 0;
|
||||
|
||||
if (timePeriod < 0)
|
||||
{
|
||||
timePeriod = -timePeriod;
|
||||
timePeriod = (vec-Vector(x,y,z)).getLength3D() / timePeriod;
|
||||
/*
|
||||
std::ostringstream os;
|
||||
os << "calced: " << timePeriod;
|
||||
debugLog(os.str());
|
||||
*/
|
||||
|
||||
}
|
||||
data->timePeriod = timePeriod;
|
||||
data->from = Vector (this->x, this->y, this->z);
|
||||
data->target = vec;
|
||||
|
||||
|
||||
data->loopType = loopType;
|
||||
data->pingPong = pingPong;
|
||||
|
||||
|
@ -521,20 +451,8 @@ void InterpolatedVector::doInterpolate(float dt)
|
|||
{
|
||||
InterpolatedVectorData *data = ensureData();
|
||||
|
||||
//errorLog ("gothere");
|
||||
/*
|
||||
// old method
|
||||
if (data->ease)
|
||||
{
|
||||
float diff = data->timePassed / data->timePeriod;
|
||||
if (diff > 0.5f)
|
||||
diff = 1.0f - diff;
|
||||
diff /= 0.5f;
|
||||
diff *= 2;
|
||||
//diff += 0.5f;
|
||||
data->fakeTimePassed += dt*diff;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
data->timePassed += dt;
|
||||
if (data->timePassed >= data->timePeriod)
|
||||
{
|
||||
|
@ -566,28 +484,13 @@ void InterpolatedVector::doInterpolate(float dt)
|
|||
{
|
||||
Vector v;
|
||||
|
||||
/*
|
||||
// old method
|
||||
if (data->ease)
|
||||
{
|
||||
v = lerp(data->from, data->target, (data->timePassed / data->timePeriod), data->ease);
|
||||
//v = (data->target - data->from) *
|
||||
//v = (data->target - data->from) * (data->fakeTimePassed / data->timePeriod);
|
||||
}
|
||||
else
|
||||
{
|
||||
float perc = data->timePassed / data->timePeriod;
|
||||
v = (data->target - data->from) * perc;
|
||||
}
|
||||
|
||||
v += data->from;
|
||||
*/
|
||||
|
||||
v = lerp(data->from, data->target, (data->timePassed / data->timePeriod), data->ease ? LERP_EASE : LERP_LINEAR);
|
||||
|
||||
this->x = v.x;
|
||||
this->y = v.y;
|
||||
this->z = v.z;
|
||||
//*updatee += data->from;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,12 +23,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#include <cmath>
|
||||
#include <float.h>
|
||||
#include <vector>
|
||||
#include <vector>
|
||||
#include "Event.h"
|
||||
|
||||
#ifdef BBGE_BUILD_DIRECTX
|
||||
#include <d3dx9.h>
|
||||
#endif
|
||||
typedef float scalar_t;
|
||||
|
||||
class Vector
|
||||
|
@ -53,7 +50,7 @@ public:
|
|||
v[0] = x; v[1] = y; v[2] = z; v[3] = param;
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
// vector assignment
|
||||
const Vector &operator=(const Vector &vec)
|
||||
{
|
||||
|
@ -84,7 +81,7 @@ public:
|
|||
|
||||
// vector add (opposite of negation)
|
||||
const Vector operator+() const
|
||||
{
|
||||
{
|
||||
return Vector(*this);
|
||||
}
|
||||
|
||||
|
@ -98,13 +95,13 @@ public:
|
|||
|
||||
// vector subtraction
|
||||
const Vector operator-(const Vector& vec) const
|
||||
{
|
||||
{
|
||||
return Vector(x - vec.x, y - vec.y, z - vec.z);
|
||||
}
|
||||
|
||||
|
||||
// vector negation
|
||||
const Vector operator-() const
|
||||
{
|
||||
{
|
||||
return Vector(-x, -y, -z);
|
||||
}
|
||||
|
||||
|
@ -124,7 +121,7 @@ public:
|
|||
x *= s;
|
||||
y *= s;
|
||||
z *= s;
|
||||
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -178,11 +175,6 @@ public:
|
|||
return vec*s;
|
||||
}
|
||||
|
||||
/* friend inline const Vector operator*(const Vector &vec, const scalar_t &s)
|
||||
{
|
||||
return Vector(vec.x*s, vec.y*s, vec.z*s);
|
||||
}
|
||||
*/
|
||||
// divecide by scalar
|
||||
const Vector operator/(scalar_t s) const
|
||||
{
|
||||
|
@ -253,7 +245,7 @@ public:
|
|||
{
|
||||
if (x == 0 && y == 0 && z == 0)
|
||||
{
|
||||
//debugLog("Normalizing 0 vector");
|
||||
|
||||
x = y = z = 0;
|
||||
}
|
||||
else
|
||||
|
@ -265,7 +257,7 @@ public:
|
|||
{
|
||||
if (x == 0 && y == 0)
|
||||
{
|
||||
//debugLog("Normalizing 0 vector");
|
||||
|
||||
x = y = z= 0;
|
||||
}
|
||||
else
|
||||
|
@ -279,27 +271,14 @@ public:
|
|||
return sqrtf(x*x + y*y + z*z);
|
||||
}
|
||||
|
||||
/*
|
||||
// return vector with specified length
|
||||
const Vector operator | (const scalar_t length) const
|
||||
{
|
||||
return *this * (length / !(*this));
|
||||
}
|
||||
|
||||
// set length of vector equal to length
|
||||
const Vector& operator |= (const float length)
|
||||
{
|
||||
(*this).setLength2D(length);
|
||||
return *this;
|
||||
}
|
||||
*/
|
||||
|
||||
inline void setLength3D(const float l)
|
||||
{
|
||||
// IGNORE !!
|
||||
if (l == 0)
|
||||
{
|
||||
//debugLog("setLength3D divide by 0");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -314,14 +293,14 @@ public:
|
|||
float len = getLength2D();
|
||||
if (len == 0)
|
||||
{
|
||||
//debugLog("divide by zero!");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
this->x *= (l/len);
|
||||
this->y *= (l/len);
|
||||
}
|
||||
//this->z = 0;
|
||||
|
||||
}
|
||||
|
||||
// return angle between two vectors
|
||||
|
@ -330,31 +309,14 @@ public:
|
|||
return acosf(*this % normal);
|
||||
}
|
||||
|
||||
/*
|
||||
inline scalar_t cheatLen() const
|
||||
{
|
||||
return (x*x + y*y + z*z);
|
||||
}
|
||||
inline scalar_t cheatLen2D() const
|
||||
{
|
||||
return (x*x + y*y);
|
||||
}
|
||||
inline scalar_t getCheatLength3D() const;
|
||||
*/
|
||||
|
||||
|
||||
inline bool isLength2DIn(float radius) const
|
||||
{
|
||||
return (x*x + y*y) <= (radius*radius);
|
||||
}
|
||||
|
||||
// reflect this vector off surface with normal vector
|
||||
/*
|
||||
const Vector inline Reflection(const Vector& normal) const
|
||||
{
|
||||
const Vector vec(*this | 1); // normalize this vector
|
||||
return (vec - normal * 2.0f * (vec % normal)) * !*this;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
inline void setZero()
|
||||
{
|
||||
|
@ -392,12 +354,6 @@ public:
|
|||
z += 360;
|
||||
}
|
||||
|
||||
#ifdef BBGE_BUILD_DIRECTX
|
||||
const D3DCOLOR getD3DColor(float alpha)
|
||||
{
|
||||
return D3DCOLOR_RGBA(int(x*255), int(y*255), int(z*255), int(alpha*255));
|
||||
}
|
||||
#endif
|
||||
void rotate2DRad(float rad);
|
||||
void rotate2D360(float angle);
|
||||
};
|
||||
|
@ -451,7 +407,7 @@ struct InterpolatedVectorData
|
|||
pathTimeMultiplier = 1;
|
||||
timePassed = 0;
|
||||
timePeriod = 0;
|
||||
//fakeTimePassed = 0;
|
||||
|
||||
ease = false;
|
||||
followingPath = false;
|
||||
}
|
||||
|
|
|
@ -76,9 +76,6 @@ inline unsigned int clz(uint32 x)
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}; // end namespace bithacks
|
||||
|
||||
#endif
|
||||
|
|
|
@ -13,21 +13,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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue