nel-all
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Nel] GNU/Linux viewport fix


From: Loic Dachary
Subject: [Nel] GNU/Linux viewport fix
Date: Mon, 18 Feb 2002 22:55:54 +0100

        Hi,

        Here is a patch that fixes the viewport lossage on GNU/Linux.
The patch is minimal and while working on it I realized that X11
support probably need some serious work. Am I right or somehow
mistaken ?

        Cheers,

P.S. Note that the patch adds less than 15 lines ;-)

Index: nel/src/3d/driver/opengl/driver_opengl.cpp
===================================================================
RCS file: /home/cvsroot/code/nel/src/3d/driver/opengl/driver_opengl.cpp,v
retrieving revision 1.136
diff -u -r1.136 driver_opengl.cpp
--- nel/src/3d/driver/opengl/driver_opengl.cpp  15 Feb 2002 17:43:03 -0000      
1.136
+++ nel/src/3d/driver/opengl/driver_opengl.cpp  18 Feb 2002 21:48:32 -0000
@@ -1213,13 +1213,23 @@
 
 void CDriverGL::setupViewport (const class CViewport& viewport)
 {
-#ifdef NL_OS_WINDOWS
+#if NL_OS_WINDOWS
        if (_hWnd)
        {
                // Get window rect
                RECT rect;
                GetClientRect (_hWnd, &rect);
-
+               // Setup gl viewport
+               int clientWidth=rect.right-rect.left;
+               int clientHeight=rect.bottom-rect.top;
+#else // NL_OS_WINDOWS
+               XWindowAttributes win_attributes;
+               if (!XGetWindowAttributes(dpy, win, &win_attributes))
+                 throw EBadDisplay("Can't get window attributes.");
+               // Setup gl viewport
+               int clientWidth=win_attributes.width;
+               int clientHeight=win_attributes.height;
+#endif // NL_OS_WINDOWS
                // Get viewport
                float x;
                float y;
@@ -1227,9 +1237,6 @@
                float height;
                viewport.getValues (x, y, width, height);
 
-               // Setup gl viewport
-               int clientWidth=rect.right-rect.left;
-               int clientHeight=rect.bottom-rect.top;
                int ix=(int)((float)clientWidth*x);
                clamp (ix, 0, clientWidth);
                int iy=(int)((float)clientHeight*y);
@@ -1239,6 +1246,7 @@
                int iheight=(int)((float)clientHeight*height);
                clamp (iheight, 0, clientHeight-iy);
                glViewport (ix, iy, iwidth, iheight);
+#if NL_OS_WINDOWS
        }
 #endif // NL_OS_WINDOWS
 }

-- 
Loic   Dachary         http://www.dachary.org/  address@hidden
12 bd  Magenta         http://www.senga.org/      address@hidden
75010    Paris         T: 33 1 42 45 07 97          address@hidden
        GPG Public Key: http://www.dachary.org/loic/gpg.txt


reply via email to

[Prev in Thread] Current Thread [Next in Thread]