Permalink
Browse files

Merge pull request #1538 from andreasmuller/upstream_develop

Upstream develop
  • Loading branch information...
2 parents 09f01de + c82cefe commit 07d8a251d5fd4004c76f95cb8444012365adb4fe @arturoc arturoc committed Oct 25, 2012
@@ -292,7 +292,7 @@ void testApp::drawScene(int iCameraDraw){
// from the inverseCameraMatrix object
// to OpenGL, and apply that matrix to
// the current OpenGL transform
- glMultMatrixf(inverseCameraMatrix.getPtr());
+ ofMultMatrix( inverseCameraMatrix );
//
//--
@@ -99,7 +99,7 @@ void testApp::draw(){
mesh.drawFaces();
ofSetColor(255,255,255);
- light.customDraw();
+ light.draw();
// draw our normals, and show that they are perpendicular to the vector from the center to the vertex
@@ -122,7 +122,7 @@ void ofDrawArrow(const ofVec3f& start, const ofVec3f& end, float headSize) {
mat.makeRotationMatrix(ofVec3f(0,0,1), end - start);
ofPushMatrix();
ofTranslate(end);
- glMultMatrixf(mat.getPtr());
+ ofMultMatrix(mat.getPtr());
ofTranslate(0,0,-headSize);
ofCone(headSize, headSize);
ofPopMatrix();
@@ -97,7 +97,8 @@ void ofCamera::begin(ofRectangle viewport) {
calcClipPlanes(viewport);
glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
+ ofLoadIdentityMatrix();
+
if(isOrtho) {
// if(vFlip) glOrtho(0, width, height, 0, nearDist, farDist);
// else
@@ -106,14 +107,18 @@ void ofCamera::begin(ofRectangle viewport) {
#else
ofMatrix4x4 ortho;
ortho.makeOrthoMatrix(0, viewport.width, 0, viewport.height, nearClip, farClip);
- glLoadMatrixf(ortho.getPtr());
+ ofLoadMatrix( ortho );
#endif
} else {
- gluPerspective(fov, viewport.width/viewport.height, nearClip, farClip);
+
+ ofMatrix4x4 persp;
+ persp.makePerspectiveMatrix( fov, viewport.width/viewport.height, nearClip, farClip );
+ ofLoadMatrix( persp );
+ //gluPerspective(fov, viewport.width/viewport.height, nearClip, farClip);
}
glMatrixMode(GL_MODELVIEW);
- glLoadMatrixf(ofMatrix4x4::getInverseOf(getGlobalTransformMatrix()).getPtr());
+ ofLoadMatrix( ofMatrix4x4::getInverseOf(getGlobalTransformMatrix()) );
ofViewport(viewport);
}
@@ -342,13 +342,14 @@ void ofNode::draw() {
//----------------------------------------
void ofNode::transformGL() const {
- glPushMatrix();
- glMultMatrixf(getGlobalTransformMatrix().getPtr());
+ ofPushMatrix();
+ ofMultMatrix( getGlobalTransformMatrix() );
+ //glMultMatrixf( getGlobalTransformMatrix().getPtr() );
}
//----------------------------------------
void ofNode::restoreTransformGL() const {
- glPopMatrix();
+ ofPopMatrix();
}
//----------------------------------------
@@ -360,11 +360,20 @@ void ofGLRenderer::setupScreenPerspective(float width, float height, ofOrientati
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
- gluPerspective(fov, aspect, nearDist, farDist);
+
+ ofMatrix4x4 persp;
+ persp.makePerspectiveMatrix(fov, aspect, nearDist, farDist);
+ loadMatrix( persp );
+ //gluPerspective(fov, aspect, nearDist, farDist);
+
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
- gluLookAt(eyeX, eyeY, dist, eyeX, eyeY, 0, 0, 1, 0);
+
+ ofMatrix4x4 lookAt;
+ lookAt.makeLookAtViewMatrix( ofVec3f(eyeX, eyeY, dist), ofVec3f(eyeX, eyeY, 0), ofVec3f(0, 1, 0) );
+ loadMatrix( lookAt );
+ //gluLookAt(eyeX, eyeY, dist, eyeX, eyeY, 0, 0, 1, 0);
//note - theo checked this on iPhone and Desktop for both vFlip = false and true
if(ofDoesHWOrientation()){
@@ -677,6 +686,32 @@ void ofGLRenderer::rotate(float degrees){
glRotatef(degrees, 0, 0, 1);
}
+
+//----------------------------------------------------------
+void ofGLRenderer::loadIdentityMatrix (void){
+ glLoadIdentity();
+}
+
+//----------------------------------------------------------
+void ofGLRenderer::loadMatrix (const ofMatrix4x4 & m){
+ loadMatrix( m.getPtr() );
+}
+
+//----------------------------------------------------------
+void ofGLRenderer::loadMatrix (const float *m){
+ glLoadMatrixf(m);
+}
+
+//----------------------------------------------------------
+void ofGLRenderer::multMatrix (const ofMatrix4x4 & m){
+ multMatrix( m.getPtr() );
+}
+
+//----------------------------------------------------------
+void ofGLRenderer::multMatrix (const float *m){
+ glMultMatrixf(m);
+}
+
//----------------------------------------------------------
void ofGLRenderer::setColor(const ofColor & color){
setColor(color.r,color.g,color.b,color.a);
@@ -64,7 +64,12 @@ class ofGLRenderer: public ofBaseRenderer{
void rotateY(float degrees);
void rotateZ(float degrees);
void rotate(float degrees);
-
+ void loadIdentityMatrix (void);
+ void loadMatrix (const ofMatrix4x4 & m);
+ void loadMatrix (const float * m);
+ void multMatrix (const ofMatrix4x4 & m);
+ void multMatrix (const float * m);
+
// screen coordinate things / default gl values
void setupGraphicDefaults();
void setupScreen();
@@ -270,6 +270,31 @@ void ofRotate(float degrees){
renderer->rotate(degrees);
}
+//----------------------------------------------------------
+void ofLoadIdentityMatrix (void){
+ renderer->loadIdentityMatrix();
+}
+
+//----------------------------------------------------------
+void ofLoadMatrix (const ofMatrix4x4 & m){
+ renderer->loadMatrix(m);
+}
+
+//----------------------------------------------------------
+void ofLoadMatrix (const float *m){
+ renderer->loadMatrix(m);
+}
+
+//----------------------------------------------------------
+void ofMultMatrix (const ofMatrix4x4 & m){
+ renderer->multMatrix(m);
+}
+
+//----------------------------------------------------------
+void ofMultMatrix (const float *m){
+ renderer->multMatrix(m);
+}
+
// end transformation matrix related functions
//----------------------------------------------------------
@@ -52,6 +52,11 @@ void ofRotateX(float degrees);
void ofRotateY(float degrees);
void ofRotateZ(float degrees);
void ofRotate(float degrees);
+void ofLoadIdentityMatrix (void);
+void ofLoadMatrix (const ofMatrix4x4 & m); // Andreas: I've included both a ofMatrix4x4* and a float* version here,
+void ofLoadMatrix (const float *m); // ideally we would always use ofMatrix4x4, but in a lot of temporary
+void ofMultMatrix (const ofMatrix4x4 & m); // ofMatrix4x4 objects when interacting with non-OF code
+void ofMultMatrix (const float *m);
// screen coordinate things / default gl values
void ofSetupGraphicDefaults();
@@ -197,6 +197,37 @@ class ofRendererCollection: public ofBaseRenderer{
}
}
+ void loadIdentityMatrix (void){
+ for(int i=0;i<(int)renderers.size();i++){
+ renderers[i]->loadIdentityMatrix();
+ }
+ }
+
+ void loadMatrix (const ofMatrix4x4 & m){
+ for(int i=0;i<(int)renderers.size();i++){
+ renderers[i]->loadMatrix( m );
+ }
+ }
+
+ void loadMatrix (const float * m){
+ for(int i=0;i<(int)renderers.size();i++){
+ renderers[i]->loadMatrix( m );
+ }
+ }
+
+ void multMatrix (const ofMatrix4x4 & m){
+ for(int i=0;i<(int)renderers.size();i++){
+ renderers[i]->multMatrix( m );
+ }
+ }
+
+ void multMatrix (const float * m){
+ for(int i=0;i<(int)renderers.size();i++){
+ renderers[i]->multMatrix( m );
+ }
+ }
+
+
// screen coordinate things / default gl values
void setupGraphicDefaults(){
for(int i=0;i<(int)renderers.size();i++){
@@ -16,6 +16,7 @@
#include "ofColor.h"
#include "ofMesh.h"
#include "ofPixels.h"
+#include "ofMatrix4x4.h"
template<typename T>
class ofImage_;
@@ -318,7 +319,12 @@ class ofBaseRenderer{
virtual void rotateY(float degrees){};
virtual void rotateZ(float degrees){};
virtual void rotate(float degrees){};
-
+ virtual void loadIdentityMatrix (void){};
+ virtual void loadMatrix (const ofMatrix4x4 & m){};
+ virtual void loadMatrix (const float *m){};
+ virtual void multMatrix (const ofMatrix4x4 & m){};
+ virtual void multMatrix (const float *m){};
+
// screen coordinate things / default gl values
virtual void setupGraphicDefaults(){};
virtual void setupScreen(){};

0 comments on commit 07d8a25

Please sign in to comment.