? .classpath
? .project
? build
? mypatch
Index: make/stub_includes/opengl/GL/glxext.h
===================================================================
RCS file: /cvs/jogl/make/stub_includes/opengl/GL/glxext.h,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 glxext.h
*** make/stub_includes/opengl/GL/glxext.h	8 Jun 2003 19:27:06 -0000	1.1.1.1
--- make/stub_includes/opengl/GL/glxext.h	23 Nov 2003 18:05:17 -0000
***************
*** 605,610 ****
--- 605,704 ----
   **/
  
  /*
+ ** Notes:
+ **
+ **  Listed support is for current drivers and should really only be used
+ **  as a guideline.  ISV should still use glGetString() and
+ **  glXGetClientString() to determine the exact set of supported
+ **  GL and GLX extensions.
+ **
+ */
+ 
+ #ifndef GLX_ATI_pixel_format_float
+ #define GLX_ATI_pixel_format_float  1
+ 
+ #define GLX_RGBA_FLOAT_ATI_BIT				0x00000100
+ 
+ #endif // GLX_ATI_pixel_format_float
+ 
+ #ifndef GLX_ATI_render_texture
+ #define GLX_ATI_render_texture  1
+ 
+ #define GLX_BIND_TO_TEXTURE_RGB_ATI         0x9800 // need real tokens here
+ #define GLX_BIND_TO_TEXTURE_RGBA_ATI        0x9801
+ #define GLX_TEXTURE_FORMAT_ATI              0x9802
+ #define GLX_TEXTURE_TARGET_ATI              0x9803
+ #define GLX_MIPMAP_TEXTURE_ATI              0x9804
+ #define GLX_TEXTURE_RGB_ATI                 0x9805
+ #define GLX_TEXTURE_RGBA_ATI                0x9806
+ #define GLX_NO_TEXTURE_ATI                  0x9807
+ #define GLX_TEXTURE_CUBE_MAP_ATI            0x9808
+ #define GLX_TEXTURE_1D_ATI                  0x9809
+ #define GLX_TEXTURE_2D_ATI                  0x980A
+ #define GLX_MIPMAP_LEVEL_ATI                0x980B
+ #define GLX_CUBE_MAP_FACE_ATI               0x980C
+ #define GLX_TEXTURE_CUBE_MAP_POSITIVE_X_ATI 0x980D
+ #define GLX_TEXTURE_CUBE_MAP_NEGATIVE_X_ATI 0x980E
+ #define GLX_TEXTURE_CUBE_MAP_POSITIVE_Y_ATI 0x980F
+ #define GLX_TEXTURE_CUBE_MAP_NEGATIVE_Y_ATI 0x9810
+ #define GLX_TEXTURE_CUBE_MAP_POSITIVE_Z_ATI 0x9811
+ #define GLX_TEXTURE_CUBE_MAP_NEGATIVE_Z_ATI 0x9812
+ #define GLX_FRONT_LEFT_ATI                  0x9813
+ #define GLX_FRONT_RIGHT_ATI                 0x9814
+ #define GLX_BACK_LEFT_ATI                   0x9815
+ #define GLX_BACK_RIGHT_ATI                  0x9816
+ #define GLX_AUX0_ATI                        0x9817
+ #define GLX_AUX1_ATI                        0x9818
+ #define GLX_AUX2_ATI                        0x9819
+ #define GLX_AUX3_ATI                        0x981A
+ #define GLX_AUX4_ATI                        0x981B
+ #define GLX_AUX5_ATI                        0x981C
+ #define GLX_AUX6_ATI                        0x981D
+ #define GLX_AUX7_ATI                        0x981E
+ #define GLX_AUX8_ATI                        0x981F
+ #define GLX_AUX9_ATI                        0x9820
+ #define GLX_BIND_TO_TEXTURE_LUMINANCE_ATI   0x9821
+ #define GLX_BIND_TO_TEXTURE_INTENSITY_ATI   0x9822
+ 
+ #ifdef GLX_GLXEXT_PROTOTYPES
+ extern void glXBindTexImageATI (Display *, GLXPbuffer, int);
+ extern void glXReleaseTexImageATI (Display *, GLXPbuffer, int);
+ extern void glXDrawableAttribATI (Display *, GLXDrawable, const int *);
+ #endif /* GLX_GLXEXT_PROTOTYPES */
+ 
+ typedef void (* PFNGLXBINDTEXIMAGEATIPROC)(Display *dpy, GLXPbuffer pbuf, int buffer);
+ typedef void (* PFNGLXRELEASETEXIMAGEATIPROC)(Display *dpy, GLXPbuffer pbuf, int buffer);
+ typedef void (* PFNGLXDRAWABLEATTRIBATIPROC)(Display *dpy, GLXDrawable draw, const int *attrib_list);
+ 
+ #endif // GLX_ATI_render_texture
+ 
+ #ifndef GLX_ARB_multisample
+ #define GLX_ARB_multisample                 1
+ 
+ #define GLX_SAMPLE_BUFFERS_ARB              100000
+ #define GLX_SAMPLES_ARB                     100001
+ 
+ // put GL interface here for convenience
+ #ifndef GL_ARB_multisample
+ #define GL_ARB_multisample                  1
+ #define GL_MULTISAMPLE_ARB                  0x809D
+ #define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB     0x809E
+ #define GL_SAMPLE_ALPHA_TO_ONE_ARB          0x809F
+ #define GL_SAMPLE_COVERAGE_ARB              0x80A0
+ #define GL_SAMPLE_BUFFERS_ARB               0x80A8
+ #define GL_SAMPLES_ARB                      0x80A9
+ #define GL_SAMPLE_COVERAGE_VALUE_ARB        0x80AA
+ #define GL_SAMPLE_COVERAGE_INVERT_ARB       0x80AB
+ #define GL_MULTISAMPLE_BIT_ARB              0x20000000
+ 
+ 
+ typedef GLvoid (APIENTRY * PFNGLSAMPLECOVERAGEARBPROC)(GLclampf value, GLboolean invert);
+ #endif /* GL_ARB_multisample */
+ 
+ #endif // GLX_ARB_multisample
+ 
+ 
+ /*
   * ???. GL_NV_vertex_array_range
   */
  #ifndef GL_NV_vertex_array_range
Index: src/net/java/games/jogl/impl/x11/X11PbufferGLContext.java
===================================================================
RCS file: /cvs/jogl/src/net/java/games/jogl/impl/x11/X11PbufferGLContext.java,v
retrieving revision 1.2
diff -c -r1.2 X11PbufferGLContext.java
*** src/net/java/games/jogl/impl/x11/X11PbufferGLContext.java	8 Jul 2003 09:20:04 -0000	1.2
--- src/net/java/games/jogl/impl/x11/X11PbufferGLContext.java	23 Nov 2003 18:06:00 -0000
***************
*** 60,68 ****
    private static final int MAX_PFORMATS = 256;
    private static final int MAX_ATTRIBS  = 256;
  
!   // FIXME: figure out how to support render-to-texture and
!   // render-to-texture-rectangle (which appear to be supported, though
!   // it looks like floating-point buffers are not)
  
    public X11PbufferGLContext(GLCapabilities capabilities, int initialWidth, int initialHeight) {
      super(null, capabilities, null, null);
--- 60,72 ----
    private static final int MAX_PFORMATS = 256;
    private static final int MAX_ATTRIBS  = 256;
  
!   // State for render-to-texture and render-to-texture-rectangle support
!   private boolean created;
!   private boolean rtt;       		// render-to-texture requested?
!   private boolean hasRTT;    // render-to-texture extension available?
!   private boolean rect;      	// render-to-texture-rectangle requested?
!   private int textureTarget; 	// e.g. GL_TEXTURE_2D, GL_EXT_TEXTURE_RECTANGLE
!   private int texture;      			// actual texture object
  
    public X11PbufferGLContext(GLCapabilities capabilities, int initialWidth, int initialHeight) {
      super(null, capabilities, null, null);
***************
*** 85,133 ****
    }
  
    public void bindPbufferToTexture() {
!     // FIXME: figure out how to implement this
!     throw new GLException("Not yet implemented");
    }
  
    public void releasePbufferFromTexture() {
!     // FIXME: figure out how to implement this
!     throw new GLException("Not yet implemented");
    }
  
    public void createPbuffer(long display, long parentContext) {
!     if (display == 0) {
!       throw new GLException("Null display");
!     }
      
-     if (parentContext == 0) {
-       throw new GLException("Null parentContext");
-     }
- 
-     if (capabilities.getOffscreenFloatingPointBuffers()) {
-       throw new GLException("Floating-point pbuffers not supported yet on X11");
-     }
- 
-     if (capabilities.getOffscreenRenderToTexture()) {
-       throw new GLException("Render-to-texture pbuffers not supported yet on X11");
-     }
- 
-     if (capabilities.getOffscreenRenderToTextureRectangle()) {
-       throw new GLException("Render-to-texture-rectangle pbuffers not supported yet on X11");
-     }
- 
      int[]   iattributes = new int  [2*MAX_ATTRIBS];
-     float[] fattributes = new float[2*MAX_ATTRIBS];
-     int nfattribs = 0;
      int niattribs = 0;
! 
      // Since we are trying to create a pbuffer, the GLXFBConfig we
      // request (and subsequently use) must be "p-buffer capable".
      iattributes[niattribs++] = GL.GLX_DRAWABLE_TYPE;
      iattributes[niattribs++] = GL.GLX_PBUFFER_BIT;
  
      iattributes[niattribs++] = GL.GLX_RENDER_TYPE;
!     iattributes[niattribs++] = GL.GLX_RGBA_BIT;
! 
      iattributes[niattribs++] = GLX.GLX_DOUBLEBUFFER;
      if (capabilities.getDoubleBuffered()) {
        iattributes[niattribs++] = GL.GL_TRUE;
--- 89,174 ----
    }
  
    public void bindPbufferToTexture() {
! 	if (!rtt) {
! 	  throw new GLException("Shouldn't try to bind a pbuffer to a texture if render-to-texture hasn't been " +
! 							"specified in its GLCapabilities");
! 	}
! 
! 	GL gl = getGL();
! 	gl.glBindTexture(textureTarget, texture);
! 	if (rtt && hasRTT) {
! 	  GLX.glXBindTexImageATI(display, (int) buffer, GL.GLX_FRONT_LEFT_ATI);
! 	}
! 	// Note that if the render-to-texture extension is not supported,
! 	// we perform a glCopyTexImage2D in swapBuffers().
    }
  
    public void releasePbufferFromTexture() {
! 	if (!rtt) {
! 	  throw new GLException("Shouldn't try to bind a pbuffer to a texture if render-to-texture hasn't been " +
! 							"specified in its GLCapabilities");
! 	}
! 
! 	if (rtt && hasRTT) {
! 	  GLX.glXReleaseTexImageATI(display, (int) buffer, GLX.GLX_FRONT_LEFT_ATI);
! 	}
    }
  
    public void createPbuffer(long display, long parentContext) {
! 	if (display == 0) {
! 		throw new GLException("Null display");
! 	}
!     
! 	if (parentContext == 0) {
! 		throw new GLException("Null parentContext");
! 	}
! 
!     // Get the user request
!     rtt = capabilities.getOffscreenRenderToTexture();
!     rect = capabilities.getOffscreenRenderToTextureRectangle();
!     boolean useFloat = capabilities.getOffscreenFloatingPointBuffers();
! 
!     String extensionsStr = GLX.glXGetClientString(display, GLX.GLX_EXTENSIONS);
! 
! 	if (rtt) {
! 		if (extensionsStr.indexOf("GLX_ATI_render_texture") != -1) {
!             hasRTT = true;
!             
!             // FIXME : For now, shall set it to false
!           hasRTT = false;
!         }
!         else {
! 			System.err.println("Render-to-texture pbuffers only supported on X11 with ATI Radeon boards");
! 		}
! 	}
! 
! 	if (rect) {
! 		throw new GLException("Render-to-texture-rectangle pbuffers not supported yet on X11");
! 	}
! 
! 	if (useFloat) {
!         if (extensionsStr.indexOf("GLX_ATI_pixel_format_float") == -1) {
!             throw new GLException("Floating-point pbuffers only supported on X11 with ATI Radeon boards");
!         }
! 	}
      
      int[]   iattributes = new int  [2*MAX_ATTRIBS];
      int niattribs = 0;
!     
      // Since we are trying to create a pbuffer, the GLXFBConfig we
      // request (and subsequently use) must be "p-buffer capable".
      iattributes[niattribs++] = GL.GLX_DRAWABLE_TYPE;
      iattributes[niattribs++] = GL.GLX_PBUFFER_BIT;
  
      iattributes[niattribs++] = GL.GLX_RENDER_TYPE;
!     
! 	if (useFloat) {
! 		iattributes[niattribs++] = GL.GLX_RGBA_FLOAT_ATI_BIT;
! 	}
! 	else {
!     	iattributes[niattribs++] = GL.GLX_RGBA_BIT;
! 	}
! 	
      iattributes[niattribs++] = GLX.GLX_DOUBLEBUFFER;
      if (capabilities.getDoubleBuffered()) {
        iattributes[niattribs++] = GL.GL_TRUE;
***************
*** 202,207 ****
--- 243,250 ----
      iattributes[niattribs++] = initWidth;
      iattributes[niattribs++] = GL.GLX_PBUFFER_HEIGHT;
      iattributes[niattribs++] = initHeight;
+     iattributes[niattribs++] = GL.GLX_PRESERVED_CONTENTS;
+     iattributes[niattribs++] = GL.GL_TRUE;
  
      iattributes[niattribs++] = 0;
  
***************
*** 211,220 ****
--- 254,275 ----
        throw new GLException("pbuffer creation error: glXCreatePbuffer() failed");
      }
  
+     niattribs = 0;
+     iattributes[niattribs++] = GLX.GLX_TEXTURE_FORMAT_ATI;
+     iattributes[niattribs++] = GLX.GLX_TEXTURE_RGBA_ATI;
+     iattributes[niattribs++] = GLX.GLX_TEXTURE_TARGET_ATI;
+     iattributes[niattribs++] = GLX.GLX_TEXTURE_2D_ATI;
+     iattributes[niattribs++] = 0;
+ 
+     GLX.glXDrawableAttribATI(display, tmpBuffer, iattributes);
+ 
      // Set up instance variables
      this.display = display;
      this.parentContext = parentContext;
      buffer = tmpBuffer;
+ 
+     // FIXME : this.buffer attribute could be suppressed and replaced with drawable
+     this.drawable = buffer;
      this.fbConfig = fbConfig;
  
      // Determine the actual width and height we were able to create.
***************
*** 230,267 ****
    }
  
    protected synchronized boolean makeCurrent(Runnable initAction) throws GLException {
!     if (buffer == 0) {
!       // pbuffer not instantiated yet
!       return false;
!     }
  
!     lockAWT();
!     try {
!       boolean created = false;
!       if (context == 0) {
!         create();
!         if (DEBUG) {
!           System.err.println("!!! Created GL context for " + getClass().getName());
          }
!         created = true;
!       }
! 
!       // FIXME: this cast to int would be wrong on 64-bit platforms
!       // where the argument type to glXMakeCurrent would change (should
!       // probably make GLXDrawable, and maybe XID, Opaque as long)
!       if (!GLX.glXMakeContextCurrent(display, (int) buffer, (int) buffer, context)) {
!         throw new GLException("Error making context current");
!       }
! 
!       if (created) {
!         resetGLFunctionAvailability();
!         initAction.run();
!       }
!       return true;
      } finally {
!       unlockAWT();
!     }
    }
  
    protected synchronized void free() throws GLException {
      lockAWT();
--- 285,329 ----
    }
  
    protected synchronized boolean makeCurrent(Runnable initAction) throws GLException {
!  	created = false;
  
! 	if (buffer == 0) {
! 		// pbuffer not instantiated yet
! 		return false;
! 	}
! 
! 	lockAWT();
! 	try {
! 		boolean res = super.makeCurrent(initAction);
! 
! 		if (created) {
! 
! 			// Initialize render-to-texture support if requested
! 			if (rtt) {
! 				if (DEBUG) {
! 					System.err.println(
! 						"Initializing render-to-texture support");
! 				}
! 
! 				textureTarget = GL.GL_TEXTURE_2D;
! 
! 				int[] tmp = new int[1];
! 				gl.glGenTextures(1, tmp);
! 				texture = tmp[0];
!                 gl.glBindTexture(textureTarget, texture);
!                 gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST);
! 			    gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST);
!                 gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP_TO_EDGE);
!                 gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP_TO_EDGE);
!                 gl.glCopyTexImage2D(textureTarget, 0, GL.GL_RGBA, 0, 0, width, height, 0);
!             }
          }
!         
!         return res;
      } finally {
!     unlockAWT();
    }
+ }
  
    protected synchronized void free() throws GLException {
      lockAWT();
***************
*** 307,320 ****
      if (context == 0) {
        throw new GLException("pbuffer creation error: glXCreateNewContext() failed");
      }
! 
      if (DEBUG) {
        System.err.println("Created context for pbuffer " + width + " x " + height);
      }
    }
  
    protected void swapBuffers() throws GLException {
      // FIXME: do we need to do anything if the pbuffer is double-buffered?
    }
  
    private int queryFBConfig(long display, GLXFBConfig fbConfig, int attrib) {
--- 369,393 ----
      if (context == 0) {
        throw new GLException("pbuffer creation error: glXCreateNewContext() failed");
      }
!     
      if (DEBUG) {
        System.err.println("Created context for pbuffer " + width + " x " + height);
      }
+     
+     created = true;
    }
  
    protected void swapBuffers() throws GLException {
      // FIXME: do we need to do anything if the pbuffer is double-buffered?
+ 	// For now, just grab the pixels for the render-to-texture support.
+ 	if (rtt && !hasRTT) {
+ 	  if (DEBUG) {
+ 		System.err.println("Copying pbuffer data to GL_TEXTURE_2D state");
+ 	  }
+ 
+ 	  GL gl = getGL();
+ 	  gl.glCopyTexSubImage2D(textureTarget, 0, 0, 0, 0, 0, width, height);
+ 	}
    }
  
    private int queryFBConfig(long display, GLXFBConfig fbConfig, int attrib) {
***************
*** 334,338 ****
--- 407,426 ----
  
    private void unlockAWT() {
      getJAWT().Unlock();
+   }
+ 
+   private String glxGetLastError() {
+   //	int err = WGL.GetLastError();
+ 	String detail = "Not yet implemented";
+   //	switch (err) {
+   //	  case WGL.ERROR_INVALID_PIXEL_FORMAT: detail = "ERROR_INVALID_PIXEL_FORMAT";       break;
+   //	  case WGL.ERROR_NO_SYSTEM_RESOURCES:  detail = "ERROR_NO_SYSTEM_RESOURCES";        break;
+   //	  case WGL.ERROR_INVALID_DATA:         detail = "ERROR_INVALID_DATA";               break;
+   //	  case WGL.ERROR_PROC_NOT_FOUND:       detail = "ERROR_PROC_NOT_FOUND";             break;
+   //	  case WGL.ERROR_INVALID_WINDOW_HANDLE:detail = "ERROR_INVALID_WINDOW_HANDLE";      break;
+   //	  default:                             detail = "(Unknown error code " + err + ")"; break;
+   //	}
+ 	return detail;
+   //  }
    }
  }
