Browse Source

Add `_perspectiveWarping` flag to `QuadSurface`

master
Krisjanis Rijnieks 10 years ago
parent
commit
c3f687172e
  1. 16
      src/Surfaces/QuadSurface.cpp
  2. 4
      src/Surfaces/QuadSurface.h

16
src/Surfaces/QuadSurface.cpp

@ -4,6 +4,7 @@ namespace ofx {
namespace piMapper { namespace piMapper {
QuadSurface::QuadSurface(){ QuadSurface::QuadSurface(){
_perspectiveWarping = false;
setup(); setup();
} }
@ -78,10 +79,11 @@ void QuadSurface::draw(){
return; return;
} }
/*if(mesh.haveVertsChanged() || mesh.haveTexCoordsChanged()){ if(mesh.haveVertsChanged() || mesh.haveTexCoordsChanged()){
calculate4dTextureCoords(); calculate4dTextureCoords();
}*/ }
/*
if(_perspectiveWarping){
glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(4, GL_FLOAT, 0, quadTexCoordinates); glTexCoordPointer(4, GL_FLOAT, 0, quadTexCoordinates);
glVertexPointer(3, GL_FLOAT, 0, quadVertices); glVertexPointer(3, GL_FLOAT, 0, quadVertices);
@ -89,12 +91,12 @@ void QuadSurface::draw(){
source->getTexture()->bind(); source->getTexture()->bind();
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, quadIndices); glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, quadIndices);
source->getTexture()->unbind(); source->getTexture()->unbind();
*/ }else{
source->getTexture()->bind(); source->getTexture()->bind();
mesh.draw(); mesh.draw();
source->getTexture()->unbind(); source->getTexture()->unbind();
} }
}
void QuadSurface::setVertex(int index, ofVec2f p){ void QuadSurface::setVertex(int index, ofVec2f p){
if(index > 3){ if(index > 3){
@ -281,5 +283,9 @@ void QuadSurface::calculate4dTextureCoords(){
quadTexCoordinates[15] = q3; quadTexCoordinates[15] = q3;
} }
void QuadSurface::setPerspectiveWarping(bool b){
_perspectiveWarping = b;
}
} // namespace piMapper } // namespace piMapper
} // namespace ofx } // namespace ofx

4
src/Surfaces/QuadSurface.h

@ -36,12 +36,16 @@ class QuadSurface : public BaseSurface {
vector <ofVec3f> & getVertices(); vector <ofVec3f> & getVertices();
vector <ofVec2f> & getTexCoords(); vector <ofVec2f> & getTexCoords();
void setPerspectiveWarping(bool b);
private: private:
void calculate4dTextureCoords(); void calculate4dTextureCoords();
GLfloat quadVertices[12]; GLfloat quadVertices[12];
GLubyte quadIndices[6]; GLubyte quadIndices[6];
GLfloat quadTexCoordinates[16]; GLfloat quadTexCoordinates[16];
bool _perspectiveWarping;
}; };
} // namespace piMapper } // namespace piMapper

Loading…
Cancel
Save