Skip to content

Commit

Permalink
fixes ofPolyline to prepare oF for glm 0.9.9.5 (#6366)
Browse files Browse the repository at this point in the history
#changelog #graphics
  • Loading branch information
npisanti authored and arturoc committed Oct 16, 2019
1 parent 34a9630 commit bf24011
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 39 deletions.
4 changes: 2 additions & 2 deletions libs/openFrameworks/3d/ofCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ glm::mat4 ofCamera::getProjectionMatrix(const ofRectangle & viewport) const {
const_cast<ofCamera*>(this)->calcClipPlanes(viewport);

if(isOrtho) {
return glm::translate(glm::mat4(), {-lensOffset.x, -lensOffset.y, 0.f}) * glm::ortho(
return glm::translate(glm::mat4(1.0), {-lensOffset.x, -lensOffset.y, 0.f}) * glm::ortho(
- viewport.width/2,
+ viewport.width/2,
- viewport.height/2,
Expand All @@ -162,7 +162,7 @@ glm::mat4 ofCamera::getProjectionMatrix(const ofRectangle & viewport) const {
}else{
float aspect = forceAspectRatio ? aspectRatio : viewport.width/viewport.height;
auto projection = glm::perspective(glm::radians(fov), aspect, nearClip, farClip);
projection = glm::translate(glm::mat4(), {-lensOffset.x, -lensOffset.y, 0.f}) * projection;
projection = glm::translate(glm::mat4(1.0), {-lensOffset.x, -lensOffset.y, 0.f}) * projection;
return projection;
}
}
Expand Down
2 changes: 1 addition & 1 deletion libs/openFrameworks/gl/ofGLProgrammableRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1682,7 +1682,7 @@ void ofGLProgrammableRenderer::drawString(string textString, float x, float y, f
bool hasViewport = false;

ofRectangle rViewport;
glm::mat4 modelView;
glm::mat4 modelView = glm::mat4(1.0);

switch (currentStyle.drawBitmapMode) {

Expand Down
12 changes: 6 additions & 6 deletions libs/openFrameworks/gl/ofGLRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ void ofGLRenderer::begin(const ofFbo & fbo, ofFboMode mode){
if(mode & OF_FBOMODE_PERSPECTIVE){
setupScreenPerspective();
}else{
glm::mat4 m;
glm::mat4 m = glm::mat4(1.0);
glGetFloatv(GL_PROJECTION_MATRIX, glm::value_ptr(m));
m = matrixStack.getOrientationMatrixInverse() * m;
ofMatrixMode currentMode = matrixStack.getCurrentMatrixMode();
Expand Down Expand Up @@ -586,7 +586,7 @@ void ofGLRenderer::bind(const ofTexture & texture, int location){
if(ofGetUsingNormalizedTexCoords()) {
matrixMode(OF_MATRIX_TEXTURE);
pushMatrix();
glm::mat4 m;
glm::mat4 m = glm::mat4(1.0);

#ifndef TARGET_OPENGLES
if(texture.texData.textureTarget == GL_TEXTURE_RECTANGLE_ARB)
Expand Down Expand Up @@ -640,7 +640,7 @@ void ofGLRenderer::unbind(const ofCamera & camera){
void ofGLRenderer::pushView() {
getCurrentViewport();

glm::mat4 m;
glm::mat4 m = glm::mat4(1.0);
ofMatrixMode matrixMode = matrixStack.getCurrentMatrixMode();
glGetFloatv(GL_PROJECTION_MATRIX,glm::value_ptr(m));
matrixStack.matrixMode(OF_MATRIX_PROJECTION);
Expand Down Expand Up @@ -945,7 +945,7 @@ void ofGLRenderer::loadMatrix (const float *m){
* @param matrixMode_ Which matrix mode to query
*/
glm::mat4 ofGLRenderer::getCurrentMatrix(ofMatrixMode matrixMode_) const {
glm::mat4 mat;
glm::mat4 mat = glm::mat4(1.0);
switch (matrixMode_) {
case OF_MATRIX_MODELVIEW:
glGetFloatv(GL_MODELVIEW_MATRIX, glm::value_ptr(mat));
Expand All @@ -971,7 +971,7 @@ glm::mat4 ofGLRenderer::getCurrentOrientationMatrix() const {
//----------------------------------------------------------
void ofGLRenderer::multMatrix (const glm::mat4 & m){
if(matrixStack.getCurrentMatrixMode()==OF_MATRIX_PROJECTION){
glm::mat4 current;
glm::mat4 current = glm::mat4(1.0);
glGetFloatv(GL_PROJECTION_MATRIX, glm::value_ptr(current));
if(matrixStack.customMatrixNeedsFlip()){
current = glm::scale(current, glm::vec3(1,-1,1));
Expand Down Expand Up @@ -1598,7 +1598,7 @@ void ofGLRenderer::drawString(string textString, float x, float y, float z) cons

rViewport = getCurrentViewport();

glm::mat4 modelview, projection;
glm::mat4 modelview = glm::mat4(1.0), projection = glm::mat4(1.0);
glGetFloatv(GL_MODELVIEW_MATRIX, glm::value_ptr(modelview));
glGetFloatv(GL_PROJECTION_MATRIX, glm::value_ptr(projection));
glm::mat4 mat = matrixStack.getOrientationMatrixInverse() * projection * modelview;
Expand Down
36 changes: 12 additions & 24 deletions libs/openFrameworks/graphics/of3dGraphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ void of3dGraphics::drawPlane(float x, float y, float width, float height) const{

//----------------------------------------------------------
void of3dGraphics::drawPlane(float x, float y, float z, float width, float height) const{
glm::mat4 m;
m = glm::translate(m, glm::vec3(x,y,z));
glm::mat4 m = glm::translate(glm::mat4(1.0), glm::vec3(x,y,z));
m = glm::scale(m, glm::vec3(width,height,1));
renderer->pushMatrix();
renderer->multMatrix(m);
Expand All @@ -131,8 +130,7 @@ void of3dGraphics::drawPlane(glm::vec3& position, float width, float height) con

//----------------------------------------------------------
void of3dGraphics::drawPlane( float width, float height ) const{
glm::mat4 m;
m = glm::scale(m, glm::vec3(width,height,1));
glm::mat4 m = glm::scale(glm::mat4(1.0), glm::vec3(width,height,1));
renderer->pushMatrix();
renderer->multMatrix(m);
renderCached3dPrimitive( plane );
Expand All @@ -155,8 +153,7 @@ int of3dGraphics::getSphereResolution() const{

//----------------------------------------------------------
void of3dGraphics::drawSphere(float x, float y, float z, float radius) const{
glm::mat4 m;
m = glm::translate(m, glm::vec3(x,y,z));
glm::mat4 m = glm::translate(glm::mat4(1.0), glm::vec3(x,y,z));
m = glm::scale(m, glm::vec3(radius,radius,radius));
renderer->pushMatrix();
renderer->multMatrix(m);
Expand All @@ -176,8 +173,7 @@ void of3dGraphics::drawSphere(const glm::vec3& position, float radius) const{

//----------------------------------------------------------
void of3dGraphics::drawSphere(float radius) const{
glm::mat4 m;
m = glm::scale(m, glm::vec3(radius,radius,radius));
glm::mat4 m = glm::scale(glm::mat4(1.0), glm::vec3(radius,radius,radius));
renderer->pushMatrix();
renderer->multMatrix(m);
renderCached3dPrimitive( sphere );
Expand All @@ -200,8 +196,7 @@ int of3dGraphics::getIcoSphereResolution() const{

//----------------------------------------------------------
void of3dGraphics::drawIcoSphere(float x, float y, float z, float radius) const{
glm::mat4 m;
m = glm::translate(m, glm::vec3(x,y,z));
glm::mat4 m = glm::translate(glm::mat4(1.0), glm::vec3(x,y,z));
m = glm::scale(m, glm::vec3(radius,radius,radius));
renderer->pushMatrix();
renderer->multMatrix(m);
Expand All @@ -221,8 +216,7 @@ void of3dGraphics::drawIcoSphere(const glm::vec3& position, float radius) const{

//----------------------------------------------------------
void of3dGraphics::drawIcoSphere(float radius) const{
glm::mat4 m;
m = glm::scale(m, glm::vec3(radius,radius,radius));
glm::mat4 m = glm::scale(glm::mat4(1.0), glm::vec3(radius,radius,radius));
renderer->pushMatrix();
renderer->multMatrix(m);
renderCached3dPrimitive( icoSphere );
Expand Down Expand Up @@ -250,8 +244,7 @@ void of3dGraphics::drawCylinder(float x, float y, float radius, float height) co

//----------------------------------------------------------
void of3dGraphics::drawCylinder(float x, float y, float z, float radius, float height) const{
glm::mat4 m;
m = glm::translate(m, glm::vec3(x,y,z));
glm::mat4 m = glm::translate(glm::mat4(1.0), glm::vec3(x,y,z));
m = glm::scale(m, glm::vec3(radius,height,radius));
renderer->pushMatrix();
renderer->multMatrix(m);
Expand All @@ -266,8 +259,7 @@ void of3dGraphics::drawCylinder(const glm::vec3& position, float radius, float h

//----------------------------------------------------------
void of3dGraphics::drawCylinder(float radius, float height) const{
glm::mat4 m;
m = glm::scale(m, glm::vec3(radius,height,radius));
glm::mat4 m = glm::scale(glm::mat4(1.0), glm::vec3(radius,height,radius));
renderer->pushMatrix();
renderer->multMatrix(m);
renderCached3dPrimitive( cylinder );
Expand All @@ -291,8 +283,7 @@ glm::vec3 of3dGraphics::getConeResolution() const{

//----------------------------------------------------------
void of3dGraphics::drawCone(float x, float y, float z, float radius, float height) const{
glm::mat4 m;
m = glm::translate(m, glm::vec3(x,y,z));
glm::mat4 m = glm::translate(glm::mat4(1.0), glm::vec3(x,y,z));
m = glm::scale(m, glm::vec3(radius,height,radius));
renderer->pushMatrix();
renderer->multMatrix(m);
Expand All @@ -312,8 +303,7 @@ void of3dGraphics::drawCone(const glm::vec3& position, float radius, float heigh

//----------------------------------------------------------
void of3dGraphics::drawCone(float radius, float height) const{
glm::mat4 m;
m = glm::scale(m, glm::vec3(radius,height,radius));
glm::mat4 m = glm::scale(glm::mat4(1.0), glm::vec3(radius,height,radius));
renderer->pushMatrix();
renderer->multMatrix(m);
renderCached3dPrimitive( cone );
Expand Down Expand Up @@ -342,8 +332,7 @@ glm::vec3 of3dGraphics::getBoxResolution() const{

//----------------------------------------------------------
void of3dGraphics::drawBox( float x, float y, float z, float width, float height, float depth) const{
glm::mat4 m;
m = glm::translate(m, glm::vec3(x,y,z));
glm::mat4 m = glm::translate(glm::mat4(1.0), glm::vec3(x,y,z));
m = glm::scale(m, glm::vec3(width,height,depth));

renderer->pushMatrix();
Expand Down Expand Up @@ -383,8 +372,7 @@ void of3dGraphics::drawBox( float width, float height, float depth ) const{


void of3dGraphics::drawAxis(float size) const{
glm::mat4 m;
m = glm::scale(m, glm::vec3(size,size,size));
glm::mat4 m = glm::scale(glm::mat4(1.0), glm::vec3(size,size,size));
renderer->pushMatrix();
renderer->multMatrix(m);
renderCached3dPrimitive( axis );
Expand Down
2 changes: 1 addition & 1 deletion libs/openFrameworks/graphics/ofCairoRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ void ofCairoRenderer::setHexColor( int hexColor ){
//our openGL wrappers
glm::mat4 ofCairoRenderer::getCurrentMatrix(ofMatrixMode matrixMode_) const{
ofLogWarning() << "getCurrentMatrix not yet implemented for Cairo Renderer.";
return glm::mat4();
return glm::mat4(1.0);
}

//----------------------------------------------------------
Expand Down
10 changes: 5 additions & 5 deletions libs/openFrameworks/graphics/ofPolyline.inl
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ inline T getClosestPointUtil(const T& p1, const T& p2, const T& p3, float* norma
if(normalizedPosition != nullptr) {
*normalizedPosition = u;
}
return glm::lerp(toGlm(p1), toGlm(p2), u);
return glm::mix(toGlm(p1), toGlm(p2), u);
}

//----------------------------------------------------------
Expand Down Expand Up @@ -958,7 +958,7 @@ T ofPolyline_<T>::getPointAtIndexInterpolated(float findex) const {
getInterpolationParams(findex, i1, i2, t);
T leftPoint(points[i1]);
T rightPoint(points[i2]);
return glm::lerp(toGlm(leftPoint), toGlm(rightPoint), t);
return glm::mix(toGlm(leftPoint), toGlm(rightPoint), t);
}


Expand Down Expand Up @@ -1027,7 +1027,7 @@ T ofPolyline_<T>::getRotationAtIndexInterpolated(float findex) const {
int i1, i2;
float t;
getInterpolationParams(findex, i1, i2, t);
return glm::lerp(toGlm(getRotationAtIndex(i1)), toGlm(getRotationAtIndex(i2)), t);
return glm::mix(toGlm(getRotationAtIndex(i1)), toGlm(getRotationAtIndex(i2)), t);
}

//--------------------------------------------------
Expand All @@ -1045,7 +1045,7 @@ T ofPolyline_<T>::getTangentAtIndexInterpolated(float findex) const {
int i1, i2;
float t;
getInterpolationParams(findex, i1, i2, t);
return glm::lerp(toGlm(getTangentAtIndex(i1)), toGlm(getTangentAtIndex(i2)), t);
return glm::mix(toGlm(getTangentAtIndex(i1)), toGlm(getTangentAtIndex(i2)), t);
}

//--------------------------------------------------
Expand All @@ -1063,7 +1063,7 @@ T ofPolyline_<T>::getNormalAtIndexInterpolated(float findex) const {
int i1, i2;
float t;
getInterpolationParams(findex, i1, i2, t);
return glm::lerp(toGlm(getNormalAtIndex(i1)), toGlm(getNormalAtIndex(i2)), t);
return glm::mix(toGlm(getNormalAtIndex(i1)), toGlm(getNormalAtIndex(i2)), t);
}


Expand Down

0 comments on commit bf24011

Please sign in to comment.