[GRASS5] NVIZ compile problem

Hello Bob,
After updating to the latest NVIZ source I get the following compile error
on IRIX 6.2:

#################################################################
/indigo-disk2/grass/grass/src.contrib/GMSL/NVIZ2.2/src
  make -f OBJ.mips-sgi-irix6.2/make.rules

make[1]: Entering directory `/indigo-disk2/grass/grass/src.contrib/GMSL/NVIZ2.2/src'
cc -L/indigo-disk2/grass/grass/src/libes/LIB.mips-sgi-irix6.2 -L/indigo-disk2/grass/doom.ee.qub.ac.uk/lib -o nvwish OBJ.mips-sgi-irix6.2/nvizAppInit.o OBJ.mips-sgi-irix6.2/change_view.o OBJ.mips-sgi-irix6.2/draw.o OBJ.mips-sgi-irix6.2/exag.o OBJ.mips-sgi-irix6.2/glwrappers.o OBJ.mips-sgi-irix6.2/init_commands.o OBJ.mips-sgi-irix6.2/lights.o OBJ.mips-sgi-irix6.2/map_obj.o OBJ.mips-sgi-irix6.2/misc.o OBJ.mips-sgi-irix6.2/nviz_init.o OBJ.mips-sgi-irix6.2/position.o OBJ.mips-sgi-irix6.2/quick_draw.o OBJ.mips-sgi-irix6.2/anim_support.o OBJ.mips-sgi-irix6.2/cutplane_obj.o OBJ.mips-sgi-irix6.2/script_support.o OBJ.mips-sgi-irix6.2/do_zoom.o OBJ.mips-sgi-irix6.2/label.o OBJ.mips-sgi-irix6.2/nvizMain.o OBJ.mips-sgi-irix6.2/togl.o OBJ.mips-sgi-irix6.2/togl_cb.o OBJ.mips-sgi-irix6.2/query_postgr.o OBJ.mips-sgi-irix6.2/openvect.o OBJ.mips-sgi-irix6.2/getCat.o OBJ.mips-sgi-irix6.2/buildPg.o OBJ.mips-sgi-irix6.2/runPg.o /indigo-disk2/grass/grass/src/libes/ogsf/LIB.mips-sgi-irix6.2/libgsf.a /indigo-disk2/grass/grass/src/libes/libimage/LIB.mips-sgi-irix6.2/libimage.a \
-lbitmap -llinkm -lvect -ldig2 \
-lgis /indigo-disk2/grass/doom.ee.qub.ac.uk/lib/LIB.mips-sgi-irix6.2/libsnprintf.a -lm -lz \
-ldatetime -L/indigo-disk2/grass/doom.ee.qub.ac.uk/lib -ltk -lm -ltcl -lm -lGLU -lGL -lSM -lICE -lX11 -lXmu -lXext -lm -lz -ltiff -lSM -lICE -lX11
ld: WARNING 84: /usr/lib/libSM.so is not used for resolving any symbol.
ld: WARNING 84: /indigo-disk2/grass/doom.ee.qub.ac.uk/lib/libz.a is not used for resolving any symbol.
ld: ERROR 33: Unresolved text symbol "glXGetCurrentDisplay" -- 1st referenced by /indigo-disk2/grass/grass/src/libes/ogsf/LIB.mips-sgi-irix6.2/libgsf.a(gsd_fonts.o).
ld: INFO 152: Output file removed because of error.
make[1]: *** [nvwish] Error 1
make[1]: Leaving directory `/indigo-disk2/grass/grass/src.contrib/GMSL/NVIZ2.2/src'
make: *** [nvwish] Error 2

I think I have a bit of an idea what's going on:
The function used is an extension to the standard OpenGL functionality
(hence the glX prefix) and the extension functions have non-standard names
that are different on different platforms. E.g. in /usr/local/include/GL/glx.h
I have
extern Display * glXGetCurrentDisplayEXT (void);
i.e. the function has a non-standard suffix.

I found the following document which seems to explain the whole thing
quite well:
http://developer.nvidia.com/docs/IO/1377/ATT/GDC2K_ogl_extensions.pdf
e.g. you may have to use the glGetString() function to find out what the
exact name is for a particular extension function before calling it.
Or something like that. Sorry I haven't got more time to look into it at
the minute....

Paul

Hi Paul,

It looks like you are right. The glXGetCurrentDisplay is a newer function and requires GLX version 1.2 or greater. This is the same problem I ran into with the off-screen rendering stuff. If you enable the OS_RENDER compile flag you will probably get errors from gsd_prim.c as well.

Like you say we need a better test for each of these functions to determine the compatible function to use. Or to find an alternative to the glX library?

Paul Kelly wrote:

Hello Bob,
After updating to the latest NVIZ source I get the following compile error
on IRIX 6.2:

#################################################################
/indigo-disk2/grass/grass/src.contrib/GMSL/NVIZ2.2/src
  make -f OBJ.mips-sgi-irix6.2/make.rules

make[1]: Entering directory `/indigo-disk2/grass/grass/src.contrib/GMSL/NVIZ2.2/src'
cc -L/indigo-disk2/grass/grass/src/libes/LIB.mips-sgi-irix6.2 -L/indigo-disk2/grass/doom.ee.qub.ac.uk/lib -o nvwish OBJ.mips-sgi-irix6.2/nvizAppInit.o OBJ.mips-sgi-irix6.2/change_view.o OBJ.mips-sgi-irix6.2/draw.o OBJ.mips-sgi-irix6.2/exag.o OBJ.mips-sgi-irix6.2/glwrappers.o OBJ.mips-sgi-irix6.2/init_commands.o OBJ.mips-sgi-irix6.2/lights.o OBJ.mips-sgi-irix6.2/map_obj.o OBJ.mips-sgi-irix6.2/misc.o OBJ.mips-sgi-irix6.2/nviz_init.o OBJ.mips-sgi-irix6.2/position.o OBJ.mips-sgi-irix6.2/quick_draw.o OBJ.mips-sgi-irix6.2/anim_support.o OBJ.mips-sgi-irix6.2/cutplane_obj.o OBJ.mips-sgi-irix6.2/script_support.o OBJ.mips-sgi-irix6.2/do_zoom.o OBJ.mips-sgi-irix6.2/label.o OBJ.mips-sgi-irix6.2/nvizMain.o OBJ.mips-sgi-irix6.2/togl.o OBJ.mips-sgi-irix6.2/togl_cb.o OBJ.mips-sgi-irix6.2/query_postgr.o OBJ.mips-sgi-irix6.2/openvect.o OBJ.mips-sgi-irix6.2/getCat.o OBJ.mips-sgi-irix6.2/buildPg.o OBJ.mips-sgi-irix6.2/runPg.o /indigo-disk2/grass/grass/src/libes/ogsf/LIB.mips-sgi-irix6.2/libgs

f.a /indigo-disk2/grass/grass/src/libes/libimage/LIB.mips-sgi-irix6.2/libimage.a \

-lbitmap -llinkm -lvect -ldig2 \
-lgis /indigo-disk2/grass/doom.ee.qub.ac.uk/lib/LIB.mips-sgi-irix6.2/libsnprintf.a -lm -lz \
-ldatetime -L/indigo-disk2/grass/doom.ee.qub.ac.uk/lib -ltk -lm -ltcl -lm -lGLU -lGL -lSM -lICE -lX11 -lXmu -lXext -lm -lz -ltiff -lSM -lICE -lX11
ld: WARNING 84: /usr/lib/libSM.so is not used for resolving any symbol.
ld: WARNING 84: /indigo-disk2/grass/doom.ee.qub.ac.uk/lib/libz.a is not used for resolving any symbol.
ld: ERROR 33: Unresolved text symbol "glXGetCurrentDisplay" -- 1st referenced by /indigo-disk2/grass/grass/src/libes/ogsf/LIB.mips-sgi-irix6.2/libgsf.a(gsd_fonts.o).
ld: INFO 152: Output file removed because of error.
make[1]: *** [nvwish] Error 1
make[1]: Leaving directory `/indigo-disk2/grass/grass/src.contrib/GMSL/NVIZ2.2/src'
make: *** [nvwish] Error 2

I think I have a bit of an idea what's going on:
The function used is an extension to the standard OpenGL functionality
(hence the glX prefix) and the extension functions have non-standard names
that are different on different platforms. E.g. in /usr/local/include/GL/glx.h
I have
extern Display * glXGetCurrentDisplayEXT (void);
i.e. the function has a non-standard suffix.

I found the following document which seems to explain the whole thing
quite well:
http://developer.nvidia.com/docs/IO/1377/ATT/GDC2K_ogl_extensions.pdf
e.g. you may have to use the glGetString() function to find out what the
exact name is for a particular extension function before calling it.
Or something like that. Sorry I haven't got more time to look into it at
the minute....

Paul

--
Bob Covill

Tekmap Consulting
P.O. Box 2016
Fall River, N.S.
B2T 1K6
Canada

E-Mail: bcovill@tekmap.ns.ca
Phone: 902-860-1496
Fax: 902-860-1498

Hello again Bob

On Fri, 2 May 2003, Bob Covill wrote:

Hi Paul,

It looks like you are right. The glXGetCurrentDisplay is a newer
function and requires GLX version 1.2 or greater. This is the same

Looks like it became standardised with GLX 1.2 but was already existing as
an experimental extension in GLX 1.1. I've just realised there are 3 machines
in my lab with GLX versions 1.1 and 1.2 (SGI Irix 6.2 and 6.4
respectively) and 1.3 (Redhat Linux 7.2) so maybe I am in a good position
to test this.

On the 1.1 system the function is there and called
glXGetCurrentDisplayEXT()
On the 1.2 system both
glXGetCurrentDisplayEXT() *and* glXGetCurrentDisplay()
are present and on the 1.3 system only
glXGetCurrentDisplay()
is there.

So is the following patch OK by you?

Index: gsd_fonts.c

RCS file: /grassrepository/grass/src/libes/ogsf/gsd_fonts.c,v
retrieving revision 1.6
diff -u -r1.6 gsd_fonts.c
--- gsd_fonts.c 22 Apr 2003 17:23:35 -0000 1.6
+++ gsd_fonts.c 2 May 2003 20:31:27 -0000
@@ -59,7 +59,11 @@

    assert( name );

+#ifdef GLX_VERSION_1_2
    dpy = glXGetCurrentDisplay();
+#else
+ dpy = glXGetCurrentDisplayEXT();
+#endif
    fontinfo = XLoadQueryFont( dpy, name );
    if (!fontinfo) {
      fprintf(stderr, "Error -- unable to load font\n");

It works for me so if it works for you you should submit it. Maybe we
could do something similar for the off-screen rendering. I will look at it
when I have time and test the other new features. I see already the slider
for positioning the vector above the surface. It is really good as the
same feature in SG3d doesn't have a numerical value beside it (for most of
my work I need it dead on the surface) and I just had to guess if it was
on the surface when parts of it started to slightly disappear. So it is a
good improvement.

Paul

Paul,

I think you are on the right track. My only worry is that glXGetCurrentDisplayEXT() may not be the standard function for pre GLX 1.2. Unfortunately all of my machinces are post 1.2 so it is difficult to test.

Out of curiousity I replaced my
dpy = glXGetCurrentDisplay();
with
dpy = XOpenDisplay(0);
and it worked. You should close the XOpenDisplay at the end of the function (before return fontbase).

Could you see if this works for you. It may be a more generic display query that is not subject to library versions.

Thanks for looking into this.

Paul Kelly wrote:

Hello again Bob

On Fri, 2 May 2003, Bob Covill wrote:

Hi Paul,

It looks like you are right. The glXGetCurrentDisplay is a newer
function and requires GLX version 1.2 or greater. This is the same

Looks like it became standardised with GLX 1.2 but was already existing as
an experimental extension in GLX 1.1. I've just realised there are 3 machines
in my lab with GLX versions 1.1 and 1.2 (SGI Irix 6.2 and 6.4
respectively) and 1.3 (Redhat Linux 7.2) so maybe I am in a good position
to test this.

On the 1.1 system the function is there and called
glXGetCurrentDisplayEXT()
On the 1.2 system both
glXGetCurrentDisplayEXT() *and* glXGetCurrentDisplay()
are present and on the 1.3 system only
glXGetCurrentDisplay()
is there.

So is the following patch OK by you?

Index: gsd_fonts.c

RCS file: /grassrepository/grass/src/libes/ogsf/gsd_fonts.c,v
retrieving revision 1.6
diff -u -r1.6 gsd_fonts.c
--- gsd_fonts.c 22 Apr 2003 17:23:35 -0000 1.6
+++ gsd_fonts.c 2 May 2003 20:31:27 -0000
@@ -59,7 +59,11 @@

    assert( name );

+#ifdef GLX_VERSION_1_2
    dpy = glXGetCurrentDisplay();
+#else
+ dpy = glXGetCurrentDisplayEXT();
+#endif
    fontinfo = XLoadQueryFont( dpy, name );
    if (!fontinfo) {
      fprintf(stderr, "Error -- unable to load font\n");

It works for me so if it works for you you should submit it. Maybe we
could do something similar for the off-screen rendering. I will look at it
when I have time and test the other new features. I see already the slider
for positioning the vector above the surface. It is really good as the
same feature in SG3d doesn't have a numerical value beside it (for most of
my work I need it dead on the surface) and I just had to guess if it was
on the surface when parts of it started to slightly disappear. So it is a
good improvement.

Paul

--
Bob Covill

Tekmap Consulting
P.O. Box 2016
Fall River, N.S.
B2T 1K6
Canada

E-Mail: bcovill@tekmap.ns.ca
Phone: 902-860-1496
Fax: 902-860-1498

Bob Covill wrote:

I think you are on the right track. My only worry is that
glXGetCurrentDisplayEXT() may not be the standard function for pre GLX
1.2. Unfortunately all of my machinces are post 1.2 so it is difficult
to test.

It would be better to just avoid the use of glXGetCurrentDisplay[EXT]
altogether.

Out of curiousity I replaced my
dpy = glXGetCurrentDisplay();
with
dpy = XOpenDisplay(0);
and it worked. You should close the XOpenDisplay at the end of the
function (before return fontbase).

Could you see if this works for you. It may be a more generic display
query that is not subject to library versions.

AFAICT, the OGSF library should not be using any glX functions, or
even any X-specific functions.

The version in 5.0.2 doesn't use a single Xlib or glX function; it
uses functions from other GRASS libraries, TIFF, GL/GLU and ANSI
functions from libc/libm, and so should be completely portable (i.e.
the 5.0.2 OGSF library should work with a native Windows version).

--
Glynn Clements <glynn.clements@virgin.net>

Glynn Clements wrote:

Bob Covill wrote:

I think you are on the right track. My only worry is that glXGetCurrentDisplayEXT() may not be the standard function for pre GLX 1.2. Unfortunately all of my machinces are post 1.2 so it is difficult to test.

It would be better to just avoid the use of glXGetCurrentDisplay[EXT]
altogether.

Out of curiousity I replaced my
dpy = glXGetCurrentDisplay();
with
dpy = XOpenDisplay(0);
and it worked. You should close the XOpenDisplay at the end of the function (before return fontbase).

Could you see if this works for you. It may be a more generic display query that is not subject to library versions.

AFAICT, the OGSF library should not be using any glX functions, or
even any X-specific functions.

The version in 5.0.2 doesn't use a single Xlib or glX function; it
uses functions from other GRASS libraries, TIFF, GL/GLU and ANSI
functions from libc/libm, and so should be completely portable (i.e. the 5.0.2 OGSF library should work with a native Windows version).

Glynn,

I agree it would be nice to avoid any unnecessary dependancies. The font stuff that I added in gsd_fonts.c is a modification of the code from togl.c (Togl_LoadBitmapFont). I changed it a little bit.

Would it be better to have the font loading stuff in NVIZ2.2/src and then pass the fontbase (OpenGL list) to whatever function is requesting it (eg. gsd_put_legend)?

--
Bob Covill

Tekmap Consulting
P.O. Box 2016
Fall River, N.S.
B2T 1K6
Canada

E-Mail: bcovill@tekmap.ns.ca
Phone: 902-860-1496
Fax: 902-860-1498

Bob Covill wrote:

Would it be better to have the font loading stuff in NVIZ2.2/src and
then pass the fontbase (OpenGL list) to whatever function is requesting
it (eg. gsd_put_legend)?

Yes. Given that the OGSF library has remained portable so far, it
would be worth keeping it that way, IMHO.

Similarly, the off-screen rendering stuff might be better off being
added to Togl.

As all of NVIZ' main components (OpenGL, Tcl/Tk and Togl) are
available on both Unix/X11 and Windows (OpenGL and Tcl/Tk are also
available for Mac but, AFAIK, Togl isn't), it would be worth avoiding
creating unnecessary obstacles to having a native Windows version of
NVIZ in the future.

--
Glynn Clements <glynn.clements@virgin.net>