diff --git a/openglcanvas.cpp b/openglcanvas.cpp index ced8346a46a3c3e5811304c4b00f9addfc1a4a48..2ed9039cefebe571ff5a2a181bf130b4c98f8f54 100644 --- a/openglcanvas.cpp +++ b/openglcanvas.cpp @@ -157,11 +157,11 @@ void OpenGLCanvas::initializeGL(){ struct stat testbuf; if(stat(input_image,&testbuf)){ fprintf(stderr,"the default image file does not exist!\n"); - free(input_image); load_image(QFileDialog::getOpenFileName(this,tr("Choose Panorama File")).toStdString().c_str()); }else{ load_image(input_image); } + free(input_image); // mesh resolution int m,n; @@ -196,9 +196,7 @@ void OpenGLCanvas::initializeGL(){ numberOfIndices = meshNumIndices; triangleIndices = indices; - free(input_image); setShaders(); - } void OpenGLCanvas::define_texture_coordinates(float *texCoord, int m, int n, float min_phi, float max_phi, float min_lambda, float max_lambda){ @@ -458,8 +456,10 @@ void OpenGLCanvas::readTextureBytes(const char * const progname, } void OpenGLCanvas::resizeGL(int w, int h){ - glViewport(0,0,w,h); - + if(w>h) + glViewport(0,(h-w)/2,w,w); + else + glViewport((w-h)/2,0,h,h); } char * OpenGLCanvas::textFileRead(char *fn) { diff --git a/openglcanvas.h b/openglcanvas.h index 835834e0b3252a5a0a0cfd2e504dcc7eecfc1445..88fdc7b132107c8c8e4ac098cd6e644cc3eee9e3 100644 --- a/openglcanvas.h +++ b/openglcanvas.h @@ -86,9 +86,8 @@ private: unsigned int * triangleIndices; float * verticesPositions; float * textureCoordinates; - float windowWidth; - float windowHeight; - + //float windowWidth; + //float windowHeight; }; #endif // OPENGLCANVAS_H