Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (522)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (590)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1] 2
1  Java Game APIs & Engines / JOGL Development / Compiling JOGL source on: 2004-11-30 13:29:22
I am trying to compile the jogl source code.
I have included all ant and antlr lib in the class path but still a couple of objects can not be resolved:
--GnuCLexer
--GnuCParser
--GNUCTokenTypes
--HeaderParser constructor is not visible.. etc..
Is this sun.net.www.HeaderParser? It does not seem so.
Could any one point what is missing here?
Any hint is deeply appreciated.
Thanks
2  Java Game APIs & Engines / JOGL Development / Re: JOGL crashes on: 2004-11-09 14:15:03

.....
# Java VM: Java HotSpot(TM) Client VM (1.5.0-beta2-b51 mixed mode, sharing)
# Problematic frame:
# C  0x00000ef1
#
# An error report file with more information is saved as hs_err_pid6823.log
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
#


Some times my application  crashes with a smilar out put as above.
I dont know what the problem is.


3  Java Game APIs & Engines / JOGL Development / JOGJ and CAD file on: 2004-10-29 15:40:15
I have been experimenting with jogl for quite some time.
I have a viewer application for drawing and displaying pirimitives and some complex drawings.
I know there some data formats that some jogl application can read and display the figures.
I am just curious if there is a way to display a cad drawing in my jogl viewer? Any idea or advice are very wellcome.
4  Java Game APIs & Engines / JOGL Development / Resizing GLCanvas in JSplitPane on: 2004-10-26 17:57:58
I have a JSplitPane which has a JPanel containing canvas in the center and a vertical nevigation bar in east.
When JPanel has not canvas JSplitPane resizes but in the case canvas is in the center, no way to resize it.
Any idea?
5  Java Game APIs & Engines / JOGL Development / Re: calling repaint of GLCanvas->Performance pr on: 2004-06-09 16:17:37
Lesson 5 modified for rotation(left) and zooming(right)based on mouse events. Animator is commented out.



/*
* Lesson05.java
*
* Created on July 15, 2003, 11:30 AM
*/

import java.awt.*;
import java.awt.event.*;

import net.java.games.jogl.*;
import net.java.games.jogl.util.*;


public class Lesson05 {


 /** Program's main entry point
  * @param args command line arguments.
  */
 public static void main(String[] args) {
   Frame frame = new Frame("Lesson 5: 3D Shapes");
   GLCanvas canvas = GLDrawableFactory.getFactory().createGLCanvas(new
       GLCapabilities());
   canvas.setGL(new DebugGL(canvas.getGL()));
   L_5_Renderer r = new L_5_Renderer();
   canvas.addGLEventListener(r);
   canvas.addKeyListener(r);
   canvas.addMouseMotionListener(r);
   canvas.addMouseListener(r);

   frame.add(canvas);
   frame.setSize(640, 480);
   //animator = new Animator(canvas);
   frame.addWindowListener(new WindowAdapter() {
     public void windowClosing(WindowEvent e) {
       //animator.stop();
       System.exit(0);
     }
   });
   frame.show();
   //animator.start();
   canvas.requestFocus();
 }
}


class L_5_Renderer
  implements GLEventListener,
  KeyListener, MouseMotionListener, MouseListener {

GL gl;
GLU glu;
private float rquadX = 0.0f;
private float rtriX = 0.0f;
private float rquadY = 0.0f;
private float rtriY = 0.0f;
private float rquadZ = 0.0f;
private float transZ =-6.0f;
private int buttonType=-1;

public void display(GLDrawable gLDrawable) {
  gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
  gl.glLoadIdentity();

  gl.glTranslatef(0.0f, 0.0f, transZ);

  gl.glRotatef(rquadX, 0.0f, 1.0f, 0.0f);
  gl.glRotatef(rquadY, 1.0f, 0.0f, 0.0f);
  gl.glRotatef(rquadZ, 0.0f, 0.0f, 1.0f);
  //Rotate end....

  gl.glBegin(GL.GL_QUADS); // Draw A Quad
  gl.glColor3f(0.0f, 1.0f, 0.0f); // Set The Color To Green
  gl.glVertex3f(1.0f, 1.0f, -1.0f); // Top Right Of The Quad (Top)
  gl.glVertex3f( -1.0f, 1.0f, -1.0f); // Top Left Of The Quad (Top)
  gl.glVertex3f( -1.0f, 1.0f, 1.0f); // Bottom Left Of The Quad (Top)
  gl.glVertex3f(1.0f, 1.0f, 1.0f); // Bottom Right Of The Quad (Top)

  gl.glColor3f(1.0f, 0.5f, 0.0f); // Set The Color To Orange
  gl.glVertex3f(1.0f, -1.0f, 1.0f); // Top Right Of The Quad (Bottom)
  gl.glVertex3f( -1.0f, -1.0f, 1.0f); // Top Left Of The Quad (Bottom)
  gl.glVertex3f( -1.0f, -1.0f, -1.0f); // Bottom Left Of The Quad (Bottom)
  gl.glVertex3f(1.0f, -1.0f, -1.0f); // Bottom Right Of The Quad (Bottom)

  gl.glColor3f(1.0f, 0.0f, 0.0f); // Set The Color To Red
  gl.glVertex3f(1.0f, 1.0f, 1.0f); // Top Right Of The Quad (Front)
  gl.glVertex3f( -1.0f, 1.0f, 1.0f); // Top Left Of The Quad (Front)
  gl.glVertex3f( -1.0f, -1.0f, 1.0f); // Bottom Left Of The Quad (Front)
  gl.glVertex3f(1.0f, -1.0f, 1.0f); // Bottom Right Of The Quad (Front)

  gl.glColor3f(1.0f, 1.0f, 0.0f); // Set The Color To Yellow
  gl.glVertex3f(1.0f, -1.0f, -1.0f); // Bottom Left Of The Quad (Back)
  gl.glVertex3f( -1.0f, -1.0f, -1.0f); // Bottom Right Of The Quad (Back)
  gl.glVertex3f( -1.0f, 1.0f, -1.0f); // Top Right Of The Quad (Back)
  gl.glVertex3f(1.0f, 1.0f, -1.0f); // Top Left Of The Quad (Back)

  gl.glColor3f(0.0f, 0.0f, 1.0f); // Set The Color To Blue
  gl.glVertex3f( -1.0f, 1.0f, 1.0f); // Top Right Of The Quad (Left)
  gl.glVertex3f( -1.0f, 1.0f, -1.0f); // Top Left Of The Quad (Left)
  gl.glVertex3f( -1.0f, -1.0f, -1.0f); // Bottom Left Of The Quad (Left)
  gl.glVertex3f( -1.0f, -1.0f, 1.0f); // Bottom Right Of The Quad (Left)

  gl.glColor3f(1.0f, 0.0f, 1.0f); // Set The Color To Violet
  gl.glVertex3f(1.0f, 1.0f, -1.0f); // Top Right Of The Quad (Right)
  gl.glVertex3f(1.0f, 1.0f, 1.0f); // Top Left Of The Quad (Right)
  gl.glVertex3f(1.0f, -1.0f, 1.0f); // Bottom Left Of The Quad (Right)
  gl.glVertex3f(1.0f, -1.0f, -1.0f); // Bottom Right Of The Quad (Right)
  gl.glEnd(); // Done Drawing The Quad
  gl.glFlush();

}

public void displayChanged(GLDrawable gLDrawable, boolean modeChanged,
                           boolean deviceChanged) {
}

public void init(GLDrawable gLDrawable) {

  gl = gLDrawable.getGL();
  glu = gLDrawable.getGLU();

  gl.glShadeModel(GL.GL_SMOOTH); // Enable Smooth Shading
  gl.glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background
  gl.glClearDepth(1.0f); // Depth Buffer Setup
  gl.glEnable(GL.GL_DEPTH_TEST); // Enables Depth Testing
  gl.glDepthFunc(GL.GL_LEQUAL); // The Type Of Depth Testing To Do
  gl.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST); // Really Nice Perspective Calculations
}

public void reshape(GLDrawable gLDrawable, int x, int y, int width,
                    int height) {
  if (height <= 0) { // avoid a divide by zero error!
    height = 1;
  }
  final float h = (float) width / (float) height;
  gl.glViewport(0, 0, width, height);
  gl.glMatrixMode(GL.GL_PROJECTION);
  gl.glLoadIdentity();
  glu.gluPerspective(45.0f, h, 1.0, 20.0);
  gl.glMatrixMode(GL.GL_MODELVIEW);
  gl.glLoadIdentity();
}

public void keyPressed(KeyEvent e) {
  if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
    System.exit(0);
  }
}

public void keyReleased(KeyEvent e) {}

public void keyTyped(KeyEvent e) {}

private int prevMouseX, prevMouseY;
private boolean mouseRButtonDown = false;

public void mouseDragged(MouseEvent e) {
  int x = e.getX();
  int y = e.getY();

  Dimension size = e.getComponent().getSize();
  GLCanvas canvas = (GLCanvas) e.getSource();
  canvas.repaint();
  System.out.println("buttonType " + buttonType);

  float thetaX = 360.0f * (float) (x - prevMouseX) / (float) size.width;
  float thetaY = 360.0f * (float) ( -prevMouseY + y) / (float) size.height;

  if(buttonType==1)
  {
    rquadX += thetaX;
    rtriX += thetaX;
    rquadY += thetaY;
    rtriY += thetaY;
  }
  if(buttonType==3)
  {
    transZ +=(float) ( -prevMouseY + y)/100;
  }

  prevMouseX = x;
  prevMouseY = y;
}

public void mouseMoved(MouseEvent e) {
}

// Methods required for the implementation of MouseListener
public void mouseEntered(MouseEvent e) {}

public void mouseExited(MouseEvent e) {}

public void mousePressed(MouseEvent e) {
  buttonType=e.getButton();
  prevMouseX = e.getX();
  prevMouseY = e.getY();
  if ( (e.getModifiers() & e.BUTTON3_MASK) != 0) {
    mouseRButtonDown = true;
  }
}

public void mouseReleased(MouseEvent e) {
  if ( (e.getModifiers() & e.BUTTON3_MASK) != 0) {
    mouseRButtonDown = false;
  }
}

public void mouseClicked(MouseEvent e) {}

}

6  Java Game APIs & Engines / JOGL Development / Re: calling repaint of GLCanvas->Performance pr on: 2004-06-09 12:11:15
If you are running animator, there is no need for repaint or display for the canvas. If your project is rendering huge number of objects as in a molecular viewer, animator turns to killer, sucking up all cpu.What is better depends on type of your project, by the way repaint or display are tricky issues since jogl is not thread safe.
7  Java Game APIs & Engines / JOGL Development / Re: Picking an object with the mouse on: 2004-06-08 19:35:07
Search for 'PickObject' Not 'pick'.
8  Java Game APIs & Engines / JOGL Development / Re: Picking an object with the mouse on: 2004-06-08 19:30:57
Search the forum with "pick", there are sample codes.
9  Java Game APIs & Engines / JOGL Development / Re: No NURBS support in JoGL??? on: 2004-05-14 13:26:41
No nurbs in jogl.
10  Java Game APIs & Engines / JOGL Development / Re: gl.glRasterPos2f arguments on: 2004-05-11 12:17:26
Thanks for hints.
It seems some work there.
11  Java Game APIs & Engines / JOGL Development / gl.glRasterPos2f arguments on: 2004-05-10 19:42:24
All I want to do is to display an image on the canvas where the user mouse presses. I try  gl.glRasterPos2f(..)  and glut.glutBitmapString(...) but It seems x and y coordinates provided by mouse press are not proper arguments and they should be converted to view-port reference system. What is the best way to do this?
Any idea is appreciated.
Thanks...
12  Java Game APIs & Engines / JOGL Development / Re: picking in JOGL 1.1 b02 on: 2004-04-26 12:30:12
0.. Number of names.
1.. & 2.. max & min z-coordiates intersected by viewing volume.
4.. Name.
13  Java Game APIs & Engines / JOGL Development / Re: OpenGL Commands outside of Display on: 2004-04-05 20:04:27
It is getting late..
You can not reflect the changes instantly, well I assume you make changes through mouse events, since event thread is running before that of rendering when triggered by glcanvas repaint. It seems Jogl is not safe, when it deals with events especially when rendering big volumes of objects.
14  Java Game APIs & Engines / JOGL Development / Re: How To Draw arc on: 2004-04-05 18:02:40
Thanks for response.
That is right, by some math I draw it, but
I just wanted to check if any jogl method was available. By the way, I could not find NURBS in any jogl library. Huh

15  Java Game APIs & Engines / JOGL Development / How To Draw arc on: 2004-04-05 12:29:50
Hi,
I need to draw an arc from one point to an other.
There are some methods to draw curves in OpenGl Guide but not available in jogl. What do I need to draw a curved line form point A to B?

Thanks..
16  Java Game APIs & Engines / JOGL Development / Re: Picking in the volume?? on: 2004-03-19 19:28:16
Hamareno,
Was the number of hits a non-zero value while you were gettting all zero for the data int[] buffer? This was happening once in a while or a continious thing? It seems It depends on the rendering load. With smaller number of objects rendered, I does not happen.I am very careful on this thread issue but still once out of 10 press my program returns data int[] buffer with all zero despite the hit is correct, a non-zero number.
Thanks..
17  Java Game APIs & Engines / JOGL Development / Picking Depth Values on: 2004-03-12 15:19:53
Hi There,

First,
Any idea regarding how to get this code working with model-dialog is deeply appreciated.

Second,
OpenGL Programming Guide, plainly tells that window-coordinate max and min Z-Values of all vertices of the primitives intersected in viewing volume are given in the int[] buffer.
In the sample the cube is beyond the sphere, but the z-values of sphere are (absolute value) greater than those of the cube. I think closer object to window screen should have smaller z-values (absolute value).
Since the sphere is closer it is supposed to have smaller z-values(absolute value). It seems it is not the case in sample.

Thanks..
/////////////////////////////////////////////
I modified sample code posted here before.

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import net.java.games.jogl.*;
import net.java.games.jogl.util.*;
public class JoglTest
   implements GLEventListener, MouseListener, MouseMotionListener, KeyListener {
 static private Frame frame;
 //static private Animator animator;
 static private GLCanvas canvas;
 private float prevMouseX, prevMouseY;
 private float mouseX, mouseY;
 private float transX = 0f, transY = 0f, transZ = -4.0f;
 private boolean picked;
 private int pickedName;
 private float view_rotX_1 = 0.0f, view_rotY_1 = 0.0f, view_rotZ = 0.0f;
 private float view_rotX_2 = 0.0f, view_rotY_2 = 0.0f;
 private final int test = 1;
 private float fAspect;
 float lambr = 0.0f;
 float lambg = 0.0f;
 float lambb = 0.0f;
 float ldifr = 1.0f;
 float ldifg = 1.0f;
 float ldifb = 1.0f;
 float lsper = 1.0f;
 float lspeg = 1.0f;
 float lspeb = 1.0f;
 float lposx = 0.8f;
 float lposy = 0.8f;
 float lposz = 0.8f;
 float light_ambient[] = {lambr, lambg, lambb, 1.0f};
 float light_diffuse[] = {ldifr, ldifg, ldifb, 1.0f};
 float light_specular[] = {lsper, lspeg, lspeb, 1.0f};
 float light_position[] = {lposx, lposy, lposz};
 float global_ambient[] = {0.75f, 0.75f, 0.75f, 1.0f};
 float mambr = 0.25f;
 float mambg = 0.2f;
 float mambb = 0.074f;
 float mdifr = 0.57f;
 float mdifg = 0.14f;
 float mdifb = 0.17f;
 float msper = 0.8f;
 float mspeg = 0.65f;
 float mspeb = 0.25f;
 float ambient[] = {mambr, mambg, mambb, 1.0f};
 float diffuse[] = {mdifr, mdifg, mdifb, 1.0f};
 float specular[] = {msper, mspeg, mspeb, 1.0f};
 float shininess = 20.0f;
 JDialog d = new JDialog();

 private JoglTest() {
   System.out.println("JoglTest instance created");
   // Canvas setup
   GLCapabilities caps = new GLCapabilities();
   caps.setDoubleBuffered(true);
   caps.setAlphaBits(Cool;
   caps.setStencilBits(Cool;
   canvas = GLDrawableFactory.getFactory().createGLCanvas(caps);
   canvas.addGLEventListener(this);
   canvas.setGL(new DebugGL(canvas.getGL()));
   canvas.addMouseListener(this);
   canvas.addMouseMotionListener(this);
   canvas.addKeyListener(this);
   // Frame setup
   frame = new Frame("Vectrix");
   frame.add(canvas);
   frame.setSize(800, 600);
   d.setUndecorated(true);
   frame.addWindowListener(new WindowAdapter() {
     public void windowClosing(WindowEvent e) {
       System.exit(0);
     }
   });
 }

 public static void main(String[] args) {
   System.out.println("Vectrix starting...");
   JoglTest app = new JoglTest();
   //show frame
   frame.show();
 }

 // GL Event Listener methods
 // Called when GL has been initialised for the first time.
 public void init(GLDrawable drawable) {
   GL gl = drawable.getGL();
   // light properties
   gl.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, light_ambient);
   gl.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, light_diffuse);
   gl.glLightfv(GL.GL_LIGHT0, GL.GL_SPECULAR, light_specular);
   gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, light_position);
   gl.glLightModelfv(GL.GL_LIGHT_MODEL_AMBIENT, global_ambient);
   // material properties
   gl.glMaterialfv(GL.GL_FRONT, GL.GL_AMBIENT, ambient);
   gl.glMaterialfv(GL.GL_FRONT, GL.GL_DIFFUSE, diffuse);
   gl.glMaterialfv(GL.GL_FRONT, GL.GL_SPECULAR, specular);
   gl.glMaterialf(GL.GL_FRONT, GL.GL_SHININESS, shininess);
   // various OpenGL states
   gl.glFrontFace(GL.GL_CW);
   gl.glEnable(GL.GL_LIGHTING);
   gl.glEnable(GL.GL_LIGHT0);
   gl.glEnable(GL.GL_AUTO_NORMAL);
   gl.glEnable(GL.GL_NORMALIZE);
   gl.glDepthFunc(GL.GL_LESS);
   gl.glEnable(GL.GL_DEPTH_TEST);
   gl.glMatrixMode(GL.GL_PROJECTION);
   gl.glLoadIdentity();
   gl.glMatrixMode(GL.GL_TEXTURE);
   gl.glLoadIdentity();
   gl.glMatrixMode(GL.GL_MODELVIEW);
   gl.glLoadIdentity();
 }

 public void display(GLDrawable drawable) {

   if (picked) {
     processSelection(drawable, mouseX, mouseY);
   }else
   {draw(drawable);}
 }

 public void draw(GLDrawable drawable) {
   GL gl = drawable.getGL();
   GLU glu = drawable.getGLU();
   GLUT glut = new GLUT();

   gl.glClearColor(0.2f, 0.2f, 0.2f, 0.0f);
   gl.glClear(
       GL.GL_COLOR_BUFFER_BIT
       | GL.GL_DEPTH_BUFFER_BIT
       | GL.GL_STENCIL_BUFFER_BIT);
   float ambient[] = {0.0f, 0.7f, 0.9f, 1.0f};
   gl.glMaterialfv(GL.GL_FRONT, GL.GL_AMBIENT, ambient);
   gl.glInitNames();
   gl.glPushName(0);
   gl.glPushMatrix();
   gl.glTranslatef(transX - 0.5f, transY, transZ);
   gl.glRotatef(view_rotX_1, 1.0f, 0.0f, 0.0f);
   gl.glRotatef(view_rotY_1, 0.0f, 1.0f, 0.0f);
   gl.glRotatef(view_rotZ, 0.0f, 0.0f, 1.0f);
   gl.glLoadName(1);
   glut.glutWireSphere(glu, 0.5, 100, 100);
   gl.glPopMatrix();

   float ambient_1[] = {0.9f, 0.7f, 0.0f, 1.0f};
   gl.glMaterialfv(GL.GL_FRONT, GL.GL_AMBIENT, ambient_1);
   gl.glPushMatrix();
   gl.glTranslatef(transX, transY, -6);
   gl.glRotatef(view_rotX_2, 1.0f, 0.0f, 0.0f);
   gl.glRotatef(view_rotY_2, 0.0f, 1.0f, 0.0f);
   gl.glRotatef(view_rotZ, 0.0f, 0.0f, 1.0f);
   gl.glLoadName(2);
   glut.glutSolidCube(gl, 1.1f);
   gl.glPopMatrix();

   gl.glFlush();
 }

 public void reshape(
     GLDrawable drawable,
     int x,
     int y,
     int width,
     int height) {
   GL gl = drawable.getGL();
   GLU glu = drawable.getGLU();
   fAspect = (float) width / (float) height;
   gl.glMatrixMode(GL.GL_PROJECTION);
   gl.glLoadIdentity();
   glu.gluPerspective(30.0, (float) width / (float) height, 1.0, 50);
   gl.glMatrixMode(GL.GL_MODELVIEW);
   gl.glLoadIdentity();
 }

 public void displayChanged(GLDrawable arg0, boolean arg1, boolean arg2) {
 }

 public void processSelection(GLDrawable drawable, float x, float y) {
   GL gl = drawable.getGL();
   GLU glu = drawable.getGLU();
   int[] selectBuff = new int[64];
   int hits = 0;
   int[] viewport = new int[4];

   gl.glSelectBuffer(64, selectBuff);
   gl.glGetIntegerv(GL.GL_VIEWPORT, viewport);
   gl.glMatrixMode(GL.GL_PROJECTION);
   gl.glPushMatrix();

   gl.glRenderMode(GL.GL_SELECT);
   gl.glLoadIdentity();
   glu.gluPickMatrix(x, viewport[3] - y, 50, 50, viewport);
   glu.gluPerspective(30.0f, fAspect, 1.0, 50);
   draw(drawable);
   hits = gl.glRenderMode(GL.GL_RENDER);
   if (hits > 0) {
     System.out.println("hits " + hits);
     int count = selectBuff[0];
     pickedName = selectBuff[3];
     d = new JDialog();
     //d.setModal(true);
     d.setUndecorated(true);
     d.getContentPane().setLayout(new BorderLayout());
     d.setSize(new Dimension(100, 100));
     d.setLocation( (int) x, (int) y);
     JPanel p = new JPanel(new GridLayout(hits * 4, 1));
     for (int i = 0; i < hits * 4; i++) {
       String name = String.valueOf(selectBuff);
       JLabel l = new JLabel(String.valueOf(name));
       p.add(l);
     }
     d.getContentPane().add(p, BorderLayout.CENTER);
     d.setVisible(true);
   }
   else {
     System.out.println("no hit");
     pickedName = 0;
     d.dispose();
   }
   gl.glMatrixMode(GL.GL_PROJECTION);
   gl.glPopMatrix();
   gl.glMatrixMode(GL.GL_MODELVIEW);
   picked = false;
 }

 public void processKey(KeyEvent event) {
   int key = event.getKeyCode();
   if (event.isControlDown() && key == KeyEvent.VK_DOWN) {
     transY -= 0.1f;
   }
   else if (event.isControlDown() && key == KeyEvent.VK_UP) {
     transY += 0.1f;
   }
   else if (key == KeyEvent.VK_DOWN) {
     transZ += 0.1f;
   }
   else if (key == KeyEvent.VK_UP) {
     transZ -= 0.1f;
   }
   else if (key == KeyEvent.VK_LEFT) {
     transX -= 0.1f;
   }
   else if (key == KeyEvent.VK_RIGHT) {
     transX += 0.1f;
   }
 }

 public void mouseEntered(MouseEvent e) {
 }

 public void mouseExited(MouseEvent e) {
 }

 public void mousePressed(MouseEvent e) {
   if (d.isVisible()) {
     d.dispose();
   }
   prevMouseX = e.getX();
   prevMouseY = e.getY();
   mouseX = e.getX();
   mouseY = e.getY();
   picked = true;
 }

 public void mouseReleased(MouseEvent e) {
   canvas.repaint();
 }
 public void mouseClicked(MouseEvent e) {
 }

 public void mouseDragged(MouseEvent e) {
   int x = e.getX();
   int y = e.getY();
   Dimension size = e.getComponent().getSize();
   float thetaY = 360.0f * (float) (x - prevMouseX) / (float) size.width;
   float thetaX = 360.0f * (float) (prevMouseY - y) / (float) size.height;
   prevMouseX = x;
   prevMouseY = y;
   switch (pickedName) {
     case 1:
       view_rotX_1 += thetaX;
       view_rotY_1 += thetaY;
       break;
     case 2:
       view_rotX_2 += thetaX;
       view_rotY_2 += thetaY;
       break;
   }
   canvas.repaint();
 }
 public void mouseMoved(MouseEvent e) {
 }

 public void keyPressed(KeyEvent e) {
   processKey(e);
 }
 public void keyReleased(KeyEvent e) {
 }
 public void keyTyped(KeyEvent e) {
 }
}
18  Java Game APIs & Engines / JOGL Development / Re: net.java.games.jogl.GLException: Surface alrea on: 2004-03-10 15:24:17
That is right,
It is a risk to handle a modal dialog.
On the other hand I have to update the data through the canvas screen and right after update new screen and new configuration must be displayed.
What would you suggest instead of a modal dialog?
I would deeply appreciate any hint..
Thanks.
19  Java Game APIs & Engines / JOGL Development / Re: net.java.games.jogl.GLException: Surface alrea on: 2004-03-08 13:27:29
Thanks, ShadowCaster.
Repaint is triggered in mouse events right before process of picking. I commented the dialog, and just tracing the picking process.
It seems the problem starts with picking. It works fine except the int[] buffer is empty, it is all zero. I create gl,glu all in display.
In short, objects are picked but no information is retrieved.
I will post a small code summarizing the situation.
Thanks.
20  Java Game APIs & Engines / JOGL Development / Re: net.java.games.jogl.GLException: Surface alrea on: 2004-03-05 20:41:05
Some times, Number of picked object is nonzero, in other words It is picking but the buffer int[] buff is empty in "gl.glSelectBuffer(pickedObjectNumber, buff);".
Every thing is created and run in display.
Waht I do is not a radikal solution but It might help to uderstand waht is going on. If the buffer is empty when objects are picked, I force the process repeat until the buffer is filled and no more error..
Why is it picking objects but not filling the int[] buff some times(approximately once out of 20)?

Huh?
21  Java Game APIs & Engines / JOGL Development / net.java.games.jogl.GLException: Surface already u on: 2004-03-05 19:17:08
Hi there..
All I do is to display a JDialog in canvas.repaint() initiated by mouse release. Once out of 20 mouse press I get this error, otherwise every thing is perfect.
It seems again an unsynch thread issue, but this getting out of control in a GUI application that is strongly dependent on mouse events like mine. Setting rendering event to current event is not even an option since more than 5000 objects rendered.
Any body has any idea to get rid of this "Surface already unlocked" error message?
Any hint is deeply appreciated.

Thanks.




Exception occurred during event dispatching:

net.java.games.jogl.GLException: Surface already unlocked

     at net.java.games.jogl.impl.windows.WindowsOnscreenGLContext.unlockSurface(WindowsOnscreenGLContext.java:192)

     at net.java.games.jogl.impl.windows.WindowsOnscreenGLContext.free(WindowsOnscreenGLContext.java:134)

     at net.java.games.jogl.impl.GLContext.invokeGL(GLContext.java:265)

     at net.java.games.jogl.GLCanvas.displayImpl(GLCanvas.java:182)

     at net.java.games.jogl.GLCanvas.display(GLCanvas.java:82)

     at net.java.games.jogl.GLCanvas.paint(GLCanvas.java:89)

     at net.java.games.jogl.GLCanvas.update(GLCanvas.java:116)

     at sun.awt.RepaintArea.paint(RepaintArea.java:169)

     at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:260)

     at java.awt.Component.dispatchEventImpl(Component.java:3678)

     at java.awt.Component.dispatchEvent(Component.java:3477)

     at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)

     at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)

     at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)

     at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:141)

     at java.awt.Dialog$1.run(Dialog.java:540)

     at java.awt.Dialog.show(Dialog.java:561)

     at java.awt.Component.show(Component.java:1133)

     at java.awt.Component.setVisible(Component.java:1088)

     at com.certusoft.openfoldviewer.Renderer.processSelection(Renderer.java:491)

     at com.certusoft.openfoldviewer.Renderer.display(Renderer.java:151)

     at net.java.games.jogl.impl.GLDrawableHelper.display(GLDrawableHelper.java:74)

     at net.java.games.jogl.GLCanvas$DisplayAction.run(GLCanvas.java:194)

     at net.java.games.jogl.impl.GLContext.invokeGL(GLContext.java:235)

     at net.java.games.jogl.GLCanvas.displayImpl(GLCanvas.java:182)

     at net.java.games.jogl.GLCanvas.display(GLCanvas.java:82)

     at net.java.games.jogl.GLCanvas.paint(GLCanvas.java:89)

     at net.java.games.jogl.GLCanvas.update(GLCanvas.java:116)

     at sun.awt.RepaintArea.paint(RepaintArea.java:169)

     at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:260)

     at java.awt.Component.dispatchEventImpl(Component.java:3678)

     at java.awt.Component.dispatchEvent(Component.java:3477)

     at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)

     at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)

     at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)

     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)

     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)

     at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
22  Java Game APIs & Engines / JOGL Development / Re: Picking in the volume?? on: 2004-03-04 15:09:54
Thanks for response.
Every thing is fine, I dont know why the first rendered oject is not picked.
I think some thing is wrong with my program.
Thanks.
23  Java Game APIs & Engines / JOGL Development / Picking in the volume?? on: 2004-03-02 15:38:26
Hi there,
I have five identical objects and picking works fine when they are visible on the screen plane (no overlapping) or even partially overlapping. After rotating some and get them overlapped so that only the one nearest to the observer is visible, all others are hidden behind it. Why is nothing picked when it is clicked in the center or with in the object's boundary?
Is not it supposed to pick all in a certain volume defined by "glu.gluPickMatrix..." ? It picks only the one nearest when clicked nearby within the boundary defined again by "glu.gluPickMatrix...". Can any body tell me what is going on??
Thanks..
24  Java Game APIs & Engines / JOGL Development / Re: JOGL on a single thread on: 2004-02-27 13:33:39
It seems ok, debug version is on, removed timer, action listener, added mouse events and direct calls to gl from events and no more "java.lang OutOfMemeory".
Basically you set glRendering thread to that of events.
I was trying the opposite. Thanks.
25  Java Game APIs & Engines / JOGL Development / Re: canvas.setGL(new DebugGL(canvas.getGL())); on: 2004-02-27 12:27:59
Thanks,
I need to experiment some..
26  Java Game APIs & Engines / JOGL Development / Re: mousemotionlistener doesn't work right on: 2004-02-26 13:33:37
I had the same trouble.
If you are drawing too many objects, animator sucks all cpu up, then it gets slower.
I got rid of animator.
That is what I do in MouseMotionListener shortly;

"
 public void mouseDragged(MouseEvent e) {
   int x = e.getX();
   int y = e.getY();
   Dimension size = e.getComponent().getSize();
   String className = e.getSource().getClass().getName();
   if (className.compareTo("net.java.games.jogl.GLCanvas") == 0) {
     if (mouseAction == 1) {
       float thetaX = 360.0f * (float) (x - prevMouseX) / (float) size.width;
       float thetaY = 360.0f * (float) ( -prevMouseY + y) /
           (float) size.height;
       prevMouseX = x;
       prevMouseY = y;

         rotateX += thetaX;
         rotateY += thetaY;
        canvas.repaint();
   }
"
or, you can repaint in mouse Released.

regards.
27  Java Game APIs & Engines / JOGL Development / Re: canvas.setGL(new DebugGL(canvas.getGL())); on: 2004-02-26 13:16:52
Thanks for the hints.
User Guide is no doubt great help, I thing some details must be emphasised with more plain English.
It seems the more plausible way is to get the threads syncronized between rendering and awt events.  Please let me know I you get it works.

An other issue,
   int[] pickBuff = new int[count];
   gl.glSelectBuffer(count, pickBuff );

I get nonzero hits, but pickBuff is emty some times, one out of ten presses.
I thing mouse release thread is a little bit late.

Any idea??


Thanks.
28  Java Game APIs & Engines / JOGL Development / Re: canvas.setGL(new DebugGL(canvas.getGL())); on: 2004-02-24 13:57:11
Thanks, Andy.
It seems, calling opengl from events is a big "no".
That is right, instead of playing with debugger in and out, the best is to go the way without making any call from events.
29  Java Game APIs & Engines / JOGL Development / Re: java.lang.OutOfMemoryError on: 2004-02-24 11:19:51
Thanks.
30  Java Game APIs & Engines / JOGL Development / java.lang.OutOfMemoryError on: 2004-02-23 19:04:35
Ok,
Let me ask my question with a code sample.
This is Lesson 5, and I modified it for the mouse events.
It works fine except I do two things together:

1. Add (line 13) "canvas.setGL(new DebugGL(canvas.getGL()));"
2. Add (line 154) "gl.glInitNames();"

then get "java.lang.OutOfMemoryError", actually not crashing but freezes for a considerable time.

Any hint is deeply appreciated.
Thanks.






----------------------------------------------------------------
import java.awt.*;
import java.awt.event.*;
import net.java.games.jogl.*;
import net.java.games.jogl.util.*;

public class Lesson05 {

 public static void main(String[] args) {
   Frame frame = new Frame("Lesson 5: 3D Shapes");
   GLCanvas canvas = GLDrawableFactory.getFactory().createGLCanvas(new
       GLCapabilities());
   canvas.setGL(new DebugGL(canvas.getGL()));
   L_5_Renderer r = new L_5_Renderer();
   canvas.addGLEventListener(r);
   canvas.addKeyListener(r);
   canvas.addMouseMotionListener(r);
   canvas.addMouseListener(r);
   frame.add(canvas);
   frame.setSize(640, 480);
   frame.addWindowListener(new WindowAdapter() {
     public void windowClosing(WindowEvent e) {
       System.exit(0);
     }
   });
   frame.show();
   canvas.requestFocus();
 }

 static class L_5_Renderer
     implements GLEventListener,
     KeyListener, MouseMotionListener, MouseListener {
   GL gl;
   GLU glu;
   private float rquadX = 0.0f;
   private float rtriX = 0.0f;
   private float rquadY = 0.0f;
   private float rtriY = 0.0f;
   private float rquadZ = 0.0f;

   public void init(GLDrawable gLDrawable) {

     gl = gLDrawable.getGL();
     glu = gLDrawable.getGLU();

     gl.glShadeModel(GL.GL_SMOOTH); // Enable Smooth Shading
     gl.glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background
     gl.glClearDepth(1.0f); // Depth Buffer Setup
     gl.glEnable(GL.GL_DEPTH_TEST); // Enables Depth Testing
     gl.glDepthFunc(GL.GL_LEQUAL); // The Type Of Depth Testing To Do
     gl.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST); // Really Nice Perspective Calculations
   }

   public void reshape(GLDrawable gLDrawable, int x, int y, int width,
                       int height) {
     if (height <= 0) { // avoid a divide by zero error!
       height = 1;
     }
     final float h = (float) width / (float) height;
     gl.glViewport(0, 0, width, height);
     gl.glMatrixMode(GL.GL_PROJECTION);
     gl.glLoadIdentity();
     glu.gluPerspective(45.0f, h, 1.0, 20.0);
     gl.glMatrixMode(GL.GL_MODELVIEW);
     gl.glLoadIdentity();
   }

   public void display(GLDrawable gLDrawable) {
     gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
     gl.glLoadIdentity();
     gl.glTranslatef(0.0f, 0.0f, -6.0f);
     gl.glRotatef(rquadX, 0.0f, 1.0f, 0.0f);
     gl.glRotatef(rquadY, 1.0f, 0.0f, 0.0f);
     gl.glRotatef(rquadZ, 0.0f, 0.0f, 1.0f);
     //Rotate end....
     gl.glBegin(GL.GL_QUADS); // Draw A Quad
     gl.glColor3f(0.0f, 1.0f, 0.0f); // Set The Color To Green
     gl.glVertex3f(1.0f, 1.0f, -1.0f); // Top Right Of The Quad (Top)
     gl.glVertex3f( -1.0f, 1.0f, -1.0f); // Top Left Of The Quad (Top)
     gl.glVertex3f( -1.0f, 1.0f, 1.0f); // Bottom Left Of The Quad (Top)
     gl.glVertex3f(1.0f, 1.0f, 1.0f); // Bottom Right Of The Quad (Top)
     gl.glColor3f(1.0f, 0.5f, 0.0f); // Set The Color To Orange
     gl.glVertex3f(1.0f, -1.0f, 1.0f); // Top Right Of The Quad (Bottom)
     gl.glVertex3f( -1.0f, -1.0f, 1.0f); // Top Left Of The Quad (Bottom)
     gl.glVertex3f( -1.0f, -1.0f, -1.0f); // Bottom Left Of The Quad (Bottom)
     gl.glVertex3f(1.0f, -1.0f, -1.0f); // Bottom Right Of The Quad (Bottom)
     gl.glColor3f(1.0f, 0.0f, 0.0f); // Set The Color To Red
     gl.glVertex3f(1.0f, 1.0f, 1.0f); // Top Right Of The Quad (Front)
     gl.glVertex3f( -1.0f, 1.0f, 1.0f); // Top Left Of The Quad (Front)
     gl.glVertex3f( -1.0f, -1.0f, 1.0f); // Bottom Left Of The Quad (Front)
     gl.glVertex3f(1.0f, -1.0f, 1.0f); // Bottom Right Of The Quad (Front)
     gl.glColor3f(1.0f, 1.0f, 0.0f); // Set The Color To Yellow
     gl.glVertex3f(1.0f, -1.0f, -1.0f); // Bottom Left Of The Quad (Back)
     gl.glVertex3f( -1.0f, -1.0f, -1.0f); // Bottom Right Of The Quad (Back)
     gl.glVertex3f( -1.0f, 1.0f, -1.0f); // Top Right Of The Quad (Back)
     gl.glVertex3f(1.0f, 1.0f, -1.0f); // Top Left Of The Quad (Back)
     gl.glColor3f(0.0f, 0.0f, 1.0f); // Set The Color To Blue
     gl.glVertex3f( -1.0f, 1.0f, 1.0f); // Top Right Of The Quad (Left)
     gl.glVertex3f( -1.0f, 1.0f, -1.0f); // Top Left Of The Quad (Left)
     gl.glVertex3f( -1.0f, -1.0f, -1.0f); // Bottom Left Of The Quad (Left)
     gl.glVertex3f( -1.0f, -1.0f, 1.0f); // Bottom Right Of The Quad (Left)
     gl.glColor3f(1.0f, 0.0f, 1.0f); // Set The Color To Violet
     gl.glVertex3f(1.0f, 1.0f, -1.0f); // Top Right Of The Quad (Right)
     gl.glVertex3f(1.0f, 1.0f, 1.0f); // Top Left Of The Quad (Right)
     gl.glVertex3f(1.0f, -1.0f, 1.0f); // Bottom Left Of The Quad (Right)
     gl.glVertex3f(1.0f, -1.0f, -1.0f); // Bottom Right Of The Quad (Right)
     gl.glEnd(); // Done Drawing The Quad
     gl.glFlush();
   }

   public void displayChanged(GLDrawable gLDrawable, boolean modeChanged,
                              boolean deviceChanged) {
   }

   public void keyPressed(KeyEvent e) {
     if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
       System.exit(0);
     }
   }
   public void keyReleased(KeyEvent e) {}
   public void keyTyped(KeyEvent e) {}
   private int prevMouseX, prevMouseY;
   private boolean mouseRButtonDown = false;

   public void mouseDragged(MouseEvent e) {
     int x = e.getX();
     int y = e.getY();

     Dimension size = e.getComponent().getSize();
     GLCanvas canvas = (GLCanvas) e.getSource();
     canvas.repaint();
     //System.out.println(size.width + " " + size.height);

     float thetaX = 360.0f * (float) (x - prevMouseX) / (float) size.width;
     float thetaY = 360.0f * (float) ( -prevMouseY + y) / (float) size.height;

     prevMouseX = x;
     prevMouseY = y;

     rquadX += thetaX;
     rtriX += thetaX;
     rquadY += thetaY;
     rtriY += thetaY;
   }

   public void mouseMoved(MouseEvent e) {
   }
   // Methods required for the implementation of MouseListener
   public void mouseEntered(MouseEvent e) {}
   public void mouseExited(MouseEvent e) {}
   public void mousePressed(MouseEvent e) {
     prevMouseX = e.getX();
     prevMouseY = e.getY();
     gl.glInitNames();
   }
   public void mouseReleased(MouseEvent e) {
   }
   public void mouseClicked(MouseEvent e) {}

 }
}
----------------------------------------------------------------
Pages: [1] 2
 

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

The first screenshot will be displayed as a thumbnail.

trollwarrior1 (33 views)
2014-11-22 12:13:56

xFryIx (73 views)
2014-11-13 12:34:49

digdugdiggy (52 views)
2014-11-12 21:11:50

digdugdiggy (46 views)
2014-11-12 21:10:15

digdugdiggy (40 views)
2014-11-12 21:09:33

kovacsa (65 views)
2014-11-07 19:57:14

TehJavaDev (69 views)
2014-11-03 22:04:50

BurntPizza (68 views)
2014-11-03 18:54:52

moogie (82 views)
2014-11-03 06:22:04

CopyableCougar4 (82 views)
2014-11-01 23:36:41
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

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

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

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

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

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