mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2024-11-25 09:44:02 +00:00
get rid of GL matrix stack math completely; glm is now mandatory
This commit is contained in:
parent
aaed341569
commit
8528bfae94
4 changed files with 1 additions and 102 deletions
|
@ -47,10 +47,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include "Beam.h"
|
||||
#include "Hair.h"
|
||||
|
||||
#ifdef BBGE_USE_GLM
|
||||
#include "glm/glm.hpp"
|
||||
#include "glm/gtx/transform.hpp"
|
||||
#endif
|
||||
|
||||
|
||||
static const float MENUPAGETRANSTIME = 0.2f;
|
||||
|
@ -495,8 +493,6 @@ void Game::fillGridFromQuad(Quad *q, ObsType obsType, bool trim)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef BBGE_USE_GLM
|
||||
const float w2f = float(w2);
|
||||
const float h2f = float(h2);
|
||||
for (size_t i = 0; i < obs.size(); i++)
|
||||
|
@ -513,35 +509,6 @@ void Game::fillGridFromQuad(Quad *q, ObsType obsType, bool trim)
|
|||
if (!isObstructed(tvec))
|
||||
addGrid(tvec, obsType);
|
||||
}
|
||||
#else
|
||||
glPushMatrix();
|
||||
|
||||
for (size_t i = 0; i < obs.size(); i++)
|
||||
{
|
||||
glLoadIdentity();
|
||||
|
||||
glRotatef(q->rotation.z, 0, 0, 1);
|
||||
if (q->isfh())
|
||||
{
|
||||
glRotatef(180, 0, 1, 0);
|
||||
}
|
||||
|
||||
//glTranslatef((obs[i].x-w2)*TILE_SIZE+TILE_SIZE/2, (obs[i].y-h2)*TILE_SIZE + TILE_SIZE/2, 0);
|
||||
glTranslatef((obs[i].x-w2), (obs[i].y-h2), 0);
|
||||
|
||||
float m[16];
|
||||
glGetFloatv(GL_MODELVIEW_MATRIX, m);
|
||||
float x = m[12];
|
||||
float y = m[13];
|
||||
|
||||
//setGrid(TileVector(tpos.x+(w2*TILE_SIZE)+(x/TILE_SIZE), tpos.y+(h2*TILE_SIZE)+(y/TILE_SIZE)), obsType);
|
||||
TileVector tvec(tpos.x+w2+x, tpos.y+h2+y);
|
||||
if (!isObstructed(tvec))
|
||||
addGrid(tvec, obsType);
|
||||
|
||||
}
|
||||
glPopMatrix();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,10 +26,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include <assert.h>
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef BBGE_USE_GLM
|
||||
#include "glm/glm.hpp"
|
||||
#include "glm/gtx/transform.hpp"
|
||||
#endif
|
||||
|
||||
bool RenderObject::renderCollisionShape = false;
|
||||
size_t RenderObject::lastTextureApplied = 0;
|
||||
|
@ -122,7 +120,6 @@ RenderObject* RenderObject::getTopParent() const
|
|||
return lastp;
|
||||
}
|
||||
|
||||
#ifdef BBGE_USE_GLM
|
||||
static glm::mat4 matrixChain(const RenderObject *ro)
|
||||
{
|
||||
glm::mat4 tranformMatrix = glm::scale(
|
||||
|
@ -146,24 +143,6 @@ static glm::mat4 matrixChain(const RenderObject *ro)
|
|||
tranformMatrix *= glm::translate(glm::vec3(ro->internalOffset.x, ro->internalOffset.y, 0.0f));
|
||||
return tranformMatrix;
|
||||
}
|
||||
#else
|
||||
static void matrixChain(RenderObject *ro)
|
||||
{
|
||||
if (RenderObject *parent = ro->getParent())
|
||||
matrixChain(parent);
|
||||
|
||||
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())
|
||||
{
|
||||
|
||||
glRotatef(180, 0, 1, 0);
|
||||
}
|
||||
glTranslatef(ro->internalOffset.x, ro->internalOffset.y, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
float RenderObject::getWorldRotation() const
|
||||
{
|
||||
|
@ -184,28 +163,12 @@ Vector RenderObject::getWorldPositionAndRotation() const
|
|||
|
||||
Vector RenderObject::getWorldCollidePosition(const Vector &vec) const
|
||||
{
|
||||
#ifdef BBGE_USE_GLM
|
||||
glm::mat4 transformMatrix = glm::translate(
|
||||
matrixChain(this),
|
||||
glm::vec3(vec.x, vec.y, 0.0f)
|
||||
);
|
||||
|
||||
return Vector(transformMatrix[3][0], transformMatrix[3][1], 0);
|
||||
#else
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
|
||||
matrixChain(this);
|
||||
glTranslatef(vec.x, vec.y, 0);
|
||||
|
||||
float m[16];
|
||||
glGetFloatv(GL_MODELVIEW_MATRIX, m);
|
||||
float x = m[12];
|
||||
float y = m[13];
|
||||
|
||||
glPopMatrix();
|
||||
return Vector(x,y,0);
|
||||
#endif
|
||||
}
|
||||
|
||||
void RenderObject::fhTo(bool fh)
|
||||
|
|
|
@ -24,10 +24,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include <float.h>
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef BBGE_USE_GLM
|
||||
#include "glm/glm.hpp"
|
||||
#include "glm/gtx/transform.hpp"
|
||||
#endif
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
|
@ -43,35 +41,11 @@ void Vector::rotate2DRad(float rad)
|
|||
y = sinf(rad)*ox + cosf(rad)*oy;
|
||||
}
|
||||
|
||||
#include "RenderBase.h"
|
||||
|
||||
Vector getRotatedVector(const Vector &vec, float rot)
|
||||
{
|
||||
#ifdef BBGE_USE_GLM
|
||||
glm::mat4 m = glm::rotate(glm::mat4(1), rot, glm::vec3(0, 0, 1));
|
||||
glm::vec4 v = m * glm::vec4(vec.x, vec.y, vec.z, 1.0f);
|
||||
return Vector(v.x, v.y, v.z);
|
||||
#else
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
|
||||
glRotatef(rot, 0, 0, 1);
|
||||
|
||||
if (vec.x != 0 || vec.y != 0)
|
||||
{
|
||||
//glRotatef(this->rotation.z, 0,0,1,this->rotation.z);
|
||||
glTranslatef(vec.x, vec.y, 0);
|
||||
}
|
||||
|
||||
float m[16];
|
||||
glGetFloatv(GL_MODELVIEW_MATRIX, m);
|
||||
float x = m[12];
|
||||
float y = m[13];
|
||||
float z = m[14];
|
||||
|
||||
glPopMatrix();
|
||||
return Vector(x,y,z);
|
||||
#endif
|
||||
}
|
||||
|
||||
// note update this from float lerp
|
||||
|
|
|
@ -28,7 +28,7 @@ if(MSVC)
|
|||
# /Oi: enable intrinsic functions
|
||||
# /fp:fast: -ffast-math
|
||||
set(AQUARIA_EXTRA_COMPILE_FLAGS "/MP /GS- /Oi /fp:fast" CACHE STRING "Extra compiler flags for MSVC")
|
||||
|
||||
|
||||
option(AQUARIA_MSVC_DEBUG_EDIT_AND_CONTINUE "MSVC: Enable edit+continue for debug builds?" TRUE)
|
||||
if(AQUARIA_MSVC_DEBUG_EDIT_AND_CONTINUE)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /ZI")
|
||||
|
@ -51,7 +51,6 @@ OPTION(AQUARIA_DEMO_BUILD "Demo Build?" FALSE)
|
|||
OPTION(AQUARIA_USE_VFS "Use Virtual File System? Required for some additional features." TRUE)
|
||||
|
||||
OPTION(AQUARIA_USE_SDL2 "Use SDL2" TRUE)
|
||||
OPTION(AQUARIA_USE_GLM "Use GLM for matrix math" TRUE)
|
||||
|
||||
OPTION(AQUARIA_DEBUG_SHOW_PATHS "Show important paths upon game start to aid in finding path problems" FALSE)
|
||||
mark_as_advanced(AQUARIA_DEBUG_SHOW_PATHS)
|
||||
|
@ -117,10 +116,6 @@ if(AQUARIA_USE_VFS)
|
|||
INCLUDE_DIRECTORIES(${EXTLIBDIR}/ttvfs_cfileapi)
|
||||
ENDIF(AQUARIA_USE_VFS)
|
||||
|
||||
IF(AQUARIA_USE_GLM)
|
||||
ADD_DEFINITIONS(-DBBGE_USE_GLM=1)
|
||||
ENDIF(AQUARIA_USE_GLM)
|
||||
|
||||
if(AQUARIA_INTERNAL_FTGL)
|
||||
ADD_DEFINITIONS(-DAQUARIA_INTERNAL_FTGL=1)
|
||||
endif()
|
||||
|
|
Loading…
Reference in a new issue