72 {
73 QSize size = revent->size();
74
75 {
76 double aspect =
static_cast<double>(viewer_.plane_.
texWidth()) /
77 static_cast<double>(viewer_.plane_.
texHeight());
78
79 int wc = 4;
80 int hc = 9;
81 if (aspect == 4.0 / 3.0) {
82 wc = 2;
83 hc = 3;
84 } else if (aspect == 16.0 / 10.0) {
85 wc = 4;
86 hc = 10;
87 }
88
89 int w = size.width();
90 int h = size.height();
91
92 int tmpH = w >> wc;
93 w = tmpH << wc;
94 size.setWidth(w);
95 tmpH *= hc;
96 if (tmpH <= h) {
97 size.setHeight(tmpH);
98 } else {
99 tmpH = h / hc;
100 h = tmpH * hc;
101 size.setHeight(h);
102 size.setWidth(tmpH << wc);
103 }
104 }
105
106 viewer_.setGeometry((revent->size().width() - size.width()) / 2,
107 (revent->size().height() - size.height()) / 2,
108 size.width(), size.height());
109 QWidget::resizeEvent(revent);
110}
GLsizei texWidth(void) const