Commit fca0faf5 authored by Luis Peñaranda's avatar Luis Peñaranda

keep aspect ratio while resizing the window

parent 9fe614ff
......@@ -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) {
......
......@@ -86,9 +86,8 @@ private:
unsigned int * triangleIndices;
float * verticesPositions;
float * textureCoordinates;
float windowWidth;
float windowHeight;
//float windowWidth;
//float windowHeight;
};
#endif // OPENGLCANVAS_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment