This post was updated on .
I used to use JOGL 1.0 for game dev, spent a few years away and now JOGL 2.0 is out. My OS is Linux Mint 13. I am using the JOGL natives i586 although my OS is i686. using Java 7 Open JDK i386(same issues with Java 6 before I upgraded). Getting some weird errors.
I tried running a JOGL2.0 picking example(http://jogamp.org/jogl-demos/src/demos/misc/Picking.java) and the display flashed the renderings correctly for maybe a half second then it went black(set clear color). Also when I resize the frame anything inside of it disappears. This was all of course after countlessly trying to debug my own scripts. In my own script it seems that the glcanvas never updates the GluLookAt . Meaning the camera view never changes. If I change any of the rendering(changing the color of the objects being drawn, not rendering the scene at all) during the application it still only displays the first rendering. I'm thinking this might be a java and or jogl error rather then a script error. Either way any advice is appreciated. If anyone could run my script and tell me if when you click the mouse the black pyramid gets further and further away it would be very appreciated. Thank you for your time. Here's my code: orbitalExplorerApp.java [code] import java.applet.*; import java.awt.*; import javax.media.opengl.awt.GLCanvas; import com.jogamp.opengl.util.Animator; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLProfile; @SuppressWarnings("serial") public class orbitalExplorerApp extends Applet{ private static final long serialVersionUID = 7403003329697278728L; protected Animator animator; protected GLCanvas glcanvas; private orbitalExplorer orbExplorer = new orbitalExplorer(); public void init() { setLayout( new BorderLayout() ); GLProfile profile = GLProfile.get(GLProfile.GL2); GLProfile.initSingleton(); GLCapabilities capabilities = new GLCapabilities(profile); glcanvas = new GLCanvas(capabilities); glcanvas.addGLEventListener(orbExplorer); glcanvas.addMouseListener(orbExplorer); glcanvas.setBounds(0, 0, 512, 512); animator = new Animator(glcanvas); add(glcanvas, BorderLayout.CENTER); } public void start() { animator.setRunAsFastAsPossible(false); animator.start(); } public void stop() { animator.stop(); } public void destroy() {} } [/code] orbitalExplorer.java [code] import java.awt.event.MouseListener; import java.awt.event.MouseEvent; import javax.media.opengl.GL2; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLEventListener; import javax.media.opengl.awt.GLCanvas; import javax.media.opengl.glu.GLU; public class orbitalExplorer extends GLCanvas implements GLEventListener, MouseListener{ private GLU glu = new GLU(); private GL2 gl; private Camera3D camera = new Camera3D(-1.0f,0f,-16.0f,//Location X,Y,Z 0f,0f,0f,//Angle X,Y,Z, 2f,//Orbiting Radius 0f,0f,0f);//Focus Position private float degreeToRadian = 0.0174532925f; public void mouseClicked(MouseEvent mouse) { camera.z = camera.z - 10.0f; System.out.println("camera-z:"+camera.z);//Displays correct camera values on clicking } public void mousePressed(MouseEvent mouse) { } public void mouseReleased(MouseEvent mouse) { } public void mouseEntered(MouseEvent mouse) {} public void mouseExited(MouseEvent mouse) {} public void mouseDragged(MouseEvent mouse) {} public void mouseMoved(MouseEvent mouse) {} public void mouseWheelMoved(MouseEvent mouse) {} public void reshape( GLAutoDrawable drawable, int x, int y, int width, int height ) { gl = drawable.getGL().getGL2(); 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(GL2.GL_PROJECTION); gl.glLoadIdentity(); glu.gluPerspective(45.0f, h, 1.0f, 100.0f);//20 = LOOK AT DIST gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glLoadIdentity(); } public void init( GLAutoDrawable drawable ) { gl = drawable.getGL().getGL2(); //Set Up GL gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); gl.glEnable(GL2.GL_DEPTH_TEST); gl.glClearDepth(1.0f); gl.glDepthFunc(GL2.GL_LEQUAL); gl.glHint(GL2.GL_PERSPECTIVE_CORRECTION_HINT, GL2.GL_NICEST); } public void dispose( GLAutoDrawable drawable ) {} public void display( GLAutoDrawable drawable ) { //Canvas Clearing gl = drawable.getGL().getGL2(); gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT); gl.glLoadIdentity(); //Camera Permutations glu.gluLookAt(camera.x, camera.y, camera.z, camera.focusx, camera.focusy, camera.focusz, 0, 1, 0); //Rendering Operations gl.glPushMatrix(); gl.glBegin(GL2.GL_TRIANGLES); // Drawing Using Triangles gl.glColor3f(0.0f, 0.0f, 0.0f); // gl.glVertex3f(0.0f, 1.0f, 0.0f); // Top Of Triangle (Front) gl.glVertex3f(-1.0f, -1.0f, 1.0f); // Left Of Triangle (Front) gl.glVertex3f(1.0f, -1.0f, 1.0f); // Right Of Triangle (Front) gl.glVertex3f(0.0f, 1.0f, 0.0f); // Top Of Triangle (Right) gl.glVertex3f(1.0f, -1.0f, 1.0f); // Left Of Triangle (Right) gl.glVertex3f(1.0f, -1.0f, -1.0f); // Right Of Triangle (Right) gl.glVertex3f(0.0f, 1.0f, 0.0f); // Top Of Triangle (Back) gl.glVertex3f(1.0f, -1.0f, -1.0f); // Left Of Triangle (Back) gl.glVertex3f(-1.0f, -1.0f, -1.0f); // Right Of Triangle (Back) gl.glVertex3f(0.0f, 1.0f, 0.0f); // Top Of Triangle (Left) gl.glVertex3f(-1.0f, -1.0f, -1.0f); // Left Of Triangle (Left) gl.glVertex3f(-1.0f, -1.0f, 1.0f); // Right Of Triangle (Left) gl.glEnd(); gl.glPopMatrix(); gl.glFlush(); } } [/code] Vector3D.java [code] public class Vector3D { public float x, y, z; public float mag; public Vector3D(float X, float Y, float Z){ x = X; y = Y; z = Z; } public Vector3D(){ x = 0f; y = 0f; z = 0f; } public Vector3D(Vector3D vector){ x = vector.x; y = vector.y; z = vector.z; } public void setX(float X){x = X;} public void setY(float Y){x = Y;} public void setZ(float Z){x = Z;} public void setXYZ(float X,float Y,float Z) {x = X; y = Y; z = Z;} public float magnitude(){ return (float)Math.sqrt(x*x + y*y + z*z); } public void add(Vector3D vector){ x += vector.x; y += vector.y; z += vector.z; } public void subtract(Vector3D vector){ x -= vector.x; y -= vector.y; z -= vector.z; } public void scalar(float scalar){ x = x * scalar; y = y * scalar; z = z * scalar; } public void divide(float scalar){ x = x / scalar; y = y / scalar; z = z / scalar; } public float dotProduct(Vector3D vector){ return (float) (x * vector.x) + (y * vector.y) + (z * vector.z); } public Vector3D crossProduct(Vector3D vector){ float crossX = y * vector.z + vector.y * z; float crossY = z * vector.x - vector.z * x; float crossZ = x * vector.y - vector.x * y; return new Vector3D(crossX, crossY, crossZ); } public void normalize(){ float mag = magnitude(); if(mag > 0){ divide(mag); } } public float distance(Vector3D vector){ float distanceX = x - vector.x, distanceY = y - vector.y, distanceZ = z - vector.z; return (float)Math.sqrt(distanceX * distanceX + distanceY * distanceY + distanceZ * distanceZ); } public float angleBetween(Vector3D vector){ float dot = dotProduct(vector); float theta = (float)Math.acos(dot / (magnitude() * vector.magnitude())); return theta; } } [/code] Camera3D.Java [code] public class Camera3D extends Vector3D{ public float anglex, angley, anglez; public float radius = 1f; public float focusx = 0f, focusy = 0f, focusz = 0f; public Camera3D(float X, float Y, float Z, float angleX, float angleY, float angleZ, float Radius, float focusX, float focusY, float focusZ){ x = X; y = Y; z = Z; anglex = angleX; angley = angleY; anglez = angleZ; radius = Radius; focusx = focusX; focusy = focusY; focusz = focusZ; } } [/code] I realize BB code isn't used on this forum but I figured I'd leave my message with it in just for organization. |
Nevermind just had to install new drivers for my graphics card!
|
Administrator
|
I'm glad to see that you fixed your problem.
Julien Gouesse | Personal blog | Website
|
Free forum by Nabble | Edit this page |