Subject: [Nel] GNU/Linux compilation patches

From: Loic Dachary <[email-masked]>
Date: Sat, 2 Mar 2002 00:15:28 +0100

Hi,

	Here is a small patch against todays CVS so that 
nel & snowballs compile on the GNU/Linux operating system.

	- Missing file in 3d/Makefile.am
	- Embeded struct definition that makes gcc-2.95.4 choke
	- s/)/}/ (previously reported on the list)
	- Viewport fix previously sent but apparently not yet applied
	- Spurious inlines that prevent --with-debug compilations
	  also reported in a previous patch but apparently forgotten

	Have a nice weekend :-)

Index: nel/src/3d/Makefile.am
===================================================================
RCS file: /home/cvsroot/code/nel/src/3d/Makefile.am,v
retrieving revision 1.69
diff -u -r1.69 Makefile.am
--- nel/src/3d/Makefile.am	19 Feb 2002 11:20:57 -0000	1.69
+++ nel/src/3d/Makefile.am	1 Mar 2002 23:13:56 -0000
@@ -52,6 +52,7 @@
                        cluster.h                                       \
                        coarse_mesh_build.cpp                           \
                        coarse_mesh_build.h                             \
+                       meshvp_wind_tree.cpp                            \
                        coarse_mesh_manager.cpp                         \
                        coarse_mesh_manager.h                           \
                        computed_string.cpp                             \
Index: nel/src/3d/ps_ribbon.cpp
===================================================================
RCS file: /home/cvsroot/code/nel/src/3d/ps_ribbon.cpp,v
retrieving revision 1.4
diff -u -r1.4 ps_ribbon.cpp
--- nel/src/3d/ps_ribbon.cpp	28 Feb 2002 12:59:51 -0000	1.4
+++ nel/src/3d/ps_ribbon.cpp	1 Mar 2002 23:13:56 -0000
@@ -30,6 +30,7 @@
 #include "3d/particle_system.h"
 #include "3d/driver.h"
 #include "3d/ps_util.h"
+#include "3d/ps_located.h"
 #include "3d/texture_mem.h"
 #include "nel/misc/matrix.h"
 
@@ -38,6 +39,11 @@
 
 static NLMISC::CRGBA GradientB2W[] = {NLMISC::CRGBA(0, 0, 0, 0), NLMISC::CRGBA(255, 255, 255, 255) };
 
+struct CDummy2DAngle : CPSRotated2DParticle
+{
+  CPSLocated *getAngle2DOwner(void) { return NULL; }
+};
+
 /// private use : this create a gradient texture that goew from black to white
 static ITexture *CreateGradientTexture()
 {
@@ -160,11 +166,6 @@
 
 		// we dont use the 2d angle anymore...serial a dummy one
 		{
-			struct CDummy2DAngle : CPSRotated2DParticle
-			{
-				CPSLocated *getAngle2DOwner(void) { return NULL; }
-			};
-
 			 CDummy2DAngle _Dummy2DAngle;
 			_Dummy2DAngle.serialAngle2DScheme(f); 
 		}
Index: nel/src/3d/zone_manager.cpp
===================================================================
RCS file: /home/cvsroot/code/nel/src/3d/zone_manager.cpp,v
retrieving revision 1.5
diff -u -r1.5 zone_manager.cpp
--- nel/src/3d/zone_manager.cpp	28 Feb 2002 12:59:52 -0000	1.5
+++ nel/src/3d/zone_manager.cpp	1 Mar 2002 23:13:57 -0000
@@ -235,6 +235,7 @@
 	}
 	else
 	{
+		nldebug("file not found: %s", zonePath.c_str ());
 		_Lz->FileNotFound = true;
 		delete _Zm->Zone;
 	}
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	1 Mar 2002 23:14:01 -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
 }
Index: nel/src/3d/driver/opengl/driver_opengl_material.cpp
===================================================================
RCS file: /home/cvsroot/code/nel/src/3d/driver/opengl/driver_opengl_material.cpp,v
retrieving revision 1.57
diff -u -r1.57 driver_opengl_material.cpp
--- nel/src/3d/driver/opengl/driver_opengl_material.cpp	15 Feb 2002 17:43:41 -0000	1.57
+++ nel/src/3d/driver/opengl/driver_opengl_material.cpp	1 Mar 2002 23:14:01 -0000
@@ -104,7 +104,7 @@

 // --------------------------------------------------
-inline void CDriverGL::setTextureEnvFunction(uint stage, CMaterial& mat)
+void CDriverGL::setTextureEnvFunction(uint stage, CMaterial& mat)
 {
 	ITexture	*text= mat.getTexture(stage);
 	if(text)
@@ -138,7 +138,7 @@

 //--------------------------------
-inline void CDriverGL::setupUserTextureMatrix(uint numStages, CMaterial& mat)
+void CDriverGL::setupUserTextureMatrix(uint numStages, CMaterial& mat)
 { 
 	if (
 		(_UserTexMatEnabled != 0 && (mat.getFlags() & IDRV_MAT_USER_TEX_MAT_ALL) == 0)		
Index: nel/src/misc/p_thread.cpp
===================================================================
RCS file: /home/cvsroot/code/nel/src/misc/p_thread.cpp,v
retrieving revision 1.8
diff -u -r1.8 p_thread.cpp
--- nel/src/misc/p_thread.cpp	27 Feb 2002 15:38:48 -0000	1.8
+++ nel/src/misc/p_thread.cpp	1 Mar 2002 23:14:05 -0000
@@ -51,7 +51,7 @@
 {
 	/// \todo: implement this functionnality for posix thread
 	return NULL;
-)
+}

 /*

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

---

From: "Vianney Lecroart" <[email-masked]>
Date: Mon, 4 Mar 2002 10:30:52 +0100

Hi Loic,

The patch is applied right now. Tanks a lot.
A little things, for the macro NL_OS_WINDOWS and NL_OS_UNIX, in our case,
it's better to use #ifdef instead of  #if because on windows we only define
the macro but not set it to 1 (types_nl.h)

Vianney Lecroart
---
lead network programmer / nevrax.com
icq#: 6870415
homepage: http://ace.planet-d.net
www.geekcode.com: GCS/E d- s+++: a-- C+++$ UL++ P- L+++>+$ E+>- W++ N+ o? K-
w++$ O- M- V- PS- PE? Y PGP t 5? X+ R- tv++ b- DI D+ G e++ h+ r-- y?

---

From: Loic Dachary <[email-masked]>
Date: Mon, 4 Mar 2002 14:57:19 +0100

> the macro but not set it to 1 (types_nl.h)

	Oops. Sorry about that and thanks for the explanation.

	Cheers,

---

From: Lars Weber <[email-masked]>
Date: 02 Mar 2002 13:03:13 +0100

> nel & snowballs compile on the GNU/Linux operating system.

Thanks Loic for the patches, with them I was finally able to make
snowballs compile!

*Swwweeeeeeeet*!

My hardware is a Duron 800 with 384 MB RAM and a Voodoo 4 graphics card,
and the software a pretty clean Debian unstable system with XFree4.1 and
no non-free drivers or anything.  I can see snow and everything... and the
landscape really looks awesome!

I really had to force myself into bed yesterday night... :-)

The only problems are the low framerate, which jumps around somewhere
between 3 and 5 fps, and an extremely sensitive mouse.  I will shortly
take a look at the client.cfg to see if there are any settings that can
help me make exploring the territory even more fun!

Best wishes,
Lars

-- 
[ Lars Weber ]------< me @ lars.in-berlin.de >----[ GPG-ID: 1383B42E ]
+++ fingerprint: 44B1 1D23 DD53 E6B2 4AAB 4C36 0323 9141 1383 B42E +++
[ Using GNU ]----< www.gnu.org | www.debian.org >---[ Running Debian ]

---

From: "Vianney Lecroart" <[email-masked]>
Date: Tue, 5 Mar 2002 10:47:12 +0100

Hi,

> help me make exploring the territory even more fun!

mouse_listener.cpp line 121:
  turnZ.rotateZ ((float) Pi*2.f*(_X-mouseEvent->X));

You can change the factor (2.f) and set a lower value to have a lower mouse
sensitive.

The low framerate is normal I think, because of your Voodoo 4 (perhaps
driver are not accelerated or badly accelerated). Loic have a very high
framerate with his 3d card (nVidia) on GNU/Linux.

Vianney Lecroart
---

---

From: Loic Dachary <[email-masked]>
Date: Tue, 5 Mar 2002 10:56:02 +0100

> help me make exploring the territory even more fun!

	You could try /tilenear 0.1 while in game. It is reported to 
accelerate significatly on a G400. It is of no help if you have an
opengl driver that accelerates the calculations that are saved by reducing
this value.

	I'd be interested to know if you're using a Free Software driver
for the Voodoo 4. Since you have a rather poor framerate, I guess it's the
case. Could you provide the output of glxinfo ? 

	I found noticeable enhancement in xfree-4.2, you may want to switch
to it. Or wait that it pops in unstable.

	I'm using a Debian unstable, xfree-4.2, ati radeon 7500 on a 
Dual PIII 450 with 512Mb RAM, AGP x1. That gives me 8fps on average.

	Cheers,

---

From: Loic Dachary <[email-masked]>
Date: Wed, 6 Mar 2002 10:59:00 +0100

> framerate with his 3d card (nVidia) on GNU/Linux.

	That must be someone else. Unfortunately there is no Free
Software driver for the nVidia cards and people valuing freedom have to
chose another hardware.

	Cheers,

---

From: "Vianney Lecroart" <[email-masked]>
Date: Wed, 6 Mar 2002 11:23:24 +0100

> Software driver for the nVidia cards and people valuing freedom have to

Oups, right, it's a Vincent Caron that have a high framerate :)

Vianney Lecroart
---

---

From: Lars Weber <[email-masked]>
Date: 06 Mar 2002 14:22:46 +0100

> opengl driver that accelerates the calculations that are saved by reducing

I've tried /tilenear, and it seems to have at least a little effect:
something of up to 2 (though the framerate is a little bit too jumpy to
say exactly).

> case. Could you provide the output of glxinfo ? 

Sure:

| name of display: :0.0
| display: :0  screen: 0
| direct rendering: Yes
| server glx vendor string: SGI
| server glx version string: 1.2
| server glx extensions:
|     GLX_EXT_visual_info, GLX_EXT_visual_rating, GLX_EXT_import_context
| client glx vendor string: SGI
| client glx version string: 1.2
| client glx extensions:
|     GLX_EXT_visual_info, GLX_EXT_visual_rating, GLX_EXT_import_context
| GLX extensions:
|     GLX_EXT_visual_info, GLX_EXT_visual_rating, GLX_EXT_import_context
| OpenGL vendor string: VA Linux Systems, Inc.
| OpenGL renderer string: Mesa DRI Voodoo4 20010501 x86/MMX/3DNow!
| OpenGL version string: 1.2 Mesa 3.4.2
| OpenGL extensions:
|     GL_ARB_multitexture, GL_ARB_transpose_matrix, GL_EXT_abgr, 
|     GL_EXT_clip_volume_hint, GL_EXT_compiled_vertex_array, GL_EXT_histogram, 
|     GL_EXT_packed_pixels, GL_EXT_paletted_texture, GL_EXT_polygon_offset, 
|     GL_EXT_rescale_normal, GL_EXT_stencil_wrap, GL_EXT_texture3D, 
|     GL_EXT_texture_env_add, GL_EXT_texture_env_combine, GL_EXT_texture_object, 
|     GL_EXT_texture_lod_bias, GL_EXT_vertex_array, GL_HP_occlusion_test, 
|     GL_MESA_window_pos, GL_MESA_resize_buffers, GL_NV_texgen_reflection, 
|     GL_PGI_misc_hints, GL_SGI_color_matrix, GL_SGI_color_table, 
|     GL_SGIS_pixel_texture, GL_SGIS_texture_edge_clamp, GL_SGIX_pixel_texture
| glu version: 1.3
| glu extensions:
|     GLU_EXT_nurbs_tessellator, GLU_EXT_object_space_tess
| 
|    visual  x  bf lv rg d st colorbuffer ax dp st accumbuffer  ms  cav
|  id dep cl sp sz l  ci b ro  r  g  b  a bf th cl  r  g  b  a ns b eat
| ----------------------------------------------------------------------
| 0x23 24 tc  0 24  0 r  .  .  8  8  8  8  0  0  0  0  0  0  0  0 0 None
| 0x24 24 tc  0 24  0 r  .  .  8  8  8  8  0  0  0 16 16 16 16  0 0 Slow
| 0x25 24 tc  0 24  0 r  .  .  8  8  8  8  0 24  8  0  0  0  0  0 0 None
| 0x26 24 tc  0 24  0 r  .  .  8  8  8  8  0 24  8 16 16 16 16  0 0 Slow
| 0x27 24 tc  0 24  0 r  y  .  8  8  8  8  0  0  0  0  0  0  0  0 0 None
| 0x28 24 tc  0 24  0 r  y  .  8  8  8  8  0  0  0 16 16 16 16  0 0 Slow
| 0x29 24 tc  0 24  0 r  y  .  8  8  8  8  0 24  8  0  0  0  0  0 0 None
| 0x2a 24 tc  0 24  0 r  y  .  8  8  8  8  0 24  8 16 16 16 16  0 0 Slow
| 0x2b 24 dc  0 24  0 r  .  .  8  8  8  8  0  0  0  0  0  0  0  0 0 None
| 0x2c 24 dc  0 24  0 r  .  .  8  8  8  8  0  0  0 16 16 16 16  0 0 Slow
| 0x2d 24 dc  0 24  0 r  .  .  8  8  8  8  0 24  8  0  0  0  0  0 0 None
| 0x2e 24 dc  0 24  0 r  .  .  8  8  8  8  0 24  8 16 16 16 16  0 0 Slow
| 0x2f 24 dc  0 24  0 r  y  .  8  8  8  8  0  0  0  0  0  0  0  0 0 None
| 0x30 24 dc  0 24  0 r  y  .  8  8  8  8  0  0  0 16 16 16 16  0 0 Slow
| 0x31 24 dc  0 24  0 r  y  .  8  8  8  8  0 24  8  0  0  0  0  0 0 None
| 0x32 24 dc  0 24  0 r  y  .  8  8  8  8  0 24  8 16 16 16 16  0 0 Slow

As you have rightly guessed it is all Free Software -- just like the rest
of my system :-).  And the card worked almost out of the box.  IIRC I only
had to install the xlibmesa3 package to get acceleration working.

> to it. Or wait that it pops in unstable.

According to Branden's X Strike Force page, XFree4.2 packages shouldn't be
that far of into the future.  As I don't really feel the desire currently
to start meddling with my X setup, I think I'll go with the latter option
:-)

Gruss,
Lars

---

From: Lars Weber <[email-masked]>
Date: 06 Mar 2002 14:48:12 +0100

> You can change the factor (2.f) and set a lower value to have a lower mouse

I actually got a little used to the current sensitivity now, so it isn't
really that urgent.  But maybe I'll give this a try in the next few days
anyway.

> driver are not accelerated or badly accelerated). [...]

Yes, and I didn't really expect much more of my setup, either ;-) [0].
The card is fast enough to play most of the installed 3D screensavers
though, and so far I didn't have much use for 3D acceleration aside from
that :-)

Gruss,
Lars

[0] Though I must admit that there were some secret hopes...