From 0795ca4a8eb91b93804caec35071c9920d6d6325 Mon Sep 17 00:00:00 2001 From: Philippe Houdoin Date: Mon, 15 Oct 2007 18:17:28 +0000 Subject: [PATCH] Applied pieterpan's patch to disallow window to get too small. #1542 is not fixed yet, as the crash happened in Mesa Software Renderer add-on first. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22573 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../kits/opengl/direct_mode/GLDirectMode.cpp | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/tests/kits/opengl/direct_mode/GLDirectMode.cpp b/src/tests/kits/opengl/direct_mode/GLDirectMode.cpp index f510f7dad8..af2cb97933 100644 --- a/src/tests/kits/opengl/direct_mode/GLDirectMode.cpp +++ b/src/tests/kits/opengl/direct_mode/GLDirectMode.cpp @@ -71,8 +71,16 @@ SampleGLApp::SampleGLApp() SampleGLWindow::SampleGLWindow(BRect frame, uint32 type) - : BDirectWindow(frame, "OpenGL Test", B_TITLED_WINDOW, 0) + : BDirectWindow(frame, "GLDirectMode", B_TITLED_WINDOW, 0) { + float minWidth = 0.0f; + float maxWidth = 0.0f; + float minHeight = 0.0f; + float maxHeight = 0.0f; + + GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight); + SetSizeLimits(50.0f, maxWidth, 50.0f, maxHeight); + BRect r = Bounds(); r.InsetBy(10, 10); @@ -208,10 +216,12 @@ void SampleGLView::gDraw(float rotation) void SampleGLView::gReshape(int width, int height) { glViewport(0, 0, width, height); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective(45, width / (float) height, 1, 500); - glMatrixMode(GL_MODELVIEW); + if (height) { // Avoid Divide By Zero error... + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(45, width / (float) height, 1, 500); + glMatrixMode(GL_MODELVIEW); + } }