[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference bgsdev::open3d

Title:open3d
Notice:Kits on notes 3 and 4; Documents note 223
Moderator:WRKSYS::COULTER
Created:Wed Dec 09 1992
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:1306
Total number of notes:5260

1243.0. "Is GL_PROXY_TEXTURE_2D_EXT a supported extension ?" by PEACHS::PEACHS::BECHTOLD () Tue Feb 11 1997 19:08

	Hello,

	I have a customer with Digital Unix V4.01 and Open3D V4.1 for Digital Unix 
running on an AlphaStation 600 with a PowerStorm 4D60T, No Texture Memory, and their
trying to use the GL_PROXY_TEXTURE_2D_EXT extension. 

- Is this supported under Open3D V4.1 ?

I have a customers reproducer that Seg Faults when run using this extension.

Customer reproducer is appended...

I'm not to OpenGL literate so be nice :^)

Any help is appreciated.

Regards,
Dave Bechtold
DTN 343-1216
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 * xtsize.c
 *
 * Calculate max number of 32-bit Texels available on this host.
 *
 * Eric LaPresto, CCF CAMIS, February 5, 1996
 *
 */

static const char rcsid[] = "$Id$";

static const char copyright[] = "Copyright (c) 1997, Cleveland Clinic Foundation
, Cleveland, OH";

/*
 * $Log$
 */

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <math.h>

#include <Xm/Frame.h>

#include <X11/keysym.h>

#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glx.h>
#include <X11/GLw/GLwMDrawA.h>  /* Motif OpenGL drawing area widget */

void
ignoreGLerror (GLenum error)
{
  GLenum error2;

  error2 = glGetError();

  if (error2 == GL_NO_ERROR) {
    return;
  }

  while ((error2 != GL_NO_ERROR) && (error2 != error)) {
    fprintf(stderr, "GL error: %s\n", gluErrorString(error));
    error2 = glGetError();
  }

  return;
}

/* assumes dimensions are powers of 2 */

int
calcBestImageSize (unsigned long *width, unsigned long *height)
{
  unsigned long dims[2];
  GLint ret_value = 1;
  register int i;
  GLenum pnames[2] =
    {GL_TEXTURE_WIDTH, GL_TEXTURE_HEIGHT};

  dims[0] = *width;
  dims[1] = *height;

  glPixelStorei (GL_UNPACK_ALIGNMENT, 1);

  /* test initial settings */

  fprintf (stdout, "running glTexImage2D...\n");

  glTexImage2D (GL_PROXY_TEXTURE_2D_EXT,         /* target */
                0,                               /* level-of-detail */
                GL_RGBA,                         /* internal format */
                dims[0], dims[1],                /* width and height */
                0,                               /* border width */
                GL_RGBA,                         /* format */
                GL_UNSIGNED_BYTE,                /* type */
                NULL);                           /* image pointer */

  ignoreGLerror (GL_TEXTURE_TOO_LARGE_EXT);

  for (i = 0; (i < 2) && ret_value; i++) {
    fprintf (stdout, "running glGetTexLevelParameteriv()...\n");

    glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D_EXT,
                              0,
                              pnames[i],
                              &ret_value);

    ignoreGLerror (GL_TEXTURE_TOO_LARGE_EXT);
  }

  fprintf (stdout, "%d\t%d\n", dims[0], dims[1]);

  if (i == 2) {
    return (1);
  }

  /* start downsampling dimensions */

  while (1) {

    dims[0] /= 2;

    fprintf (stdout, "running glTexImage2D...\n");

    glTexImage2D (GL_PROXY_TEXTURE_2D_EXT,             /* target */
                  0,                               /* level-of-detail */
                  GL_RGBA,                         /* internal format */
                  dims[0], dims[1],                /* width and height */
                  0,                               /* border width */
                  GL_RGBA,                         /* format */
                  GL_UNSIGNED_BYTE,                /* type */
                  NULL);                           /* image pointer */

    ignoreGLerror (GL_TEXTURE_TOO_LARGE_EXT);

    ret_value = 1;

    for (i = 0; (i < 2) && ret_value; i++) {

      fprintf (stdout, "running glGetTexLevelParameteriv()...\n");

      glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D_EXT,
                                0,
                                pnames[i],
                                &ret_value);

      ignoreGLerror (GL_TEXTURE_TOO_LARGE_EXT);
      fprintf (stdout, "%d\t%d\n", dims[0], dims[1]);
    }

  if (i == 2) {
    *width = dims[0];
    *height = dims[1];
    return (1);
  }

  }    /* while (1) */

  return;
}

static unsigned long
getMaxTexels (void)
{
  unsigned long width, height;

  width = 512;
  height = 512;

  calcBestImageSize (&width, &height);

  return (width * height);
}


main(int argc, char *argv[])
{
  XtAppContext   app;
  Display        *dpy;
  Widget toplevel, draw;
  GLXContext cx;
  XVisualInfo *vi;
  unsigned long ntexels;

  static int dblBuf[] = {
    GLX_DOUBLEBUFFER, GLX_RGBA, GLX_DEPTH_SIZE, 16,
    GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1,
    None
  };

  toplevel = XtAppInitialize (&app,
                              "XTsize",
                              NULL, 0,
                              &argc, argv,
                              NULL, NULL, 0);

  dpy = XtDisplay (toplevel);

  vi = glXChooseVisual(dpy, DefaultScreen(dpy), dblBuf);

  if (vi == NULL) {
    fprintf (stderr, "No available visual.\n");
    exit (1);
  }

  cx = glXCreateContext(dpy, vi,
                        /* no display list sharing */ None,
                        /* favor direct */ GL_TRUE);
  if (cx == NULL)
    XtAppError(app, "could not create rendering context");

  draw = XtVaCreateManagedWidget("draw",
                                 glwMDrawingAreaWidgetClass,
                                 toplevel,
                                 GLwNvisualInfo, vi, NULL);

  XtRealizeWidget (toplevel);
  glXMakeCurrent(dpy, XtWindow(draw), cx);

  fprintf (stdout, "OGL Version: %s\n", glGetString (GL_VERSION));
  ignoreGLerror (GL_NO_ERROR);

  fprintf (stdout, "OGL Extensions: %s\n\n", glGetString (GL_EXTENSIONS));
  ignoreGLerror (GL_NO_ERROR);

  fprintf (stdout, "GLU Version: %s\n", glGetString (GLU_VERSION));
  ignoreGLerror (GL_NO_ERROR);

  ntexels = getMaxTexels();

  fprintf (stdout, "%d\n", ntexels);

  XtAppMainLoop(app);
}
T.RTitleUserPersonal
Name
DateLines
1243.1Rules for using OpenGL extensionsVESPER::VESPEROpenGL Alpha GeekWed Feb 12 1997 10:0350
There are rules on how applications must be written to work correctly
in the presence or absence of extensions. I realize that the code in .0
is a reproducer, not the application itself, and so these rules may well
be used in the application and if so my comments can be ignored.

First, the application must check at compile time if the extension is
present in the compile-time environment. This is done with an #ifdef
test seeing if the name of the extension is defined. In this case,
the extension that provide proxy access is GL_EXT_texture, so any
use of GL_PROXY_TEXTURE_2D_EXT must be guarded with:

#ifdef GL_EXT_texture
	...
     	glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D_EXT,
                                0,
                                pnames[i],
                                &ret_value);
#else
	...
	(Code that handles no proxy texture queries)
#endif


Second, the application must check at run time if the extension is
present in the run-time environment. Since OpenGL is built on top of
X11, it may be driving a display on another computer, possibly thousands
of miles away. If that computer does not handle proxy queries, then the
application cannot make those calls. To check for this, the application
must check the string returned by glGetString (GL_EXTENSIONS) to see if
it contains "EXT_texture". Our code now looks like:

#ifdef GL_EXT_texture
	if (proxy_texture_supported) {
	    glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D_EXT,
                                0,
                                pnames[i],
                                &ret_value);
   	} else {
	    /* handle no proxy texture case */
	}
#else
	/* handle no proxy texture case */
#endif


Now, I haven't attempted to run the reproducer, so I don't know if there is
or is not a bug in the implementation. I have to let somebody from that group
look into it.

Andy V
1243.2More information...PEACHS::PEACHS::BECHTOLDWed Feb 12 1997 22:3657
    
    	Hi Andy,
    
    	Thanks for the comments. I understand the techniques you have
    described. Based on you input one would assume that the
    GL_PROXY_TEXTURE_2D_EXT routine is supported by the Open3D GL Extension 
    GL_EXT_texture. 
    
    - So this should work, correct ?
    
    I have reproduced this using the customers reproducer code on an
    AlphaStation 600, ZLXp-L2, Open3D V4.1, DUnix V4.0a. The odd thing I
    see is after it creates a small window it hangs out for 20-30 seconds
    then seg faults. Also, I also changed the customers code from passing
    GL_RGBA to passing 4 for the internal parameter, but it still fails.
    I have gotten a core dump using the reproducer as is displaying to the
    ZLXp-L2, the trace output is below along with the output from the code.
    
    # xtsize
    OGL Version: 1.0
    DEC:PKO:O3D:3.3.0:x11r6:2.6.0:11:15:95:OSF1:V4.0.214:CC:3.11:OPT::
    OGL Extensions: DEC_primitive:1.1 primitiveDEC:1.1
    GL_EXT_vertex_array:1.0 GL_EXT_vertex_array DEC_stream:1.1 
    
    GLU Version: (null)
    GL error: no error
    running glTexImage2D...
    Memory fault(coredump)
    # 
    # dbx ./xtsize core
    dbx version 3.11.10
    Type 'help' for help.
    Core file created by program "xtsize"
    
    signal Segmentation fault at >*[memcpy, 0x3ff800d2164]  ldq_u   r3,
    0(r17)
    (dbx) t
    >  0 memcpy(0x10, 0x3ffc0080e18, 0x100000, 0x200, 0x3ff80194608)
    [0x3ff800d2164]
       1 __glFillImage(0x1401, 0x1400231e8, 0x100003, 0x200, 0x200)
    [0x3ff8188c02c]
       2 (unknown)() [0x3ff8188c5fc]
       3 glProtoTexImage2D(0x3ffc00802d8, 0x140000020, 0x8064,
    0x10000000000200, 0x1400222a0) [0x3ff8188d1f4]
       4 glTexImage2D(0x1400222a0, 0x140000020, 0x1908, 0x1401, 0x0)
    [0x3ff81815b7c]
       5 calcBestImageSize(0x100100001000, 0x200, 0x200, 0x3ffc00802d8,
    0x140000100) [0x120001fec]
       6 main(0x270032, 0x200, 0x200, 0x140008180, 0x100000001)
    [0x1200024bc]
    (dbx)
    
    
    Any other input or help is greatly appreciated.
    
    Dave Bechtold
    
1243.3Sorry, but it appears that Open3D v4.1 does NOT support GL_EXT_texture extensionVESPER::VESPEROpenGL Alpha GeekThu Feb 13 1997 10:3437
>    	Thanks for the comments. I understand the techniques you have
>    described. Based on you input one would assume that the
>    GL_PROXY_TEXTURE_2D_EXT routine is supported by the Open3D GL Extension 
>    GL_EXT_texture. 

Almost -- I said that GL_PROXY_TEXTURE_2D_EXT is part of the *OpenGL*
extension named GL_EXT_texture. I did not claim explicitly that it was 
supported by *Open3D*. I should have said that I didn't know if it was 
supported on the 4D60T board. I should *not* have said:

    Now, I haven't attempted to run the reproducer, so I don't know if 
    there is or is not a bug in the implementation.

because that does imply that there *is* an implementation.

I apologize for my poor wording.

The return string from glGetString (GL_EXTENSIONS) that you report:

    # xtsize
    OGL Version: 1.0
    DEC:PKO:O3D:3.3.0:x11r6:2.6.0:11:15:95:OSF1:V4.0.214:CC:3.11:OPT::
    OGL Extensions: DEC_primitive:1.1 primitiveDEC:1.1
    GL_EXT_vertex_array:1.0 GL_EXT_vertex_array DEC_stream:1.1 

does NOT include the word "GL_EXT_texture", so I would not expect
to see support for GL_PROXY_TEXTURE_2D_EXT.

From the stack dump, it appears that the OpenGL library is attempting to
read an image from the NULL pointer. This is 'correct' for an OpenGL 1.0
implementation, according to the 1.0 OpenGL spec. This has changed for 
OpenGL 1.1, so that a NULL specified for an image causes the texture map
to be created with unspecified image contents. OpenGL 1.1 also include
the proxy texture queries, so this will work when Open3D supports OpenGL 1.1.
(For a date when this will happen, please contact product management.)

Andy V
1243.4Thanks... : )PEACHS::PEACHS::BECHTOLDThu Feb 13 1997 15:037
	Hi Andy,

	Thanks for the clearification, I thought this was the case but not sure.

Regards,
Dave Bechtold