TextRenderer broken in OS X 10.5.5

Hi, the newest OS X update (10.5.5) seems for some unknown reason to totally garble the TextRenderer code (both 2D and 3D rendering). For instance, none of the text renderer demos work properly. That is, they run, but the text is unreadable.

I have a GeForce 8600M GT. Does anyone else have this problem?

-sj

Hi, no one has any insight about this problem??

I’ve filed it as bug #364 on the jogl issue tracker.

There are also comments on the Apple Developer site about it. -sj

Thanks for the report. Sorry for not keeping up on the forums. See the comments on Issue 364 for our diagnosis and a workaround. Could you please point to the comments on the Apple Developer site regarding this problem (add the pointer to Issue 364)? Thanks.

Hi, the workaround fails as well. I set the backingStore.markDirty(…) method to take the following parameters (as it is called when private variable DEBUG is set to true):

 getBackingStore().markDirty(0, 0, getBackingStore().getWidth(),
                                    getBackingStore().getHeight());

Ie, to zap the entire backing store. It works fine when a single TextRenderer object is being used (albeit at a slightly slower frame rate). However when multiple TextRenderers are used, then after a short period of time the text begins going completely nuts. (Although the text is actually readable and not garbled, it appears as though the Texture Renderer is displaying the wrong text taken from a different TextRenderer object… very odd).

It’s good to know that someone is looking into this though as it is very frustrating!

thanks, sj

Good news: we heard from Apple that they have tracked down and fixed the bug. However as is Apple’s fashion they can not comment on when the fix will become publicly available. I told them we would appreciate it if they could fix it soon.

Just installed the latest software update… no fix yet for this TextRenderer bug!!! :frowning:

Can you give me the stack trace? I think I have a workaround for you (it is already used in TUER :smiley: as I had some problems with TextRenderer too, see Issue 356).

Using the information provided by Ken Russell, I came up with a hack that does not require a recompile of JOGL. It fixes the rendering problem with the TextureRender on the Mac temporarily until Apple releases their fix. If the code is run on Windows it does nothing since the problem is only on Mac.

NOTE: It is definitely a hack and allows you to access private functions within the TextRenderer. This violates encapsulation but since it is only temporary and I think a lot of people may not want to set up everything to recompile JOGL, here it is…

Create the following class in your classpath.


import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import com.sun.opengl.util.j2d.TextRenderer;
import com.sun.opengl.util.j2d.TextureRenderer;

/**
 * Call TextRenderHack to fix the TextRender problem on the Mac This class should only be used until
 * Apple puts out their fix.
 * 
 * @author Jeff Addison - Southgate Software Ltd. www.southgatesoftware.com
 */
public class TextRenderHack
{
	/**
	 * Call this function in your drawing code to fix the TextRender rendering problem on the Mac
	 * 
	 * @param tr Text Renderer to fix
	 */
	public static void fixIt(TextRenderer tr)
	{
		// Get the OS Name
		String osName = System.getProperty("os.name");

		// Only fix it if it's broke :)
		if (osName != null && osName.toLowerCase().contains("mac"))
		{
			// Call the TextRenderer's private function getBackingStore to get the backingStore
			TextureRenderer backingStore = (TextureRenderer) invokePrivateMethod(tr, "getBackingStore",
					null);

			// If we have a valid backing store, mark the entire thing dirty.
			if (backingStore != null)
			{
				backingStore.markDirty(0, 0, backingStore.getWidth(), backingStore.getHeight());
			}
		}
	}

	/**
	 * Invokes a private method on and Object.
	 * 
	 * @param o Object to call private method on
	 * @param methodName Name of the method to call
	 * @param params Array of parameters to be passed to the function
	 * @return Object that the method called normally returns (Cast to proper type) NOTE: This function
	 *         was found on the Internet. Lost the link so we are unable to give the author the proper
	 *         credit.
	 */
	public static Object invokePrivateMethod(Object o, String methodName, Object[] params)
	{
		// Go and find the private method...
		final Method methods[] = o.getClass().getDeclaredMethods();
		for (int i = 0; i < methods.length; ++i)
		{
			if (methodName.equals(methods[i].getName()))
			{
				try
				{
					methods[i].setAccessible(true);
					return methods[i].invoke(o, params);
				}
				catch (IllegalAccessException ex)
				{
					System.out.println("IllegalAccessException accessing " + methodName);
				}
				catch (InvocationTargetException ite)
				{
					System.out.println("InvocationTargetException accessing " + methodName);
				}
			}
		}
		return null;
	}

}

Then, use the following snippet in your drawing code wherever you use a TextRender:



TextRenderHack.fixIt( myTextRender );


I call this just before calling myTextRender.beginRendering(…); Not sure if this is the best place to call it or not, but it works.
myTextRender is the TextRender instance that you want to fix.

Hope this helps someone.

Cheers,
Jeff Addison

Is this fix required even for the first version of JOGL 1.1.1? I have no Mac to test it now.

Hi, good news-- the update from OS X 10.5.5 to 10.5.6 seems to fix all of the TextRenderer issues. Thanks again to Jeff Addison for the TextRenderHack code and the suggestions on these forums and on the jogl issuetracker.

-sj