Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (498)
Games in Android Showcase (116)
games submitted by our members
Games in WIP (563)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1] 2
1  Java Game APIs & Engines / JOGL Development / Re: Catch 22 for jogl on: 2009-11-30 22:54:02
This is an exciting discussion! There is a set of C# bindings called "The Open Toolkit Library", or "openTK" (http://www.opentk.com/) which wraps openGL, openAL, and openCL. Maybe a similar name like JOTK (for Java Open Toolkit), or JOB (for Java Open Bindings)?

-sj
2  Java Game APIs & Engines / JOGL Development / Re: FBO (convert to jogl2 problem) (update:solution found) on: 2009-10-14 20:06:18
JOGL2 also contains a nice FBO wrapper class which handles most of the functionality for binding FBOs, etc. -sj
3  Java Game APIs & Engines / JOGL Development / Re: JOGL2 TextureIO missing newTextureData method??? on: 2009-10-14 20:03:54
I know-- I filed the second of those bugs. And I filed a duplicate of the first of them on the old jogl issue tracker. I guess I keep bringing this up because I haven't heard any feedback about them via the issue tracker or this board. I'd also be happy to invest some time in fixing them myself-- for example a fix for the second bug might be as simple as commenting out a single (undeeded?) reference to GL2. But since I don't have a sense of the reason for the changes in the first place or a vision of what a finished version of jogl2 is supposed to be I'm not sure where to start. For example, is awt being deprecated in place of newt? And should things like TextureRenderer and TextRenderer even be a part of JOGL2? If they are, why not add in some other utility classes? Also, is there a whole community of people fixing bugs and making changes? Or it is just a single super busy person? It looks like there has only been 5 bug reports in the last few months. Of course, I could just clone the project and fix the bugs I am concerned about. But since I use things like bienator's netbeans pack all the time I'd like the changes to be propagated to other projects. Speaking of which, it seems like the only updates are via the nightly builds, and that the only indication of changes is via the commits mailing list-- that is, there is no high level roadmap of what is going on with the project (as far as I can tell). Ok- I promise never to bring up the TextureIO bugs here again!

-sj

4  Java Game APIs & Engines / JOGL Development / Re: JOGL2 TextureIO missing newTextureData method??? on: 2009-10-14 17:49:39
No, you are misreading me. I don't want to create another thread to load in textures. And I don't always want or to am not able to load them in the init method-- I may not know what they are initially for example, or the are chosen dynamically by the user somehow. Creating them in the display method stalls the animation. The previous version of TextureData worked perfectly to address this situation. The idea of textureData is that the expensive operation of loading in the data from disk or via a URL is done *outside* the openGL loop. Then the fast process of turning that data into a texture is done on the display loop. And of course any updates to that texture are super fast using updateImage or updateSubImage. Right now the original TextureIO.newTextureData (or AWTTextureIO.newTextureData) is broken. It functions exactly the same as regular newTexture. That is, it unnecessarily requires the openGL context to be active.

Cheers, sj
5  Java Game APIs & Engines / JOGL Development / Re: JOGL2 TextureIO missing newTextureData method??? on: 2009-10-13 17:53:19
Yes, but there is still the issue where calling newTextureData fails if the openGL context is not active. newTextureData basically now exactly the same as newTexture, which means the the TextureIO functionality is broken-- you have to set up your own threads to manage loading data, etc.

-sj
6  Java Game APIs & Engines / JOGL Development / Re: "No OpenGL context current on this thread" - why? on: 2009-09-28 18:56:15
Hi, this TextureData bug hasn't been fixed or addressed, as far as I can tell, despite being submitted to both the Project Kenai issue tracker and the older java.net issue tracker by myself and bienator over a month ago. To me it seems like a fairly important issue since it breaks the entire reason the TextureData classes were created in the first place.

Are most people still using jogl1, or are people forking jogl2 to fix bugs etc? Is using the Project Kenai issue tracker the best way to submit bugs? How come no one is using it and no one is responding to any of the bugs? Even if someone were to say "this bug is to trivial to address" it would be useful...

Thanks, sj
7  Java Game APIs & Engines / JOGL Development / Re: TextRenderer incorrectly requires openGL context on: 2009-09-28 18:40:59
Hi, I just did a git pull for the latest jogl2 sources and it looks like this bug hasn't been fixed. Also no one seems to have responded to the bug I posted on the issue tracker on the kenai site. Are submitted issues are going to be acknowledged and responded to?

-sj
8  Java Game APIs & Engines / JOGL Development / Re: TextureIO creating flipped textures? on: 2009-09-03 12:02:57
You could use getSubImageTexCoords(int x1, int y1, int x2, int y2) which would give you TextureCoords properly at various regions of your image texture. Or you could first load up the image as a BufferedImage and use the ImageUtils.flipImageVertically(BufferedImage image) method before using the AWTTextureIO class to turn it into a Texture using newTexture(BufferedImage image, boolean mipmap). I don't know if there are better ways to do it. -sj
9  Java Game APIs & Engines / JOGL Development / Re: TextureIO creating flipped textures? on: 2009-09-03 08:24:46
Once you have your texture, you can call getImageTexCoords() to get the TextureCoords for your Texture and then you can use the bottom(), left(), right(), top() methods instead of specifying 0s and 1s for your texture coordinates. Also you can check the getMustFlipVertically() method and handle it yourself. I haven't noticed any issues with images being flipped since I migrated to JOGL2 and I use the TextureCoords helper class.
HTH, sj
10  Java Game APIs & Engines / JOGL Development / TextRenderer incorrectly requires openGL context on: 2009-08-31 19:29:09
Hi, this is similar to the the TextureData bug I think. If I innocently try to grab the fontRenderContext for some TextRenderer like so

1  
frc = textRenderer.getFontRenderContext();


then I get this exception:

1  
javax.media.opengl.GLException: No OpenGL context current on this thread


The actual issue occurs at line 617 of com.sun.opengl.util.awt.TextureRenderer.init(int w, int h), which is:

1  
GL2 gl = GLContext.getCurrentGL().getGL2();


Yet the GL2 variable "gl" is not used in the method anywhere.

-sj

11  Java Game APIs & Engines / JOGL Development / Re: JOGL2 FullScreen and WindowClosing issues on: 2009-08-31 01:10:54
Hi,

1) It turns out the issue with toggling back and forth between full screen and a windowed screen had to do with the stop() method of the Animator. If you call stop() from within the display loop thread then your program will halt and never return. I don't know if this is a bug or not. Calling stop() from another thread works fine. However, in JOGL2 you don't even need to stop the animator (as Cork mentioned) to go to fullscreen. The code below can be called from a keyPressed event or wherever.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
public void toFullScreen(JFrame frame, GLCanvas canvas, boolean fullscreen)
{
    removeListeners(canvas);
   
     JFrame tmpFrame = new JFrame();

      GLCanvas tmpCanvas = new GLCanvas(
        canvas.getChosenGLCapabilities(),
        new DefaultGLCapabilitiesChooser(),
        canvas.getContext(),
        null);
      tmpFrame.add(tmpCanvas);

      addListeners(tmpCanvas);
     
      if(fullscreen)
      {
      //for fullscreen
     tmpFrame.setUndecorated(true);
      device.setFullScreenWindow(tmpFrame);      
      }
      else
      {
      //for windowed screen  
     tmpFrame.setUndecorated(false);
      tmpCanvas.setSize(300, 200);
      tmpFrame.setLocation(xLocation, yLocation);
      tmpFrame.pack();
      tmpFrame.setVisible(true);
      }
      tmpCanvas.display();
      tmpFrame.requestFocus();
      tmpCanvas.requestFocus();

      frame.dispose();
      frame = tmpFrame;
      canvas = tmpCanvas;
 }


  private void addListeners(GLCanvas can)
  {
    can.addGLEventListener(Renderer.getInstance());
    can.addKeyListener(KeyboardHandler.getInstance());
    can.addMouseListener(MouseHandler.getInstance());
    can.addMouseMotionListener(MouseHandler.getInstance());
    can.addMouseWheelListener(MouseHandler.getInstance());
  }

  private void removeListeners(GLCanvas can)
  {
    can.removeMouseListener(MouseHandler.getInstance());
    can.removeMouseMotionListener(MouseHandler.getInstance());
    can.removeMouseWheelListener(MouseHandler.getInstance());
    can.removeKeyListener(KeyboardHandler.getInstance());
    can.removeGLEventListener(Renderer.getInstance());
  }

   
(This is based on code I saw somewhere else in this forum.)


2) To get the GLEventListener.dispose(GLAutoDrawable arg0) method to be called in exactly the same way as the automatically provided windowClosing event calls it, you can fire the event manually like so:

1  
2  
3  
4  
  public void fireClosingEventToTriggerDisposeMethod(Window w)
  {
    w.getToolkit().getSystemEventQueue().postEvent(new WindowEvent(w, WindowEvent.WINDOW_CLOSING));
  }


And then that method can be called when ESC is pressed or whatever.

-sj
12  Java Game APIs & Engines / JOGL Development / JOGL2 FullScreen and WindowClosing issues on: 2009-08-28 20:02:23
Hi,

I'm using the Netbeans OpenGL pack, which is wonderful. But I am having two issues.

1) My previous code (for JOGL 1.1.1) to toggle between fullscreen and back isn't working. Instead the animator seems to freeze and the application hangs.

Here's the logic that used to work:

1. create a new frame
2. create a new canvas with the same capabilities & context of the old canvas
3. add the new canvas to the new frame
4. display the new frame (ie as full screen or in a window)
5. display the canvas
6. dispose the old frame
7. create a new Animator for the new canvas and start it.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
 JFrame tmpFrame = new JFrame(appName);
 GLCanvas tmpCanvas = new GLCanvas(
        canvas.getChosenGLCapabilities(),
        new DefaultGLCapabilitiesChooser(),
        canvas.getContext(),
        null);
      tmpFrame.add(tmpCanvas);


 tmpFrame.setUndecorated(true);
 device.setFullScreenWindow(tmpFrame);

 tmpCanvas.display();

 frame.dispose();

 frame = tmpFrame;
 canvas = tmpCanvas;

 animator = new Animator(canvas);
 animator.start();


This was working, although it did seem a bit convoluted. Any ideas on how to do a fullscreen toggle in JOGL2?

2) The default JOGL2 project for the Netbeans OpenGL pack has this code:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
 frame.addWindowListener(new WindowAdapter() {

            @Override
            public void windowClosing(WindowEvent e) {
                // Run this on another thread than the AWT event queue to
               // make sure the call to Animator.stop() completes before
               // exiting
               new Thread(new Runnable() {

                    public void run() {
                        animator.stop();
                        System.exit(0);
                    }
                }).start();
            }
        });


But as far as I can tell, the display loop immediately exits upon receiving a windowClosing event, even if no windowListener is attached to the Frame. That is, the animator seems to automatically stop by itself and the GLEventListener dispose method gets automatically called. Just wanted to point this out because my shutdown hooks weren't working and it took me a while to figure out what was going on. The GLContext is still active in the dispose method and resources can be flushed properly, etc.

In other words, I think the code above can be replaced with
1  
2  
3  
public void dispose(GLAutoDrawable arg0) {
    System.exit(0);
}        


-sj
13  Java Game APIs & Engines / JOGL Development / Re: "No OpenGL context current on this thread" - why? on: 2009-08-28 00:14:12
Ok thanks, I filed one on java.net as well. Is that site outdated now? It seems like it is still active.

https://jogl.dev.java.net/issues/show_bug.cgi?id=378
14  Java Game APIs & Engines / JOGL Development / Re: "No OpenGL context current on this thread" - why? on: 2009-08-27 23:52:47
Ok, glad you agree. What is the best way to file a bug report nowadays? It seems like the JOGL home on Project Kenai doesn't have any issue tracking set up. -sj
15  Java Game APIs & Engines / JOGL Development / Re: "No OpenGL context current on this thread" - why? on: 2009-08-27 22:49:38
Hi,

I'm having a similar issue occurring with JOGL2. In JOGL1.1.1 you could call newTextureData without worrying GLContext to get a TextureData, and then in the GL display loop decide when to convert it to a Texture, or update a Texture, etc. Which I thought was the reason to have TextureData in the first place.

However in JOGL2 even trying to create a newTextureData will return this execption;

1  
2  
3  
4  
5  
6  
7  
Exception in thread "main" javax.media.opengl.GLException: No OpenGL context current on this thread
        at javax.media.opengl.GLContext.getCurrentGL(GLContext.java:159)
        at com.sun.opengl.util.texture.awt.AWTTextureData.createFromImage(AWTTextureData.java:173)
        at com.sun.opengl.util.texture.awt.AWTTextureData.<init>(AWTTextureData.java:102)
        at com.sun.opengl.util.texture.spi.awt.IIOTextureProvider.newTextureData(IIOTextureProvider.java:69)
        at com.sun.opengl.util.texture.TextureIO.newTextureDataImpl(TextureIO.java:765)
        at com.sun.opengl.util.texture.TextureIO.newTextureData(TextureIO.java:180)


Looking at the source code the single place where an openGL context is needed is in this if statement (inside of AWTTextureData.java):

1  
2  
3  
 
GLProfile glp = GLContext.getCurrentGL().getGLProfile();
if (glp.isGL2()) { ... }


Anyhow, maybe I'm confused about this, but I thought the point in having the TextureData object was so that you could load in images/data without having an active context. And in JOGL2 you need to be in the GL thread to load the background data.

Maybe there is need for a constructor like:

1  
AWTTextureData(int internalFormat, int pixelFormat, boolean mipmap, BufferedImage image, GLProfile profile) 


or

1  
AWTTextureData(int internalFormat, int pixelFormat, boolean mipmap, BufferedImage image, String profileStr) 


?

-spiraljetty

16  Java Game APIs & Engines / JOGL Development / Re: JOGL2 TextureIO missing newTextureData method??? on: 2009-08-27 11:01:54
Ok, it looks like they were moved to the subclass AWTTextureIO.
17  Java Game APIs & Engines / JOGL Development / JOGL2 TextureIO missing newTextureData method??? on: 2009-08-27 10:52:30
Hi, I'm looking to port over to JOGL2, but I can't find these methods in JOGL2's TextureIO:

1  
public static TextureData newTextureData(BufferedImage image, boolean mipmap) 


and

1  
public static TextureData newTextureData(BufferedImage image, int internalFormat, int pixelFormat, boolean mipmap)


Also, the constructor for TextureData taking a BufferedImage is missing:

1  
public TextureData(int internalFormat, int pixelFormat, boolean mipmap, BufferedImage image) 


Is there a reason why they aren't there any more? They were very useful!!!

-spiraljetty
18  Java Game APIs & Engines / JOGL Development / Re: JOGL Project Template available for NetBeans on: 2009-07-23 21:42:27
Hi, I am using the Netbeans OpenGL pack on Netbeans 6.7. I am having a small issue with webstart when I am not connected to the internet. It looks like whenever a project using the OpenGL pack is run via webstart it attempts to download jogl/gluegen files remotely. Thus, if I am not online, I get the following error:

1  
com.sun.deploy.net.FailedDownloadException: Unable to load resource: http://download.java.net/media/jogl/builds/archive/jsr-231-1.x-webstart-current/jogl.jar


That is, after I have built the webstart project (while connected), I try to run it again via the dist/launch.html link (while offline).

Now it is my understanding that webstart will attempt to cache downloaded resources or jars and use them if no updates are found or if no internet connection to the resource is available.

Can anyone more experienced with the openGL pack (or with webstart in general) advise me on how to alter my project so that it will launch even if something goes amiss with the internet connection? Or, if I am totally mistaken about the caching thing I guess ignore this post...

Thanks, Angus
19  Java Game APIs & Engines / JOGL Development / Re: VBO - No OpenGL buffer object appears to be bound on: 2009-01-12 23:18:26
Hi-- I don't know if this is relevant to your problem, but there were some openGL issues when using OS X 10.5.5. This issue seems to have been fixed in the newest update OS X 10.5.6.

-Angus

 
20  Java Game APIs & Engines / JOGL Development / TextRenderer broken in OS X 10.5.5... but fixed in 10.5.6! on: 2008-12-16 11:09:56
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
21  Java Game APIs & Engines / JOGL Development / Re: TextRenderer broken in OS X 10.5.5 on: 2008-10-10 18:26:04
Just installed the latest software update... no fix yet for this TextRenderer bug!!!  Sad
22  Java Game APIs & Engines / JOGL Development / Re: TextRenderer broken in OS X 10.5.5 on: 2008-09-27 07:07:54
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
23  Java Game APIs & Engines / JOGL Development / Re: TextRenderer broken in OS X 10.5.5 on: 2008-09-26 21:19:01
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
24  Java Game APIs & Engines / JOGL Development / TextRenderer broken in OS X 10.5.5 on: 2008-09-24 07:29:11
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
25  Java Game APIs & Engines / JOGL Development / Re: Need strategy for deploying a Java-OpenGL program on the web on: 2008-03-22 02:06:30
hi, I happened to have the same exact problem as the original poster on this thread.

I followed the instructions (using the SimpleJOGL demo) and it doesn't work... (but the regular application does work).

I'm using the latest Netbeans (6.1 beta downloaded just now) and the latest jogl pack .nbm (also just downloaded and installed) on Ubuntu.

Can you help me figure out what I am doing? It seems like there is a java.library.path error-- but isn't the point of the opengl pack to resolve the libraries automatically? Here's the automatically created launch.jnlp file:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="file:/home/angus/NetBeansProjects/SimpleJOGL/dist" href="launch.jnlp">
    <information>
        <title>SimpleJOGL</title>
        <vendor>angus</vendor>
        <homepage href=""/>
        <description>SimpleJOGL</description>
        <description kind="short">SimpleJOGL</description>
    </information>
    <resources>
        <j2se version="1.5+"/>
        <jar href="SimpleJOGL.jar" main="true" download="eager"/>
       
        <extension name="jogl" href="http://download.java.net/media/jogl/builds/archive/jsr-231-webstart-current/jogl.jnlp" />
    </resources>
    <application-desc main-class="org.yourorghere.SimpleJOGL">
    </application-desc>
</jnlp>



here's the error I get:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
java.lang.reflect.InvocationTargetException
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at com.sun.javaws.Launcher.executeApplication(Launcher.java:1272)
   at com.sun.javaws.Launcher.executeMainClass(Launcher.java:1218)
   at com.sun.javaws.Launcher.doLaunchApp(Launcher.java:1065)
   at com.sun.javaws.Launcher.run(Launcher.java:105)
   at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.UnsatisfiedLinkError: no jogl in java.library.path
   at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
   at java.lang.Runtime.loadLibrary0(Runtime.java:823)
   at java.lang.System.loadLibrary(System.java:1030)
   at com.sun.opengl.impl.NativeLibLoader.loadLibraryInternal(NativeLibLoader.java:189)
   at com.sun.opengl.impl.NativeLibLoader.access$000(NativeLibLoader.java:49)
   at com.sun.opengl.impl.NativeLibLoader$DefaultAction.loadLibrary(NativeLibLoader.java:80)
   at com.sun.opengl.impl.NativeLibLoader.loadLibrary(NativeLibLoader.java:103)
   at com.sun.opengl.impl.NativeLibLoader.access$200(NativeLibLoader.java:49)
   at com.sun.opengl.impl.NativeLibLoader$1.run(NativeLibLoader.java:111)
   at java.security.AccessController.doPrivileged(Native Method)
   at com.sun.opengl.impl.NativeLibLoader.loadCore(NativeLibLoader.java:109)
   at com.sun.opengl.impl.x11.X11GLDrawableFactory.<clinit>(X11GLDrawableFactory.java:101)
   at java.lang.Class.forName0(Native Method)
   at java.lang.Class.forName(Class.java:169)
   at javax.media.opengl.GLDrawableFactory.getFactory(GLDrawableFactory.java:111)
   at javax.media.opengl.GLCanvas.chooseGraphicsConfiguration(GLCanvas.java:520)
   at javax.media.opengl.GLCanvas.<init>(GLCanvas.java:131)
   at javax.media.opengl.GLCanvas.<init>(GLCanvas.java:90)
   at javax.media.opengl.GLCanvas.<init>(GLCanvas.java:83)
   at org.yourorghere.SimpleJOGL.main(SimpleJOGL.java:22)
   ... 9 more


I'm using the build-jogl-template-impl.xml file downloaded from cylab's posting just above this, and I have modified my build.xml to include the jnlp target.

Thanks in advance for your help!

-sj
26  Java Game APIs & Engines / JOGL Development / Re: Unicode problems with TextRenderer. Also weird texture garbage with TextRend on: 2008-02-19 07:55:22
Hi, the fixes to TextRenderer in rc8 look great!!

I did notice one strange thing when I was testing it: If I include a unicode character as the second-to-last character in the text string, I get this slightly odd overlapping:



If however it is the last character, or at any other position, it renders fine. Here's an example where the unicode character is third-to-last:



I don't actually know if this is a jogl bug or just something to do with unicode characters, but I thought I'd point it out in case it is. It happens for any font and at any font size.

~sj
27  Java Game APIs & Engines / JOGL Development / Re: Unicode problems with TextRenderer. Also weird texture garbage with TextRend on: 2008-02-16 03:36:58
Hi, here is some test code (modified from TextCube.java in the JOGL demos). There are two cases (uncomment one or the other in the constructor). The first case shows that unicode characters crash JOGL if large fonts are used. The second case shows the weird artifacts that flip back and forth when using large fonts (and no unicode characters).

I'm going to post it to the bug database too.

Thanks, sj


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.Frame;
import java.awt.event.*;
import java.awt.geom.*;

import javax.media.opengl.*;
import javax.media.opengl.glu.*;
import com.sun.opengl.util.*;
import com.sun.opengl.util.j2d.*;

/** Test Code adapted from TextCube.java (in JOGL demos) */

public class WeirdFontTest implements GLEventListener
{
   GLU glu = new GLU();
   TextRenderer renderer;

   float textScaleFactor;
   String text;
   Font font;
   boolean useMipMaps;

   public WeirdFontTest()
   {
      //test 1 - unicode hangs program with a large font & long string
     //font = new Font("default", Font.PLAIN, 200);
     //text = "\u201Cabcdefghijklmnopqrstuvwxyz\u201D";

      //test 2 - weird artifacts appear with a large font & long string
     font = new Font("default", Font.PLAIN, 200);
      text = "abcdefghijklmnopqrstuvwxyz1234567890";

      useMipMaps = true; //false
  }

   public static void main(String[] args)
   {
      Frame frame = new Frame("WeirdFontTest");
      frame.setLayout(new BorderLayout());

      GLCanvas canvas = new GLCanvas();
      final WeirdFontTest demo = new WeirdFontTest();

      canvas.addGLEventListener(demo);
      frame.add(canvas, BorderLayout.CENTER);

      frame.setSize(512, 512);
      final Animator animator = new Animator(canvas);
      frame.addWindowListener(new WindowAdapter()
            {
              public void windowClosing(WindowEvent e)
              {
                new Thread(new Runnable()
                          {
                  public void run()
                  {
                    animator.stop();
               System.exit(0);
                       }
                     }).start();
              }
            });
      frame.show();
      animator.start();
   }

   public void init(GLAutoDrawable drawable)
   {
      GL gl = drawable.getGL();

      gl.glEnable(GL.GL_DEPTH_TEST);

      renderer = new TextRenderer(font, useMipMaps);

      Rectangle2D bounds = renderer.getBounds(text);
      float w = (float) bounds.getWidth();
      float h = (float) bounds.getHeight();
      textScaleFactor = 2.0f / (w * 1.1f);
      gl.setSwapInterval(0);
   }

   public void display(GLAutoDrawable drawable)
   {
      GL gl = drawable.getGL();
      gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);

      gl.glMatrixMode(GL.GL_MODELVIEW);
      gl.glLoadIdentity();
      glu.gluLookAt(0, 0, 10,
         0, 0, 0,
         0, 1, 0);

      renderer.begin3DRendering();
      Rectangle2D bounds = renderer.getBounds(text);
      float w = (float) bounds.getWidth();
      float h = (float) bounds.getHeight();
      renderer.draw3D(text,
          w / -2.0f * textScaleFactor,
               h / -2.0f * textScaleFactor,
          3f,
          textScaleFactor);
     
                renderer.end3DRendering();
   }

   public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height)
   {
      GL gl = drawable.getGL();
      gl.glMatrixMode(GL.GL_PROJECTION);
      gl.glLoadIdentity();
      glu.gluPerspective(15, (float) width / (float) height, 5, 15);
   }

   public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged)
   {
   }
}
28  Java Game APIs & Engines / JOGL Development / Re: Unicode problems with TextRenderer. Also weird texture garbage with TextRend on: 2008-02-13 08:24:13
Hi, it is not that hard to do. but isn't that what the TextRenderer helper class is for?? Also, I guess I am just making the assumption that advanced OGL/JOGL programmers would know of optimizations, etc that I might not know about. Anyhow, I'll post the test cases before end of day tomorrow. Thanks, sj
29  Java Game APIs & Engines / JOGL Development / Re: Unicode problems with TextRenderer. Also weird texture garbage with TextRend on: 2008-02-12 17:45:05
Thanks Ken, I will do that gladly-- How do become an observer, etc? Also, is there a particular template for describing bugs, etc, or is it fairly informal?

Jean-Baptiste, using the smaller font makes the text look super-fuzzy when scaling. I am hoping that there is a way to get large crisp looking text in my application.

Thanks, sj
30  Java Game APIs & Engines / JOGL Development / Unicode problems with TextRenderer. Also weird texture garbage with TextRenderer on: 2008-02-12 03:16:33
Hi, I am having 2 separate problems with the TextRenderer class. I am using the nightly build from two nights ago, but I also tried it with rc6.

Problem 1) If I use TextRenderer to display large text, at a certain point the text starts to go crazy, and throws up random stuff. Here I am printing part of the alphabet:




Problem 2) If I use TextRenderer to display large text containing unicode characters-- e.g. curly quotes like \u201C or \u201D or anything with the \u-- then the program crashes, and I have to kill the process manually.

I am using rather large fonts, sizes of 300 and up. But I am trying to run my application across 4 screens (eventually-- right now just using 1 screen), so I will need even larger font sizes than this.

I've tried it with all sorts of different fonts, from the default Java font, to the extended Arial Unicode, to Lucian Sans Unicode, to Georgia. So it's not a matter of choosing a better font.

It spits up grabage/crashes using Windows and Linux. I have a Nvidia card on Windows and an ATI card on Linux (Ubuntu 7.10).

Specifically I am using the commands:
 
textRenderer.begin3DRendering();
textRenderer.draw3D(...);
textRenderer.end3DRendering();

Any ideas?
Pages: [1] 2
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

radar3301 (12 views)
2014-09-21 23:33:17

BurntPizza (30 views)
2014-09-21 02:42:18

BurntPizza (22 views)
2014-09-21 01:30:30

moogie (20 views)
2014-09-21 00:26:15

UprightPath (28 views)
2014-09-20 20:14:06

BurntPizza (32 views)
2014-09-19 03:14:18

Dwinin (48 views)
2014-09-12 09:08:26

Norakomi (74 views)
2014-09-10 13:57:51

TehJavaDev (102 views)
2014-09-10 06:39:09

Tekkerue (50 views)
2014-09-09 02:24:56
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!