ウィンドウのサイズが変更されたときに、コンテンツを拡大縮小するのではなく、ビュー ポートのサイズを大きくしたいだけです。私の問題とほとんど同じであるstackoverflow(http://stackoverflow.com/questions/5894866/resize-viewport-crop-scene)で検索中にこれを見つけました。ただし、ズームを何に設定するか、どこに設定するかについて混乱しています。1.0fで試しましたが、何も表示されませんでした:s
これは、スケーリングを行う現時点でのサイズ変更関数コードです。
void GLRenderer::resize() {
RECT rect;
int width, height;
GLfloat aspect;
GetClientRect(hWnd, &rect);
width = rect.right;
height = rect.bottom;
if (height == 0) {
height = 1;
}
aspect = (GLfloat) width / height;
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0, aspect, 0.1, 100.0);
glMatrixMode(GL_MODELVIEW);
}
そして、単純な三角形をレンダリングする私の関数:
void GLRenderer::render() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslated(0, 0, -20);
glBegin(GL_TRIANGLES);
glColor3d(1, 0, 0);
glVertex3d(0, 1, 0);
glVertex3d(1, -1, 0);
glVertex3d(-1, -1, 0);
glEnd();
SwapBuffers(hDC);
}