#include "ofMain.h" class ofApp : public ofBaseApp { public: ofImage img; ofEasyCam cam; ofSpherePrimitive sphere; float zoom = 0.5; float xoff = 0; float yoff = 0; void setup() { sphere.set(1000, 128); img.load("pano.jpg"); } void update() { ofTextureData& tdata = img.getTexture().getTextureData(); bool normalized = (tdata.textureTarget == GL_TEXTURE_RECTANGLE_ARB); float w = tdata.tex_t * (1/zoom); float h = tdata.tex_u * (1/zoom); if(w > 2 * h) { h = w / 2; } else { w = h * 2; } float x = (xoff * w + tdata.tex_t - w) / 2; float y = (yoff * h + tdata.tex_u - h) / 2; sphere.mapTexCoords(x, y, x+w, y+h); } void draw() { ofEnableDepthTest(); cam.begin(); img.getTexture().bind(); sphere.draw(); img.getTexture().unbind(); cam.end(); } void keyPressed(int key) { if(key == '=') { cam.setFov(cam.getFov() - 1); } if(key == '-') { cam.setFov(cam.getFov() + 1); } if(key == '[') { zoom *= .99; } if(key == ']') { zoom /= .99; } if(key == OF_KEY_LEFT) { xoff -= 0.01; } if(key == OF_KEY_RIGHT) { xoff += 0.01; } if(key == OF_KEY_UP) { yoff -= 0.01; } if(key == OF_KEY_DOWN) { yoff += 0.01; } } }; int main() { ofSetupOpenGL(1280, 720, OF_WINDOW); ofRunApp(new ofApp()); }