Java 3D - 2D Textures

Hi
Has anyone gotten Java3D 1.3.2 or Java3D 1.4.0 (beta) to work properly on Mac OS X 10.4, using either Java 1.4.2 or Java 1.5? I have problems with Shape3D objects with Texture2D textures -- most of the time they are either black or so close to black as to be unusable. The problem does not seem to happen with OrientedShape3D or OrderedGroup nodes, but happens with everything else.
My understanding is that the following classes need to be implemented for Mac OS X 10.4, but I have not been able to find any example implementations:
J3dGraphicsConfig
NativeScreenInfo
NativeWSInfo
Please help! Thanks!

I don't have any specific answers, but start with http://search.info.apple.com/?asq=&as_epq=Java3D&as_oq=&as_eq=&btnG=Search&lr=langen&kword=&type=&Submit=Search and the associated links, especially http://www.apple.com/macosx/developertools/.

Similar Messages

  • Texture:illegal image size problem with loading texture

    i have used the method of loading an texture into a scene as shown in chapter 7 of java 3d tutorials. My image size is of the power 2. But why am i still getting the illegal image size error, pleeeeaaaase help, i will be greatful for any suggestions thank you. i have pasted the source code for the method of loading a texture below
    Thank you
    BranchGroup scene= new BranchGroup();
    QuadArray plane = new QuadArray(4,GeometryArray.COORDINATES|GeometryArray.TEXTURE_COORDINATE_2);
    Point3f p = new Point3f();
    p.set(-1.0f,1.0f,0.0f);
    plane.setCoordinate(0,p);
    p.set(-1.0f,-1.0f,0.0f);
    plane.setCoordinate(1,p);
    p.set(1.0f,-1.0f,0.0f);
    plane.setCoordinate(2,p);
    p.set(1.0f,1.0f,0.0f);
    plane.setCoordinate(3,p);
    TexCoord2f q = new TexCoord2f();
    q.set(0.0f,1.0f);
    plane.setTextureCoordinate(0,0,q);
    q.set(0.0f,0.0f);
    plane.setTextureCoordinate(0,1,q);
    q.set(1.0f,0.0f);
    plane.setTextureCoordinate(0,2,q);
    q.set(1.0f,1.0f);
    plane.setTextureCoordinate(0,3,q);
    TextureLoader loader = new TextureLoader("C:\\Documents and Settings\\Ozcan\\Desktop\\Java 3d\\examples\\texture\\brick.GIF",this);
    ImageComponent2D image = loader.getImage();
    Texture2D texture = new Texture2D();
    texture.setImage(0,image);
    Appearance appearance = new Appearance();
    appearance.setTexture(texture);
    Shape3D shape = new Shape3D(plane,appearance);
    scene.addChild(shape);
    return scene;

    GridBagLayout will make arrangements to display the JPanel at the size its layout manager says that it needs. To help the JPanels layout manager we can let it know that we need extra space to show the rendered image.
    class tt extends JPanel{
        Image pic1;
        tt(){
        public void paintComponent(Graphics comp){
        public Dimension getPreferredSize() {
            return new Dimension(pic1.getWidth(this), pic1.getHeight(this));
    }

  • How to Modify bottom text in notification mail

    Hi Experts,
    I have an issue regarding sending mails from my portal. When any Notification mail is triggered from Portal to Users mails at the bottom of the mail in the Signature place they are getting company name as below:
    ABCDCompany Pvt Ltd, Chennai, India
    now i how to remove "Pvt" from the above signature? where do i need to make the changes?
    Regards,
    Mahesh

    Hi,
    I've a similar problem - I'm using Text2D to create labels for a node-link graph. I've set all the capabilities, etc., and am finally able to change the labels using setString in Text2D. With one slight problem - now I'm getting an error:
    java.lang.IllegalArgumentException: Texture:illegal image size
            at javax.media.j3d.TextureRetained.checkImageSize(TextureRetained.java:389)
            at javax.media.j3d.TextureRetained.setImage(TextureRetained.java:423)
            at javax.media.j3d.Texture.setImage(Texture.java:869)
            at com.sun.j3d.utils.geometry.Text2D.setString(Text2D.java:118)
            at Label3D.setLabelText(Label3D.java:59)The only time I don't get the error is when I change the label from component ID to (which is a string containing an integer, e.g., 1234) to start/stop stage (which is another string containing an integer, e.g., 04, 11). If I attempt to change from component name (a string containing a string, e.g., "mesoderm"), say, to component ID, I get the error. So it's not about the length of the string, since component name is invariably longer than the ID, and the ID could be longer than the start/stop stage.
    oh, this is the code I have for the capabilities bit - no more complaints there
    private void setCapabilities()
      text.setCapability(text.ALLOW_APPEARANCE_READ);          
      text.setCapability(text.ALLOW_APPEARANCE_WRITE);
      Appearance appearance = text.getAppearance();
      appearance.setCapability(appearance.ALLOW_TEXTURE_READ);
      appearance.setCapability(appearance.ALLOW_TEXTURE_WRITE);
      Texture texture = appearance.getTexture();
      texture.setCapability(texture.ALLOW_IMAGE_READ);
      texture.setCapability(texture.ALLOW_IMAGE_WRITE);
    }Any ideas, anyone?
    aba.

  • How to modify the text in java3d??

    I want to modify the text in java3d.What should I do ??
    first , I add the text to the java3d;
    then , I pick it by using behaior;
    third, I setString("My dog") to change text!!
    but there have some capability error!
    how can I do that??
    thanks in advance!!

    Hi,
    I've a similar problem - I'm using Text2D to create labels for a node-link graph. I've set all the capabilities, etc., and am finally able to change the labels using setString in Text2D. With one slight problem - now I'm getting an error:
    java.lang.IllegalArgumentException: Texture:illegal image size
            at javax.media.j3d.TextureRetained.checkImageSize(TextureRetained.java:389)
            at javax.media.j3d.TextureRetained.setImage(TextureRetained.java:423)
            at javax.media.j3d.Texture.setImage(Texture.java:869)
            at com.sun.j3d.utils.geometry.Text2D.setString(Text2D.java:118)
            at Label3D.setLabelText(Label3D.java:59)The only time I don't get the error is when I change the label from component ID to (which is a string containing an integer, e.g., 1234) to start/stop stage (which is another string containing an integer, e.g., 04, 11). If I attempt to change from component name (a string containing a string, e.g., "mesoderm"), say, to component ID, I get the error. So it's not about the length of the string, since component name is invariably longer than the ID, and the ID could be longer than the start/stop stage.
    oh, this is the code I have for the capabilities bit - no more complaints there
    private void setCapabilities()
      text.setCapability(text.ALLOW_APPEARANCE_READ);          
      text.setCapability(text.ALLOW_APPEARANCE_WRITE);
      Appearance appearance = text.getAppearance();
      appearance.setCapability(appearance.ALLOW_TEXTURE_READ);
      appearance.setCapability(appearance.ALLOW_TEXTURE_WRITE);
      Texture texture = appearance.getTexture();
      texture.setCapability(texture.ALLOW_IMAGE_READ);
      texture.setCapability(texture.ALLOW_IMAGE_WRITE);
    }Any ideas, anyone?
    aba.

  • Illegal Image Size

    Hi, having returned to basic J3D bits and bobs for a few years now and I'm having some issues loading a texture.
    After having read through a few tutorials I have put together the following code. It simply creates a QuadArray of 4 points, sets the texture coordinates (which I don't know if I have done correct i.e., please note the first parameter, as the method I used to use is deprecated now) then apples and image of 64x64 pixels, a multiple of 2 - which i believe is required by J3D.
    private Shape3D loadTexture() {
            QuadArray plane = new QuadArray(4,GeometryArray.COORDINATES|GeometryArray.TEXTURE_COORDINATE_2);
            Point3f p = new Point3f();
            p.set(-1.0f,1.0f,0.0f);
            plane.setCoordinate(0,p);
            p.set(-1.0f,-1.0f,0.0f);
            plane.setCoordinate(1,p);
            p.set(1.0f,-1.0f,0.0f);
            plane.setCoordinate(2,p);
            p.set(1.0f,1.0f,0.0f);
            plane.setCoordinate(3,p);
            TexCoord2f q = new TexCoord2f();
            q.set(0.0f,1.0f);
            plane.setTextureCoordinate(0,0,q);
            q.set(0.0f,0.0f);
            plane.setTextureCoordinate(0,1,q);
            q.set(1.0f,0.0f);
            plane.setTextureCoordinate(0,2,q);
            q.set(1.0f,1.0f);
            plane.setTextureCoordinate(0,3,q);               
            URL textureURL = getClass().getResource(TEXTURE_LOCATION);
            TextureLoader loader = new TextureLoader(textureURL,this);
            ImageComponent2D image = loader.getImage();
            Texture2D texture = new Texture2D();
            texture.setImage(0,image);
            Appearance appearance = new Appearance();
            appearance.setTexture(texture);               
            Shape3D shape = new Shape3D(plane,appearance);
            return shape;
        }Any help working out why I am getting the following exception would be greatly appreciated:
    Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Texture:illegal image size
    at javax.media.j3d.TextureRetained.checkImageSize(TextureRetained.java:392)
    at javax.media.j3d.TextureRetained.initImage(TextureRetained.java:337)
    at javax.media.j3d.Texture.setImage(Texture.java:960)
    Thanks

    Look at the code in the file "TexturedPlane.java", an example of the Java3d API.
    Notice the comment "// can't use parameterless constuctor"... this solved this illegal size issue for me.
    Appearance createAppearance(String filename) {
            Appearance appear = new Appearance();
            System.out.println("TexturedPlane attempt to load file: "+filename);
            TextureLoader loader = new NewTextureLoader(filename);
            ImageComponent2D image = loader.getImage();
            if(image == null) {
                    System.out.println("load failed for texture: "+filename);
            System.out.println("Image width  = " + image.getWidth());
            System.out.println("Image height = " + image.getHeight());
            // can't use parameterless constuctor
            Texture2D texture = new Texture2D(Texture.BASE_LEVEL, Texture.RGBA,
                                              image.getWidth(), image.getHeight());
            texture.setImage(0, image);
            texture.setEnable(true);
            texture.setMagFilter(Texture.NICEST);
            appear.setTexture(texture);
            appear.setTransparencyAttributes(
               new TransparencyAttributes(TransparencyAttributes.FASTEST, 0.1f));
            return appear;
        }

  • Problem with head

    I created a head model in 3ds max and exported it to obj file (model in 3ds max was textured with 3 images)
    I loaded obj file into java 3d apllication and I loaded 3 textures but on my model visible is only the last one loaded
    and here is a question how can I load using java 3d 3 textures on obj file

    Hello syavash. I found a link where this question was answered and resolved. Let me know if the information here assists you, and I will continue to research the issue in the meantime. I'm only here to help!
    http://answers.microsoft.com/en-us/windows/forum/windows_vista-pictures/sound-doesnt-play-through-my...
    Mario
    I worked on behalf of HP.

  • How to unwarp texture in java 3d

    Hello all
    can java ( i know it can but have no idea how )
    to unwarp texture from 3d model ?

    I am a a new Java programmer who is interested in learning more in java.I was trying to use mysql stored procedures with Java but I do not know how to go about
    Thank you!

  • Java 3D, putting a texture on a IndexedTriangleFanArray Geometry Object

    Hello,
    Could any body please help me to put a texture on my IndexedTriangleFanArrayObject? I'm able to put texture on Primitives but I don't know how to do it on the Geometry I designed here. I've tried several ways but it does never work correctly. My texture is a *.jpg file.
    I did put into comments the part that didn't work here below.
    package ignitionSwitch;
    import javax.media.j3d.Appearance;
    import javax.media.j3d.Geometry;
    import javax.media.j3d.ImageComponent2D;
    import javax.media.j3d.IndexedTriangleFanArray;
    import javax.media.j3d.Material;
    import javax.media.j3d.Shape3D;
    import javax.media.j3d.Texture;
    import javax.media.j3d.Texture2D;
    import javax.media.j3d.TextureAttributes;
    import javax.media.j3d.TextureUnitState;
    import javax.media.j3d.TransformGroup;
    import javax.vecmath.Color3f;
    import javax.vecmath.Point3f;
    import javax.vecmath.TexCoord2f;
    import obj3D.Lanceur;
    import com.sun.j3d.utils.image.TextureLoader;
    public class IgnitionSwitch extends TransformGroup {
         TextureUnitState st;
         Color3f white = new Color3f(1.0f, 1.0f, 1.0f);
         Color3f black = new Color3f(0f, 0f, 0f);
         float isFront = 0.0f;
         float isback = -1.0f;
         float r = 0.1f;
         int n;
         double a;
         float x, y;
         Lanceur l;
         public IgnitionSwitch(Lanceur l) {
              this.l = l;
              this.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
              this.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
              this.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
              this.addChild(createShape());
         Shape3D createShape(){
    Shape3D ignistionSwitch = new Shape3D();
    ignistionSwitch.setGeometry(ignitionSwitch());
    ignistionSwitch.setAppearance(createApp());
    return ignistionSwitch;
         * Ignition Switch
         private Geometry ignitionSwitch() {
              IndexedTriangleFanArray ifa;
              int N = 68;
              int totalN = (N + 1);
              Point3f coords[] = new Point3f[totalN]; // 69 Points
              TexCoord2f[] textCoord = new TexCoord2f[totalN];
              int[] indices = new int[totalN];
              int[] texIndices = new int[totalN];
              int[] stripCounts = new int[]{ totalN };
              int n;
              int indice;
              double a;
              float x, y;
              coords[0 * (N + 1)] = new Point3f(0.0f, 0.0f, isFront);
              textCoord[0] = new TexCoord2f(0.1f, 0.0f);
              indices[0] = 0;
              for (a = 0, n = 0; n < N; a = (2*Math.PI) / (N - 1) * ++n) {
                   if (a<= Math.PI){
                        r = 0.1f;
                        x = (float) (r * Math.cos(a));
                        y = (float) (r * Math.sin(a));
                   } else {
                        r = 0.07f;
                        x = (float) (r * Math.cos(a));
                        y = (float) (r * Math.sin(a));
                   indice = n+1;
                   coords[indice] = new Point3f(x, y, isFront);
                   indices[indice] = indice;
                   System.out.println("Indice :" + indice + " x: "+ x + " y: "+ y);
                   textCoord[indice] = new TexCoord2f(x, y);
                   texIndices[indice] = indice;
              //     coords[1 * (N + 1) + n + 1] = new Point3f(x, y, tbArriere);
              //     colors[1 * (N + 1) + n + 1] = black;
    //          textureCoords[0] = new Point3f(-0.1f, -0.1f, isFront);
    //          textureCoords[1] = new Point3f(0.1f, -0.1f, isFront);
    //          textureCoords[2] = new Point3f(0.1f, 0.1f, isFront);
    //          textureCoords[3] = new Point3f(-0.1f, 0.1f, isFront);
    //          texIndices[0] = 0;
    //          texIndices[1] = 1;
    //          texIndices[2] = 2;
    //          texIndices[3] = 3;
              ifa = new IndexedTriangleFanArray(totalN, IndexedTriangleFanArray.COORDINATES | IndexedTriangleFanArray.TEXTURE_COORDINATE_2 | IndexedTriangleFanArray.COLOR_3, totalN, stripCounts);
              ifa.setCoordinates(0, coords);
              ifa.setCoordinateIndices(0, indices);
         //     ifa.setCoordinates(0, textureCoords);
              ifa.setTextureCoordinateIndices(0, 0, texIndices);
              ifa.setTextureCoordinates(0, 0, textCoord);
    //          tfa.setTextureCoordinate(0, new Point2f(0.0f, 1.0f));
    //          tfa.setTextureCoordinate(1, new Point2f(0.0f,0.0f));
    //          tfa.setTextureCoordinate(2, new Point2f( 1.0f,0.0f));
    //          tfa.setTextureCoordinate(3, new Point2f( 1.0f, 1.0f));
              return ifa;
    protected Appearance createApp() {
         TextureLoader textLoad = new TextureLoader("c:/temp/ignitionSwitch.jpg", l);
         ImageComponent2D textImage = textLoad.getImage();
         Texture2D texture = new Texture2D(Texture2D.BASE_LEVEL, Texture.RGB,
                                       textImage.getWidth(), textImage.getHeight());
         texture.setImage(0, textImage);
         texture.setBoundaryModeS(Texture2D.CLAMP);
         texture.setBoundaryModeT(Texture2D.CLAMP);
         Appearance app = new Appearance();
         app.setTexture(texture);
         app.setCapability(Appearance.ALLOW_TEXTURE_WRITE);
         app.setCapability(Appearance.ALLOW_TEXTURE_READ);
         app.setCapability(Appearance.ALLOW_TEXGEN_WRITE);
         TextureAttributes textAttr = new TextureAttributes();
         textAttr.setTextureMode(TextureAttributes.REPLACE);
         app.setTextureAttributes(textAttr);
         app.setMaterial(new Material());
         return app;
    } // end

    Hi
    I’m a Lightwave-Director 2004 user and swapping the
    image texture on the shader works well for me. You can try add the
    meshDeform Modifier to the model and check & save as a text
    file the textureCoordinateList of the meshes before and after
    swapping the texture`s image in the model, if both list
    aren’t equal there’s some problem with the texture
    coordinates on memory and could be resolved copying the texCoords
    before swapping and pasted again after that. I remember some issue
    about changing images on textures from imported W3D files on Dir 9,
    it doesn’t happens on runtime created geometry or Director
    2004.
    Have a nice coding!!!

  • Java3d speed collapse caused by other java apps running at the same time

    Hi
    I am programming a flightsimulator for some months.
    The current state is online available (all free, no copyrights)
    at http://www.snowraver.org/efcn/efcnsim/index.htm
    especially the sample (source) which shows the
    behaviour which is the reason for my post is here
    http://www.snowraver.org/efcn/efcnsim/page2.htm
    My Problem:
    When I start the sim while two other java programs
    ( one is a server running localhost, one is a client )
    are running, the speed of the flightsim is very slow,
    one frame update takes 3 to 5 seconds.
    ( 3 java.exe's in task list plus 1 which is the IDE )
    When I start the flightsim ALONE, I have 30 to 40 frames per second.
    ( 2 java.exe's in the task list = the flightsim and the IDE -> no prob here )
    That means, the flightsim is about 100 times slower, when
    started while the other two apps are running.
    BUT the other two applications do almost ***NOTHING***, the
    CPU load is 1 or 2 percent.
    Of course they have threads running, but all are waiting
    for a signal - no thread really consumes CPU power.
    Interestingly, when I FIRST start the flightsim and AFTER THIS
    start the two other applications, the flightsim
    holds 30 frames per seconds without problems, even
    though the other applications consume some CPU power
    until they have completely started up.
    Configurations:
    JSDK 1.4.2_1 , 0_2..
    Java3D 1.3.1 OPENGL (The DirectX version crashes with D3D device lost)
    Win2000,XP CPU 800MHz upto 3 GHz
    In my point of view, the java3d thread scheduler makes
    some funny decisions when it starts up, which lead
    to the order dependent behaviour described above.
    My question is, if anyone has some ideas, how I could
    get away from this speed collapse.
    The problem is caused in native code I guess.
    I also could imagine, that it has to do something with
    the order in which one creates, attaches and starts
    the Canvas3D. (? could produce race conditions)
    The flightsim runs in full retained mode. Of course
    the CPU work in the behaviours is rather big, because
    the ROAM triangulation update (..) is done there
    and the triangles are recalculated and passed
    ( all BY_REFERENCE ).
    Or could it have to do something with the memory
    consumption ( when all runs, almost all of
    the 512MB RAM is taken by the three java.exe's ) ?
    Any hints or ideas ?

    :) No, Sun does handle it [lol]
    I just have tested it on my computer at work
    ( 3GHz HP compaq, 1GB Ram and a Intel 82865G Graphics
    Card with 64MB memory, Windows XP )
    and it has worked without problems any way I tried.
    ( Except for xclusive fullscreen mode, but I guess, the administrators
    have deactivated it somehow, so we don't play games at work :)
    I couldn't test it under Linux so far, but I think, this will be less
    problematic than Windows [usually].
    However my current assumption is:
    I totally have forgot the [limited] videocard memory.
    I suppose, Java3D tries to put all triangle data and all
    textures to the videocards memory, so most data processing
    then can be passed to it's graphiccard CPU using
    OpenGL commands.
    Now the flightsim produces a varying amount of (by_reference) triangle data ( a few thousands )
    and has some texture maps for the terrain, the sea and other things,
    plus indexed triangle data for the planes and ships.
    The notebook system, which slows down has an ATI Mobile Radeon card
    with only 32MB RAM onboard, whereas the others have 64MB Ram.
    An additional pointer to that theory is that I can trigger the slowdown by resizing
    the flightsim window, while it is running.
    On the notebook, it holds 30fps, until the window exceeds a size of 962*862 pixels.
    At this size the speed collapses and goes down to 1 frame update every 4 seconds.
    If I make the window a few pixels smaller, the speed of 30fps immediately
    is there again.
    Therefore I guess, some data passed to the graphic cards memory depends
    linearly from the canvas3d's window dimension, and at some limit,
    the graphiccard's memory is too small and Java3D changes it's strategy
    and performs most calculations on the computer's mainmemory,
    which of course is a lot slower.
    I'm not very sure about that, I'm just speculating.
    Next thing I will try is to disable directdraw for the other two applications,
    possibly swing also uses graphicscard memory, when directdraw is enabled.
    The solution seems to be clear anyway: The flightsim must examine the system
    and set some parameters depending on the machine's capabilities.
    Onboard videagraphic ram is one of them. If it's too slow, I start to decrease
    the window size and expect to see a sudden increase of speed, as soon as
    the rendering can be done by the graphicscard CPU. If this never happens,
    I assume no OpenGL accelerator is present on that system. This can be seen as a method
    for finding out the amount of videocard memory on a system by trial and error ..?:)
    Thanks for your tips, Alain.
    I especially have to check out the data sharing class in 1.5.

  • Painters (java.awt.Paint interface)

    Hello,
    I would like to implement a collection of painters (like GradientPaint, TexturePaint ..). Unfortunatelly, I found little information regarding this topic on the web. I found out that I need to implement the java.awt.Paint interface (and everything that it implies: PaintContext etc..). Do you know of any web site that might have some form of collection of this painters, or more complex information like algorithms for simple textures...Mabe I am asking the question wrong, that's why any links to basic resources that I can start with are welcome. I have allready taken a look at :
    http://swing-fx.blogspot.com/2008/05/glossy-and-shiny-shapes-with-paint-and.html
    http://drj11.wordpress.com/2007/04/02/subclassing-javaawtpaint/
    These helped me to understand the logic..but I feel left somwhere in the air with only this information.
    Any help is appreciated!
    Regards,
    Radu Cosmin

    Hello,
    I would like to implement a collection of painters (like GradientPaint, TexturePaint ..). Unfortunatelly, I found little information regarding this topic on the web. I found out that I need to implement the java.awt.Paint interface (and everything that it implies: PaintContext etc..). Do you know of any web site that might have some form of collection of this painters, or more complex information like algorithms for simple textures...Mabe I am asking the question wrong, that's why any links to basic resources that I can start with are welcome. I have allready taken a look at :
    http://swing-fx.blogspot.com/2008/05/glossy-and-shiny-shapes-with-paint-and.html
    http://drj11.wordpress.com/2007/04/02/subclassing-javaawtpaint/
    These helped me to understand the logic..but I feel left somwhere in the air with only this information.
    Any help is appreciated!
    Regards,
    Radu Cosmin

  • How to fill a JPanel with a texture from a image.

    Hello,
    I have a xxx.jpg file. I'd like to use this image to set the background texture of a JPanel.
    Can someone give me a piece of code to do that.
    Many thanks in advance
    Gege

    Since I haven't had no response, I have investigated more and finally solved my problem. Maybe it may help other people to have the answer.
    Here is the piece of code which works fine.
    import java.awt.*;
    import javax.swing.*;
    import java.awt.image.*;
    import javax.imageio.*; 
    public class TestTexture extends JPanel
        java.io.File filetexture    = new  java.io.File("mytexture.jpg");          
    public void paintComponent(Graphics g)
         super.paintComponent(g);
            Graphics2D g2 = (Graphics2D) g;
            if (g2==null)
                System.out.println("error");
                return;
            try
                 BufferedImage  mImage = ImageIO.read(filetexture);
                java.awt.geom.Rectangle2D tr = new   java.awt.geom.Rectangle2D.Double(0, 0, mImage.getWidth(), mImage.getHeight());
                TexturePaint tp = new TexturePaint(mImage, tr);
                     g2.setPaint(tp);
                    java.awt.geom.Rectangle2D  r =  (java.awt.geom.Rectangle2D)this.getBounds(); 
                     g2.fill(r);
       catch (java.io.IOException ex) {}
    }

  • Java using GUI's mixed with opengl... needs help...urgent....

    guys, i need help.... is anyone there have an idea about opengl...? ill attach 4 files that needs to be enhanced or debug for possible errors. to see the canvas... you should have atleast all the needed lib and jar of opengl in your pc.
    its urgent, its for our thesis actually....ill be dividing the codes with the use of (" **** ")sign...
    * Main.java
    * Created on 29 January 2007, 08:12
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package longgong;
    * @author welcome
    public class Main {
        /** Creates a new instance of Main */
        public Main() {
         * @param args the command line arguments
        public static void main(String[] args) {
            // TODO code application logic here
            frmMain f = new frmMain();
    * frmMain.java
    * Created on November 10, 2006, 10:52 AM
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package longgong; // create a floder named longgong and add the class inside
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.*;
    * @author all user
    public class frmMain extends JFrame implements ActionListener, ChangeListener, ItemListener{
        JPanel pnlWest, pnlEast, pnlCenter, pnlSouth, pnlTitle, pnlSlider, pnlPlayers;
        JSlider slrSpeed;
        JList lstResults;
        String varResults [] = new String[31];
        JLabel lblPlayers, lblTitle;
        JCheckBox lblPlayer1, lblPlayer2, lblPlayer3, lblPlayer4, lblPlayer5, lblPlayer6;
        ImageIcon imgDice1;
        MyCanvas canvas;
        JButton btnStart, btnStop;
        JMenuBar menuBar;
        JMenu menuFile, menuView, menuHelp;
        JMenuItem menuNew, menuExit, menuIn, menuOut, menuHigh, menuPlay, menuAbout;
        boolean isNew = false;
        /** Creates a new instance of frmMain */
        public frmMain() {
            setLayout(new BorderLayout());
            setTitle("Longgong");
            setSize(780,600);
            canvas = new MyCanvas(getSize().width, getSize().height);
            imgDice1 = new ImageIcon("c:\\java\\images\\one.png");
            menuBar = new JMenuBar();
            menuFile = new JMenu("File");
            menuView = new JMenu("View");
            menuHelp = new JMenu("Help");
            menuNew = new JMenuItem ("New Game");
            menuNew.addActionListener(this);
            menuExit = new JMenuItem ("Exit");
            menuExit.addActionListener(this);
            menuIn = new JMenuItem ("Zoom In");
            menuIn.addActionListener(this);
            menuOut = new JMenuItem ("Zoom Out");
            menuOut.addActionListener(this);
            menuHigh = new JMenuItem ("High Score");
            menuPlay = new JMenuItem ("How To Play");
            menuPlay.addActionListener(this);
            menuAbout = new JMenuItem ("About");
            menuAbout.addActionListener(this);
            menuFile.add(menuNew);
            menuFile.add(menuExit);
            menuView.add(menuIn);
            menuView.add(menuOut);
            menuView.add(menuHigh);
            menuHelp.add(menuPlay);
            menuHelp.add(menuAbout);
            menuBar.add(menuFile);
            menuBar.add(menuView);
            menuBar.add(menuHelp);
            setJMenuBar(menuBar);
            varResults[0] = "Dice Results";
            varResults[1] = "1. 3-4-2";
            varResults[2] = "2. 3-1-4";
            varResults[3] = "3. 3-6-5";
            slrSpeed = new JSlider(0, 100, 0);
            slrSpeed.setPaintTicks(true);
            slrSpeed.setMinorTickSpacing(1);
            slrSpeed.setPaintLabels(true);
            slrSpeed.setSnapToTicks(true);
            slrSpeed.addChangeListener(this);
            slrSpeed.setEnabled(false);
            btnStart =  new JButton("Start");
            btnStart.addActionListener(this);
            btnStop =  new JButton("Stop");
            btnStop.addActionListener(this);
            pnlWest = new JPanel();
            pnlEast = new JPanel();
            pnlCenter = new JPanel();
            pnlSouth = new JPanel();
            pnlTitle = new JPanel();
            pnlSlider = new JPanel();       
            pnlPlayers = new JPanel();
            pnlWest.setLayout(new BorderLayout());
            pnlEast.setLayout(new BorderLayout());
            pnlEast.setPreferredSize(new Dimension(100,400));
            pnlCenter.setLayout(new BorderLayout());
            pnlSouth.setLayout(new FlowLayout());
            pnlTitle.setLayout(new FlowLayout());
            pnlSlider.setLayout(new FlowLayout());       
            pnlPlayers.setLayout(new BoxLayout(pnlPlayers,BoxLayout.Y_AXIS));
            pnlPlayers.setPreferredSize(new Dimension(150,400));
            lblPlayers = new JLabel("  Players: Choice (s)");
            lblPlayer1 = new JCheckBox("None");
            lblPlayer1.addItemListener(this);
            lblPlayer2 = new JCheckBox("None");
            lblPlayer2.addItemListener(this);
            lblPlayer3 = new JCheckBox("None");
            lblPlayer3.addItemListener(this);
            lblPlayer4 = new JCheckBox("None");
            lblPlayer4.addItemListener(this);
            lblPlayer5 = new JCheckBox("None");
            lblPlayer5.addItemListener(this);
            lblPlayer6 = new JCheckBox("None");
            lblPlayer6.addItemListener(this);
            lstResults = new JList(varResults);
            pnlPlayers.add(lblPlayers);
            pnlPlayers.add(lblPlayer1);
            pnlPlayers.add(lblPlayer2);
            pnlPlayers.add(lblPlayer3);
            pnlPlayers.add(lblPlayer4);
            pnlPlayers.add(lblPlayer5);
            pnlPlayers.add(lblPlayer6);
            pnlSlider.add(slrSpeed);
            pnlSlider.add(btnStart);
            pnlSlider.add(btnStop);
            pnlEast.add(BorderLayout.CENTER, lstResults);
            pnlCenter.add(BorderLayout.SOUTH, pnlSlider);    
            pnlCenter.add(BorderLayout.CENTER, canvas);    
            lblTitle = new JLabel("LONGGONG DICE GAME SIMULATION");
            pnlTitle.add(lblTitle);
            getContentPane().add(BorderLayout.NORTH,pnlTitle);   
            getContentPane().add(BorderLayout.WEST,pnlPlayers);
            getContentPane().add(BorderLayout.EAST,pnlEast);
            getContentPane().add(BorderLayout.CENTER, pnlCenter);
            getContentPane().add(BorderLayout.SOUTH,pnlSouth);
            setResizable(false);
            canvas.start();
            show();       
        //name change when player is selected
        public void itemStateChanged(ItemEvent e) {
        Object source = e.getItemSelectable();
        int choice;
        if (source == lblPlayer1) {
            if (lblPlayer1.isSelected()) {
                frmChoices fchoices = new frmChoices(lblPlayer1);
        if (source == lblPlayer2) {
            if (lblPlayer2.isSelected()) {
                frmChoices fchoices = new frmChoices(lblPlayer2);
        if (source == lblPlayer3) {
            if (lblPlayer3.isSelected()) {
                frmChoices fchoices = new frmChoices(lblPlayer3);
        if (source == lblPlayer4) {
            if (lblPlayer4.isSelected()) {
                frmChoices fchoices = new frmChoices(lblPlayer4);
        if (source == lblPlayer5) {
            if (lblPlayer5.isSelected()) {
                frmChoices fchoices = new frmChoices(lblPlayer5);
        if (source == lblPlayer6) {
            if (lblPlayer6.isSelected()) {
                frmChoices fchoices = new frmChoices(lblPlayer6);
           // if (e.getStateChange() == ItemEvent.DESELECTED)
            //...make a note of it...
        //slider speed change
        public void stateChanged(ChangeEvent e){      
               canvas.speed(slrSpeed.getValue());
        public void actionPerformed (ActionEvent e){
            if (e.getActionCommand().equals ("Exit")){
                System.exit (0);     
            //connects to frmNew
            if (e.getActionCommand().equals ("New Game")){
                frmNew n = new frmNew(this);   
                lblPlayer1.setText("None");
                lblPlayer2.setText("None");
                lblPlayer3.setText("None");
                lblPlayer4.setText("None");
                lblPlayer5.setText("None");
                lblPlayer6.setText("None");
                isNew = true;
                lblPlayer1.setSelected(false);
                lblPlayer2.setSelected(false);
                lblPlayer3.setSelected(false);
                lblPlayer4.setSelected(false);
                lblPlayer5.setSelected(false);
                lblPlayer6.setSelected(false);
            if (e.getActionCommand().equals ("Start")){
               slrSpeed.setEnabled(true);
               canvas.setRandomDicePosition();
            if (e.getActionCommand().equals ("Stop")){
                slrSpeed.setValue(0);
                slrSpeed.setEnabled(false);
            //ADDED
             if (e.getActionCommand().equals ("New Game")){
               frmNew n = new frmNew(this);           
            if (e.getActionCommand().equals ("Zoom In")){
                canvas.zoomIn();          
            if (e.getActionCommand().equals ("Zoom Out")){
                canvas.zoomOut();          
            if (e.getActionCommand().equals ("How To Play")){
                frmPlay p = new frmPlay();           
            if (e.getActionCommand().equals ("About")){
                frmAbout a = new frmAbout();           
    package longgong;
    // Java  classes
       import java.awt.*;
       import java.awt.event.*;
       import java.net.URL;
    // GL4Java classes
       import gl4java.GLContext;
       import gl4java.awt.GLAnimCanvas;
       import gl4java.utils.textures.*;
       class MyCanvas extends GLAnimCanvas implements KeyListener, MouseListener
         // holds information on which keys are held down.
          boolean[] keys=new boolean[256];
          float     xrot;                    // X Rotation ( NEW )
          float     yrot;                    // Y Rotation ( NEW )
          float     zrot;                    // Z Rotation ( NEW )
          float[] diceRotX = new float[3];
          float[] diceRotY = new float[3];
          float[] diceRotZ = new float[3];
          float[] diceTranX = new float[3];
          float[] diceTranY = new float[3];
          float[] diceTranZ = new float[3];     
          float speedValue;
          Dice[] D;
          float zoom = -15.0f;
          public MyCanvas(int w, int h)
             super(w, h);
             //Registers this canvas to process keyboard events, and Mouse events
             addKeyListener(this);
             addMouseListener(this);  
             setAnimateFps(60); // seemed to be essential in getting any performance
             speedValue=0.0f;
             diceTranX[0] = -2.0f;
             diceTranY[0] = 2.0f;
             diceTranZ[0] = zoom;
             diceTranX[1] = 2.0f;
             diceTranY[1] = 1.0f;
             diceTranZ[1] = zoom;
             diceTranX[2] = 0.0f;
             diceTranY[2] = -2.0f;
             diceTranZ[2] = zoom;
          public void zoomIn(){
              zoom=zoom+1.0f;
           public void zoomOut(){
              zoom=zoom-1.0f;
          public void speed(float s){
            speedValue=s/100;
        /** void reshape(int width, int height) Called after the first paint command.  */  
          public void reshape(int width, int height)
             if(height==0)height=1;
             gl.glViewport(0, 0, width, height);                       // Reset The Current Viewport And Perspective Transformation
             gl.glMatrixMode(GL_PROJECTION);                           // Select The Projection Matrix
             gl.glLoadIdentity();                                      // Reset The Projection Matrix
             glu.gluPerspective(45.0f, width / height, 0.1f, 100.0f);  // Calculate The Aspect Ratio Of The Window
             gl.glMatrixMode(GL_MODELVIEW);                            // Select The Modelview Matrix
             gl.glLoadIdentity();                                      // Reset The ModalView Matrix     
       /** void preInit() Called just BEFORE the GL-Context is created. */  
          public void preInit()
          { doubleBuffer = true; stereoView = false; // buffering but not stereoview
          public void setRandomDicePosition(){
             for (int i=0; i<3; i++){
               D.setCoordinates(diceRotX[i],diceRotY[i],diceRotZ[i],diceTranX[i],diceTranY[i],diceTranZ[i]);
    D[i].getRandomDice();
    /** void init() Called just AFTER the GL-Context is created. */
    public void init()
    //float width = (float)getSize().width;
    //float height = (float)getSize().height;
    D = new Dice[5];
    D[0] = new Dice(this);
    D[1] = new Dice(this);
    D[2] = new Dice(this);
    //initialize dice location
    for (int i=0; i<3; i++){
    D[i].setCoordinates(diceRotX[i],diceRotY[i],diceRotZ[i],diceTranX[i],diceTranY[i],diceTranZ[i]);
    D[i].getRandomDice();
    gl.glEnable(GL_TEXTURE_2D);                              //Enable Texture Mapping ( NEW )
    gl.glShadeModel(GL_SMOOTH); //Enables Smooth Color Shading
    gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); //This Will Clear The Background Color To Black
    gl.glClearDepth(1.0); //Enables Clearing Of The Depth Buffer
    gl.glEnable(GL_DEPTH_TEST); //Enables Depth Testing
    gl.glDepthFunc(GL_LEQUAL); //The Type Of Depth Test To Do
    gl.glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); //Really Nice Perspective Calculations
    public void DrawBoundaries(){
    double x,y;
    double radius = 5.0f;
    gl.glLoadIdentity();                                             // Reset The View
    gl.glTranslatef(0.0f,0.0f,zoom-1.0f);
    gl.glRotatef(90.0f,0.0f,0.0f,1.0f);
    gl.glColor3f(0.6f,0.3f,0.3f);
    gl.glBegin(gl.GL_POLYGON);
    // angle is
    // x = radius * (cosine of angle)
    // y = radius * (sine of angle)
    for (double a=0; a<360; a++) {
    x = radius * (Math.cos(a));
    y = radius * (Math.sin(a));
    gl.glVertex3d(x, y, 0.0f);
    gl.glEnd();
    gl.glColor3f(1.0f,1.0f,1.0f);
    public void DrawGLScene()
    gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);     // Clear The Screen And The Depth Buffer
    DrawBoundaries();
    for (int i=0; i<3; i++){
    D[i].startDiceMovement();
    D[i].setTz(zoom);
    D[i].setSpeed(speedValue);
    D[i].drawDice();
    for (int i=0; i<3; i++){
    //start of loop
    if(i!=0){    
    if (D[0].getMoveLeft()==true){        
    if ( (D[0].getTx()>=D[i].getTx()-1.0f) && (D[0].getTx()<=D[i].getTx()) ){
    if (D[0].getMoveLeft()== true) D[0].setMoveLeft(false);
    else D[0].setMoveLeft(true);
    }else{
    if ( (D[0].getTx()-1<=D[i].getTx()) && (D[0].getTx()-1>=D[i].getTx()-1) ){
    if (D[0].getMoveLeft()== true) D[0].setMoveLeft(false);
    else D[0].setMoveLeft(true);
    if (D[0].getMoveUp()==true){        
    if ( (D[0].getTy()>=D[i].getTy()-1.0f) && (D[0].getTy()<=D[i].getTy()) ){
    if (D[0].getMoveUp()== true) D[0].setMoveUp(false);
    else D[0].setMoveUp(true);
    }else{
    if ( (D[0].getTy()-1<=D[i].getTy()) && (D[0].getTy()-1>=D[i].getTy()-1) ){
    if (D[0].getMoveUp()== true) D[0].setMoveUp(false);
    else D[0].setMoveUp(true);
    }//end of if i!=0
    if(i!=1){    
    if (D[1].getMoveLeft()==true){        
    if ( (D[1].getTx()>=D[i].getTx()-1.0f) && (D[1].getTx()<=D[i].getTx()) ){
    if (D[1].getMoveLeft()== true) D[1].setMoveLeft(false);
    else D[1].setMoveLeft(true);
    }else{
    if ( (D[1].getTx()-1<=D[i].getTx()) && (D[1].getTx()-1>=D[i].getTx()-1) ){
    if (D[1].getMoveLeft()== true) D[1].setMoveLeft(false);
    else D[1].setMoveLeft(true);
    if (D[1].getMoveUp()==true){        
    if ( (D[1].getTy()>=D[i].getTy()-1.0f) && (D[1].getTy()<=D[i].getTy()) ){
    if (D[1].getMoveUp()== true) D[1].setMoveUp(false);
    else D[1].setMoveUp(true);
    }else{
    if ( (D[1].getTy()-1<=D[i].getTy()) && (D[1].getTy()-1>=D[i].getTy()-1) ){
    if (D[1].getMoveUp()== true) D[1].setMoveUp(false);
    else D[1].setMoveUp(true);
    }//end of if i!=1
    if(i!=2){    
    if (D[2].getMoveLeft()==true){        
    if ( (D[2].getTx()>=D[i].getTx()-1.0f) && (D[2].getTx()<=D[i].getTx()) ){
    if (D[2].getMoveLeft()== true) D[2].setMoveLeft(false);
    else D[2].setMoveLeft(true);
    }else{
    if ( (D[2].getTx()-1<=D[i].getTx()) && (D[2].getTx()-1>=D[i].getTx()-1) ){
    if (D[2].getMoveLeft()== true) D[2].setMoveLeft(false);
    else D[2].setMoveLeft(true);
    if (D[2].getMoveUp()==true){        
    if ( (D[2].getTy()>=D[i].getTy()-1.0f) && (D[2].getTy()<=D[i].getTy()) ){
    if (D[2].getMoveUp()== true) D[2].setMoveUp(false);
    else D[2].setMoveUp(true);
    }else{
    if ( (D[2].getTy()-1<=D[i].getTy()) && (D[2].getTy()-1>=D[i].getTy()-1) ){
    if (D[2].getMoveUp()== true) D[2].setMoveUp(false);
    else D[2].setMoveUp(true);
    }//end of if i!=2
    //end of loop for i
    /** void display() Draw to the canvas. */
    // Purely a Java thing. Simple calls DrawGLScene once GL is Initialized
    public void display()
    for(int i=0;i<3;i++){
    glj.gljMakeCurrent(); //Ensure GL is initialised correctly
    DrawGLScene();
    glj.gljSwap(); //Swap buffers
    glj.gljFree(); // release GL
    // Key Listener events
    public void keyTyped(KeyEvent e){
    public void keyPressed(KeyEvent e){
    switch(e.getKeyCode())
    //Kill app
    case KeyEvent.VK_ESCAPE:
    System.exit(0);
    break;
    default :
    if(e.getKeyCode()<250) // only interested in first 250 key codes, are there more?
    keys[e.getKeyCode()]=true;     
    break;
    public void keyReleased(KeyEvent e){
    if(e.getKeyCode()<250) // only interested in first 250 key codes, are there more?
    keys[e.getKeyCode()]=false;
    // mouse listener events
    public void mouseEntered( MouseEvent evt )
    Component comp = evt.getComponent();
    if( comp.equals(this ) )
    //requestFocus();
    public void mouseExited( MouseEvent evt ){
    public void mousePressed( MouseEvent evt ){
    public void mouseReleased( MouseEvent evt ){
    public void mouseClicked( MouseEvent evt )
    Component comp = evt.getComponent();
    if( comp.equals(this ) )
    requestFocus();
    * Dice.java
    * Created on 08 February 2007, 22:26
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package longgong;
    import java.net.URL;
    import gl4java.GLContext;
    import gl4java.awt.GLAnimCanvas;
    import gl4java.utils.textures.*;
    * @author welcome
    public class Dice {
          GLAnimCanvas glCanvas ;
          URL codeBase;
          int[]texture1 = new int[1]; //Storage for one texture ( NEW )    
          int[]texture2 = new int[1]; //Storage for one texture ( NEW )    
          int[]texture3 = new int[1]; //Storage for one texture ( NEW )    
          int[]texture4 = new int[1]; //Storage for one texture ( NEW )    
          int[]texture5 = new int[1]; //Storage for one texture ( NEW )    
          int[]texture6 = new int[1]; //Storage for one texture ( NEW )    
          float rx;
          float ry;
          float rz;
          float tx;
          float ty;
          float tz;
          float speed;
          boolean txMoveLeft;
          boolean tyMoveUp;
          boolean tzMoveFront;
        /** Creates a new instance of Dice */
        public Dice(GLAnimCanvas g) {
            glCanvas = g;       
            if(!LoadGLTexture("c:\\java\\images\\one.png",texture1)){
                System.out.println("Failed to load Textures,Bailing!");
                System.exit(0);
            if(!LoadGLTexture("c:\\java\\images\\two.png",texture2)){
                System.out.println("Failed to load Textures,Bailing!");
                System.exit(0);
            if(!LoadGLTexture("c:\\java\\images\\three.png",texture3)){
                System.out.println("Failed to load Textures,Bailing!");
                System.exit(0);
            if(!LoadGLTexture("c:\\java\\images\\four.png",texture4)){
                System.out.println("Failed to load Textures,Bailing!");
                System.exit(0);
            if(!LoadGLTexture("c:\\java\\images\\five.png",texture5)){
                System.out.println("Failed to load Textures,Bailing!");
                System.exit(0);
            if(!LoadGLTexture("c:\\java\\images\\six.png",texture6)){
                System.out.println("Failed to load Textures,Bailing!");
                System.exit(0);
            txMoveLeft = true;
            tyMoveUp = true;
         public boolean inCircleBoundaries(float x, float y, float radius)
            float r;       
            r = (float)Math.sqrt((x*x) + (y*y));
            if (r <= radius)
                return  true;
            else
                return false;
        public void setCoordinates(float corRx,float corRy,float corRz,float corTx,float corTy,float corTz){
            rx = corRx;
            ry = corRy;
            rz = corRz;
            tx = corTx;
            ty = corTy;
            tz = corTz;
        public void getRandomDice(){
            int num = (int)(Math.random() * 6);
            if (num==1){
                rx=0.0f;
                ry=0.0f;
                rz=0.0f;
            else if (num==2){
                rx=90.0f;
                ry=0.0f;
                rz=0.0f;
            else if (num==3){
                rx=0.0f;
                ry=-90.0f;
                rz=0.0f;
            else if (num==4){
                rx=0.0f;
                ry=90.0f;
                rz=0.0f;
            else if (num==5){
                rx=-90.0f;
                ry=0.0f;
                rz=0.0f;
            else{
                rx=180.0f;
                ry=0.0f;
                rz=0.0f;
        public float getTx(){
            return tx+0.5f;
        public float getTy(){
            return ty+0.5f;
        public float getTz(){
            return tz+0.5f;
        public void setTz(float z){
            tz=z;
        public boolean getMoveLeft(){
            return txMoveLeft;
        public boolean getMoveUp(){
            return tyMoveUp;
        public void setMoveLeft(boolean m){
            txMoveLeft = m;
        public void setMoveUp(boolean m){
            tyMoveUp = m;
        public void startDiceMovement(){    
            if (txMoveLeft==true) {
                tx+=speed;           
            else {
                tx-=speed;
            if (tyMoveUp==true) {
                ty+=speed;
            else {
                ty-=speed;
            ry+=(speed*4);
            rx+=(speed*4);
            //rz+=(speed*2);
            //tx+=speed;
            //ty+=speed;
            //tz+=speed;             
         if (inCircleBoundaries(tx,ty,3.5f)==false) {  
            if (tx>=3.0f) txMoveLeft = false;
            if (tx<=-3.0f) txMoveLeft = true;
            if (ty>=3.0f) tyMoveUp = false;
            if (ty<=-3.0f) tyMoveUp = true;
        public void setSpeed(float s){
            speed = s;
         public void drawDice(){        
             glCanvas.gl.glLoadIdentity();                                             // Reset The View
             glCanvas.gl.glTranslatef(tx,ty,tz);
             glCanvas.gl.glRotatef(rx,1.0f,0.0f,0.0f);
             glCanvas.gl.glRotatef(ry,0.0f,1.0f,0.0f);
             glCanvas.gl.glRotatef(rz,0.0f,0.0f,1.0f);
             glCanvas.gl.glBindTexture(glCanvas.gl.GL_TEXTURE_2D, texture1[0]);        
             glCanvas.gl.glBegin(glCanvas.gl.GL_QUADS);        
                // Front Face
             glCanvas.gl.glTexCoord2f(0.0f, 0.0f); glCanvas.gl.glVertex3f(-1.0f, -1.0f,  1.0f);
             glCanvas.gl.glTexCoord2f(1.0f, 0.0f); glCanvas.gl.glVertex3f( 1.0f, -1.0f,  1.0f);
             glCanvas.gl.glTexCoord2f(1.0f, 1.0f); glCanvas.gl.glVertex3f( 1.0f,  1.0f,  1.0f);
             glCanvas.gl.glTexCoord2f(0.0f, 1.0f); glCanvas.gl.glVertex3f(-1.0f,  1.0f,  1.0f);
             glCanvas.gl.glEnd();
             glCanvas.gl.glBindTexture(glCanvas.gl.GL_TEXTURE_2D, texture6[0]);
             glCanvas.gl.glBegin(glCanvas.gl.GL_QUADS);        
               // Back Face          
             glCanvas.gl.glTexCoord2f(1.0f, 0.0f); glCanvas.gl.glVertex3f(-1.0f, -1.0f, -1.0f);
             glCanvas.gl.glTexCoord2f(1.0f, 1.0f); glCanvas.gl.glVertex3f(-1.0f,  1.0f, -1.0f);
             glCanvas.gl.glTexCoord2f(0.0f, 1.0f); glCanvas.gl.glVertex3f( 1.0f,  1.0f, -1.0f);
             glCanvas.gl.glTexCoord2f(0.0f, 0.0f); glCanvas.gl.glVertex3f( 1.0f, -1.0f, -1.0f);
             glCanvas.gl.glEnd();
             glCanvas.gl.glBindTexture(glCanvas.gl.GL_TEXTURE_2D, texture2[0]);
             glCanvas.gl.glBegin(glCanvas.gl.GL_QUADS);        
                // Top Face
             glCanvas.gl.glTexCoord2f(0.0f, 1.0f); glCanvas.gl.glVertex3f(-1.0f,  1.0f, -1.0f);
             glCanvas.gl.glTexCoord2f(0.0f, 0.0f); glCanvas.gl.glVertex3f(-1.0f,  1.0f,  1.0f);
             glCanvas.gl.glTexCoord2f(1.0f, 0.0f); glCanvas.gl.glVertex3f( 1.0f,  1.0f,  1.0f);
             glCanvas.gl.glTexCoord2f(1.0f, 1.0f); glCanvas.gl.glVertex3f( 1.0f,  1.0f, -1.0f);
             glCanvas.gl.glEnd();
             glCanvas.gl.glBindTexture(glCanvas.gl.GL_TEXTURE_2D, texture5[0]);
             glCanvas.gl.glBegin(glCanvas.gl.GL_QUADS);        
                // Bottom Face
             glCanvas.gl.glTexCoord2f(1.0f, 1.0f); glCanvas.gl.glVertex3f(-1.0f, -1.0f, -1.0f);
             glCanvas.gl.glTexCoord2f(0.0f, 1.0f); glCanvas.gl.glVertex3f( 1.0f, -1.0f, -1.0f);
             glCanvas.gl.glTexCoord2f(0.0f, 0.0f); glCanvas.gl.glVertex3f( 1.0f, -1.0f,  1.0f);
             glCanvas.gl.glTexCoord2f(1.0f, 0.0f); glCanvas.gl.glVertex3f(-1.0f, -1.0f,  1.0f);
             glCanvas.gl.glEnd();
             glCanvas.gl.glBindTexture(glCanvas.gl.GL_TEXTURE_2D, texture3[0]);
             glCanvas.gl.glBegin(glCanvas.gl.GL_QUADS);        
                // Right face
             glCanvas.gl.glTexCoord2f(1.0f, 0.0f); glCanvas.gl.glVertex3f( 1.0f, -1.0f, -1.0f);
             glCanvas.gl.glTexCoord2f(1.0f, 1.0f); glCanvas.gl.glVertex3f( 1.0f,  1.0f, -1.0f);
             glCanvas.gl.glTexCoord2f(0.0f, 1.0f); glCanvas.gl.glVertex3f( 1.0f,  1.0f,  1.0f);
             glCanvas.gl.glTexCoord2f(0.0f, 0.0f); glCanvas.gl.glVertex3f( 1.0f, -1.0f,  1.0f);
             glCanvas.gl.glEnd();
             glCanvas.gl.glBindTexture(glCanvas.gl.GL_TEXTURE_2D, texture4[0]);
             glCanvas.gl.glBegin(glCanvas.gl.GL_QUADS);        
                // Left Face
             glCanvas.gl.glTexCoord2f(0.0f, 0.0f); glCanvas.gl.glVertex3f(-1.0f, -1.0f, -1.0f);
             glCanvas.gl.glTexCoord2f(1.0f, 0.0f); glCanvas.gl.glVertex3f(-1.0f, -1.0f,  1.0f);
             glCanvas.gl.glTexCoord2f(1.0f, 1.0f); glCanvas.gl.glVertex3f(-1.0f,  1.0f,  1.0f);
             glCanvas.gl.glTexCoord2f(0.0f, 1.0f); glCanvas.gl.glVertex3f(-1.0f,  1.0f, -1.0f);
             glCanvas.gl.glEnd();
          public boolean LoadGLTexture(String fileName, int textureNumber[])
             PngTextureLoader texLoader = new PngTextureLoader(glCanvas.gl, glCanvas.glu);
             if(codeBase!=null)  
                texLoader.readTexture(codeBase, fileName);
             else
                texLoader.readTexture(fileName);
             if(texLoader.isOk())
                //Create Texture
                glCanvas.gl.glGenTextures(1, textureNumber);
                glCanvas.gl.glBindTexture(glCanvas.gl.GL_TEXTURE_2D, textureNumber[0]);
                glCanvas.gl.glTexParameteri(glCanvas.gl.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        

    ill attach 4 files that needs to be
    enhanced or debug for possible errors. i hate to break it to you, but even if you post this for the seventh time, finding and fixing errors in your code remains your task.

  • Calling a method from another Java file.

    I think I'm doing this right, but I'm obviously going wrong somewhere.
    In order to not have one big long java file, I've created one main one to execute the program, and another to do some of the functions. I'm using eclipse, btw.
    In the main file, I have
    currentTB = getActiveTB(playerArea);If it works, it should get send the player area variable to the getActiveTB method, and store the value it returns in the currentTB variable, right?
    In the other file, I have;
    package scenes;
    public class sceneIndex {
         private TerrainBlock getActiveTB(String areaCode) {
              TerrainBlock tBlock = new TerrainBlock();
                     **DOES STUFF**
              return tBlock;
    }I have it set up so the second file is in the source folder "resources" and the package "scenes." The problem is I'm not calling it properly. I'm missing something simple, I think. The only error I'm getting is;
    The method getActiveTB(String) is undefined...
    Where am I screwing up?
    EDIT: Yeah, I'm a rookie here trying to figure it out on my own. My computer science courses, so far, conveniently all consist of just one big java file. Easier to write, sure, but not very efficient/organized.
    Message was edited by:
    SuckerPunch

    Yeah, so this is still pissing me off. I'm not sure what else to do. I've tried this a million different ways, in both eclipse and netbeans. Whatever. Here's the code, I'd love it if someone could point out the boneheaded mistake I'm making. I'm getting a little frustrated at being stuck on such a simple problem.
    Main.javaimport com.jme.app.BaseGame;
    import com.jme.input.KeyBindingManager;
    import com.jme.input.KeyInput;
    import com.jme.math.Vector3f;
    import com.jme.renderer.Camera;
    import com.jme.renderer.ColorRGBA;
    import com.jme.scene.Node;
    import com.jme.system.DisplaySystem;
    import com.jme.system.JmeException;
    import com.jme.util.Timer;
    import com.jmex.terrain.TerrainBlock;
    import resources.*;
    public class Main extends BaseGame {
         /* General Variable Declaration */
         private String scene;   // Tells application which scene to load, default loads default scene
         private int width, height, depth, freq; // Creates variables to store information
         private boolean fullscreen;             // on the user's window
         private Camera playerCam; // Defines the main camera for the player, first person view
         private Timer timer; // Creates a timer to be used for FPS calculations
         private Node currentScene; // The basis for building the scene the player is in
         private TerrainBlock currentTB; // This variable holds the current landscape
         private String playerArea = new String("initial"); // Contains the string
                                                                        // code for the scene
                                                                        // the player is in,
                                                                        // defaults to the opening scene, unless changed by
                                                                        // the player loading their game
            public static void main(String[] args) {
              /* Initializes and Starts the Applications. */
              Main app = new Main();
              app.setDialogBehaviour(ALWAYS_SHOW_PROPS_DIALOG, Main.class.getClassLoader().getResource("img/spunch.jpg"));
              app.start();
         protected void update(float interpolation) {
         protected void render(float interpolation) {
         protected void initSystem() {
               * Application initialization properties (window, camera, renderer, key
               * bindings, etc)
              // Stores variables for window properties
              width = properties.getWidth();
              height = properties.getHeight();
              depth = properties.getDepth();
              freq = properties.getFreq();
              fullscreen = properties.getFullscreen();
              // Assigns renderer and creates game window
              try {
                   display = DisplaySystem.getDisplaySystem(properties.getRenderer());
                   display.createWindow(width, height, depth, freq, fullscreen);
                   playerCam = display.getRenderer().createCamera(width, height);
              } catch (JmeException e) {
                   e.printStackTrace();
                   System.exit(1);
              // Sets background to black, should never be seen anyway
              display.getRenderer().setBackgroundColor(ColorRGBA.black);
              // Initializes the camera
              playerCam.setFrustumPerspective(45.0f, (float) width / (float) height,
                        1, 1000);
              Vector3f loc = new Vector3f(250.0f, 100.0f, 250.0f);
              Vector3f left = new Vector3f(-0.5f, 0.0f, 0.5f);
              Vector3f up = new Vector3f(0.0f, 1.0f, 0.0f);
              Vector3f dir = new Vector3f(-0.5f, 0.0f, -0.5f);
              // Moves and orients the camera
              playerCam.setFrame(loc, left, up, dir);
              // Update the camera since it has been changed
              playerCam.update();
              // Create a timer for FPS updates
              timer = Timer.getTimer();
              // Assign the camera as the primary display in the application
              display.getRenderer().setCamera(playerCam);
              // Initialize the escape key as a way to exit the program
              KeyBindingManager.getKeyBindingManager().set("exit",
                        KeyInput.KEY_ESCAPE);
         protected void initGame() {
              /* Game initialization */
              display.setTitle("Slumlords"); // Displays title in window
                    SceneIndex sIndex = new SceneIndex();
              currentTB = sIndex.getActiveTB(playerArea);
              currentScene.attachChild(currentTB);
              currentScene.updateGeometricState(0.0f, true);
              currentScene.updateRenderState();
         protected void reinit() {
         protected void cleanup() {
    }SceneIndex.javapackage resources;
    import javax.swing.ImageIcon;
    import com.jme.bounding.BoundingBox;
    import com.jme.image.Texture;
    import com.jme.math.Vector3f;
    import com.jme.scene.state.TextureState;
    import com.jme.system.DisplaySystem;
    import com.jme.util.TextureManager;
    import com.jmex.terrain.TerrainBlock;
    import com.jmex.terrain.util.MidPointHeightMap;
    import com.jmex.terrain.util.ProceduralTextureGenerator;
    public class SceneIndex {
         private DisplaySystem display;
         public TerrainBlock getActiveTB(String areaCode) {
              TerrainBlock tBlock = new TerrainBlock();
              if (areaCode == "initial") {
                   // Generates random terrain data
                   MidPointHeightMap heightMap = new MidPointHeightMap (64, 1.0f);
                   // Scale the data
                   Vector3f terrainScale = new Vector3f(4, 0.0575f, 4);
                   // Create the terrain block
                   tBlock = new TerrainBlock("Terrain", heightMap.getSize(), terrainScale, heightMap.getHeightMap(), new Vector3f(0, 0, 0), false);
                   tBlock.setModelBound(new BoundingBox());
                   tBlock.updateModelBound();
                   // Creating a blended texture based on the height map
                   ProceduralTextureGenerator pTexture = new ProceduralTextureGenerator(heightMap);
                   pTexture.addTexture(new ImageIcon(SceneIndex.class.getClassLoader().getResource("img/grass.gif")), -128, 0, 128);
                   pTexture.addTexture(new ImageIcon(SceneIndex.class.getClassLoader().getResource("img/dirt.jpg")), 0, 128, 255);
                   pTexture.addTexture(new ImageIcon(SceneIndex.class.getClassLoader().getResource("img/granite.jpg")), 128, 255, 384);
                   pTexture.createTexture(64);
                   // Assigning the texture to the terrain
                   TextureState tState = display.getRenderer().createTextureState();
                   Texture t1 = TextureManager.loadTexture(pTexture.getImageIcon().getImage(), Texture.MM_LINEAR_LINEAR, Texture.FM_LINEAR, true);
                   tState.setTexture(t1, 0);
                   tBlock.setRenderState(tState);
              return tBlock;
    }Again, I've tried this a few different ways, and I either get a "Could Not Find Symbol" error referring to the getActiveTB(playerArea); in Main, or it just says java.lang.NoClassDefFoundError: and Exception in thread "main".
    Whatever.

  • ART + TECH - ART VS. TECH (+ the relationship to java, coding, + vision)

    Not that this is a new struggle, here's my perspective anyway.
    I have posted this discussion as it's own topic because I thought it deserved it's own heading and title. The original was written in a response in my heart and mind to the current state of geekdom.com.
    I am not a tech by birth. I am becoming a tech out of necessity. I cannot afford 3000 programs to develop what I see. I also cannot stand to let what I see coming go undone by myself. I just reliquished a partnership with a tech friend who was working with me on my new company. He had no time to even answer emails. I am now out here in codeworld trying to create everything from scratch.
    As a visual artist, "codeworld" is not very familiar, and most of the characters inhabiting this world hate the visual world, and "see" it as unimportant. (Thoughts and interior worlds being much more valuable and relevant).
    I know that there are 2,000 languages and options to accomplish this task (see earlier posts---java Html proccessor/templator templater???). Some are pricey, some are labor intensive, some like Java seem to be so complicated that I cannot begin to think of doing this all on my own. I wanted to accomplish this originally by February, and with all the components that I need to get working, I am afraid it could be Feb. of 2005, by the time I get my vision into the real world. (of course by then, what I see will be outdated and obsolete)
    Yes, the problem here is money and time....Ha ha....like none of us have not heard that one before. I was told elsewhere today that Macromedia has all the tools I need in a package, and so I looked up the cost. I aint there yet!!!! (is it really that good---macromedia-generator????--------comments please from anyone)
    The HTML generator---templator is just one of the pieces of a large pie that I see, as a desktop/ work system. I know that Java can do it. I have seen the incredible visual tools that it can generate. I am frustrated however in that to make visual tools-----I have to deal with a totally left brained -----code based (scientific)-system----that is anti creative---anti----free radical!!!!
    I see a delivered final system for the regular JOE BLOW, that will let him deal with "pretty pictures" as a user interface. The systems I "SEE" will allow CAVE MEN to get what they want. No creature should have to go to school to use a damn program============ever!!!!!!!!!!!!!!!!!!
    After all these years of development, can't we be a little further along in delivering to the "public" a truly user friendly system?????
    In the next decade programmers and geeks will become extinct, because they insisted on their 15 milliseconds of fame and fortune. The artist, and intellectuals are coming, and will take over. All we need, all that the public needs, is a "SYSTEM" that makes sense-----real world sense--------not code sense.
    If you think I am angry.................well yes I AM....I am tired of techs that cannot take 1 minute to answer email.
    Yes, I am your free radical, Yes I am "not of your world" (techworld that is)
    Yes, you are all too busy.
    Yes, you all are in high demand at your 35.00 to 125.00 an hour rates.
    Enjoy it while you can,,,,,,,,,,,,,,it aint gonna last, your market is eroding as we talk mention it.
    Smart guys don't just grow up here out of American soil, they grow up in India, in Rumania, in the Phillipines, anywhere.............
    Because of the wonderful invention that only you were smart enough to make======the internet,,,,,,,,,,,,,you are now screwed....................
    Your tech buddie in Korea only needs 12.00 per hour instead of your 125.00 per hour..............
    I would not care about any of this if I did not see a product that needs to get to market. I forsee a product invented (with whatever tech/code/language) that will make AOL look scientific and complicated.
    I am waiting for someone who can stand code, but who can dream, and think --------------WAY BEYOND code. Yes, money is an issue, but if the product can get to market--------------------neither one of us will ever have to worry again.
    PS...........you may think I am crazy, I do not care. You know that 60 foot TV screen in NYC on the front of the NASDAC---CNB=== NBC building, I saw that.
    I saw that in 1979. (only the technological application of it that I saw, cannot be built yet, it will take 10 years of holographic tech to actualize that "vision").
    Has anyone ever "seen" what the desktop will look like in the year 2008?
    I have.
    Join me.
    PSS. I am not lazy. I do however want to continue on with my visual computer dreams.............I know there is a lot more. I need some techs to help make these dreams come true. YES, I have now contradicted myself. I am famous for that. I DO NOT HATE TECHS. I am just tired of tech excuses, and tech attitudes.
    If all of you have no time, well then fine. I will DO IT MYSELF.
    me

    Starbase,
    You've commented on how unfriendly user interfaces are, and on how the techies don't seem to pay any attention to artistst and intellectuals.
    On the first point, I think if you look objectively at what someone who doesn't know anything about computers can do now, vs. what an "expert" could do 20 years ago, you have to admit that the advances are astounding.
    My wife, my mother, my brother, all non-techies can compose nice looking documents, send email, search the web for any information they want, without having to know a whole lot of bizarre arcane tech-talk.
    Granted, there is a lot of software that has a poor UI, but things are improving, and the harder to use stuff generally (not always) gets pushed out by its frienlier cousins.
    Also, you have to realize that while doing certain tasks can be made easy (click here to get email, click there to send new email, etc.), to perform more complex, powerful, flexible operations, you will absolutely have to understand something about the technology you're using.
    Anybody can be taught the sequence of keys to press on a piano to create the melody of "Twinkle, Twinkle." However, if you don't understand something about how notes fit together to make chords, how notes, chords rhythm, etc. make a song, how the keys, hammers, dampers, strings, and pedals in a piano combine to produce sounds, then you're not going to be able to use a piano to its fullest capacity. Does that mean that a piano has a poor user interface?
    Anybody can dip a brush into a blob of paint and draw a smiley face, but an understanding of how colors combine, of water vs. oil, of different textures of brush and canvas, etc., etc....
    And finally, on this point, let me add that you need to be a little more patient. There are a lot of things that have to come together to produce a revolutionary user interface, or even one with significant incremental improvements.
    First, hardware has to be fast enough, cheap enough and ubiquitous enough. Take the 5 software packages that you think have the best interfaces and try to run them on, say, a 386. Not pretty I imagine. The 386 is how old? 5 years? 8 years? Ancient history in the computer world, but not that long for real technical revolutions.
    The simple fact is that slicker, cleaner, more powerful, yet friendlier UIs require a lot more horsepower (including CPU, memory, video, etc.) to run than a simple text driven menu system. A box with dual 1Ghz P4s and 1GB of memory and a top of the line video card could handle a more robust UI than what's on the average user's desktop today, but who's going to invest the time and money in building that UI when only a handful of people have the hardware necessary to run it.
    And hardware is just one piece of the puzzle. Again, given what is asked of a UI--that it's job is to present a front end as close to human nature as possible and convert that to something the underlying hardware can use--the simpler you want it to be for you, the more complex and sophisticated it's got to be behind the scenes. That kind of complex and sophisticated software is difficult at best and impossible at worst without certain software development techniques, tools, and practices. Those are also coming into their own along with the rest of the tehcnical evolution (no "r").
    And what about standards and convention? If software A is easy to use, and software B is easy to use, but they operate in completely different, proprietary ways, even for tasks that the two have in common, that's not going to seem all that easy to the artist who tries to use both. Getting all parties involved to agree on a common way of doing things is not a trivial task, especially now that there's an established way that works and that a lot of people are at least moderately comfortable with.
    Okay, I've rambled enough about that. I'll just ramble a little bit more about the second point--us techies not soliciting the opinions of the artists--and then I'll shutup.
    Are you aware that many (most?) companies that produce software do have artistic folks on staff whose job is make sure the interfaces make sense? I think Apple Computer has had a significant staff in that area since the introduction of the Macintosh. My own company has a creative department who is responsible for the overall look and feel and flow of our software. And in fact, at every job I've had, among the programmers I've worked with, there's always been at least one or two folks who had an artisitic or intellectual bent as well. Believe me, there are a lot of people involved in the production of software who are not just bit-shuffling coders.
    Finally, no matter how pretty the front end is, it's behavior needs to be precisely defined. That is, an almost mathematical description of "state x, input y leads to state w, behavior z, output q". It's my humble and unscientific opinion that a lot gets lost in the translation from the artist's vision to the bit-shuffler's spec. The spec is absolutely necessary--without it you'll get software that' wrong and/or unpredictable. However, the non-bit-shufflers of the world often don't want to be involved in the precise statment of behavior, and the bit shufflers don't have the patience or ability to extract and understand the precise spec from the artist's pretty pictures. I honestly think that the difficulty in communicating from vision to hard dry spec is a huge blockade on the path to getting software that does what somebody wanted in the way they wanted it done.
    I do agree with your basic premise that it would be a good thing if computers in general were simpler and more intuitive to use. However, I don't agree with your evaluation of how bleak things are right now, how little progress is being made, or how little input the artist/intellectual/"common man" has in the process right now.
    Whew. I'm bushed. Online or not, discussions like this should not take place without a good beer/wine/scotch/martini on hand. :-)

  • Creating a texture for a rounded window

    Hi.
    I'm creating a simple gui on a game framework based on lwjgl and I have a problem.
    Almost every window has a solid black texture as a background. I came up with a idea to make corners rounded. At the beginning I created gif picture of a rounded square and used it as a background texture. But it wasn't a good idea, because the corners had different sizes depends on windows sizes (and how much texture was stretched). I've decided that I have to create a texture dynamically every time a window is created.
    public void makeBackground() {
            // the texture size must be multiply of 2
            int tWidth = 2;
            while (tWidth < getWidth()) {
                tWidth *= 2;
            int tHeight = 2;
            while (tHeight < getHeight()) {
                tHeight *= 2;
            Texture t = new Texture(getWidth(), getHeight()); // new texture is created with width and height same as the window size
            int px, py, ox, oy; // some variables
            final int pw = getWidth(),  ph = getHeight(),  hww = tWidth; // as above
            ByteBuffer bb = t.getData(); // blank texture is converted to a byte buffer
            Utils.startStoper(); // start timer (for a benchmark)
            try {
                for (int p = 0;; p++) {
                    px = p % hww; // get the X of the pixel
                    py = p / hww; // get the Y of the pixel
                    ox = ROUND_ANGLE - Math.min(px + 1, pw - px + 1); //  ox = <0, 32> if near corners
                    oy = ROUND_ANGLE - Math.min(py + 1, ph - py + 1); //  as above
                    bb.put((byte) 0); // r = 0
                    bb.put((byte) 0); // g = 0
                    bb.put((byte) 0); // b = 0
                    if (ox > 0 && oy > 0) {  // if near corners
                        double hypot = Math.hypot(ox, oy);
                        if (hypot > ROUND_ANGLE) { // if outside the corner
                            bb.put((byte) 0); // apha = 0
                        } else if (hypot > ROUND_ANGLE - 1) { // if on the corner edge
                            bb.put((byte) Math.round(
                                    (ROUND_ANGLE - hypot) * 200));
                        } else {
                            bb.put((byte) 200);  // if inside the corner (200 is a max value cause the whole window is a bit transparent)
                    } else {
                        bb.put((byte) 200); // inside the window
            } catch (BufferOverflowException ex) {
            Utils.stopStoper();  // stop timer
            t.setData(bb);   // set data for a texture
            super.setImage(t);  // set texture as a background
        }And here we have a problem. The whole method takes about 70ms for a window 200x200.
    I can do it in another way: create a pictures of a rounded corner and a black box. The box would be the window inside and the corner would loaded 4 times each time rotated. Only the box would be stretched then. But I would have to override all methods of a window (setX, setY, setXY, some more).
    Any ideas?
    Thanks.
    Edited by: tom_ex on 2009-02-17 16:58

    Hi Tom,
    I haven't used lwjgl, so hope the following helps:
    1- What does it matter if it takes 70ms. Your windows will be created once. At that point juste create the texture for that window and store it until you destroy the window. The penalty hit is 70ms but only at the initialization.
    2- You are drawing a pixel at a time for everything. Why don't you calculate the area of the corners and only draw the corners a pixel at a time. For the rest, draw some filled polygons.
    3- The java Graphics object has method fill methode that can take any Shape object. Why don't you use that?
    I would use a combination of 3 and 1.
    Hope that helps.
    Ekram
    Edited by: ekram_rashid on Feb 18, 2009 2:21 PM

Maybe you are looking for

  • Macbook Pro 13-inch, mid 2009. Heat Issues

    Hi! What can i do? I have a macbook pro 13" from 2009. The fans are always on 1999 RPM, they never go faster, not even when the computer reaches a temperature of 80° Celcius. As soon as I go to youtube to watch a video, the temperature goes up alot,

  • Displaying iPad on TV using Apple TV

    I have bought an Apple TV and wish to display my Mini iPad on my TV. I understand I have to select Airplay in Control Centre to do this but there is no Airplay button showing in my Control Centre.   I have iOS 7 installed on my iPad.  How do I get Ai

  • PSE 7 Editor Not Working

    My editor is not working.   When I try to open, window comes up inside editor screen and says "Adobe Photoshop Editor has Stopped Working"   This has never happened and the organizer is still working.   Help someone!!!

  • Error on installing Shared Technologies while installing PS11

    Am getting "error while installing Shared Technologies.."  while installing PS 11.  I uninstalled the antivirus but got the same error message.  Does anybody know how this can be fixed or what I should do now?  Thank you so much..

  • Dashboard Display Error

    Hi Gurus, I getting error while accessing sub dashboard.I have Dashboard Name as Sales and i have sub dashboard underneath Sales says S1,S2,S3 and each sub dashboards has dashboard pages respectively.So when i select S1 sub dashboard it throws me err