Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (487)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (553)
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]
1  Java Game APIs & Engines / JOGL Development / Drawing a Circle on: 2006-11-09 21:41:43
Hi.  I'm slowly figuring how to draw various "stuff" I need in my application.  This scratchpad app is used to test stuff.  Everything in the following code works but I cannot figure out how to draw a circle.  I'd appreciate some help.  I've tried the following calls with no luck.  Either I am using the wrong calls to draw an unfilled circle or I am missing additional calls to make them work. 

glu.gluSphere
glut.glutWireSphere
glut.glutSolidSphere

I want to draw the circle near the middle of the virtual coordinates (around 7500,7500).  Here is what I have that does work.

Thanx.  Andy

-----------------

    public void init(GLAutoDrawable drawable) {
        // Use debug pipeline
        // drawable.setGL(new DebugGL(drawable.getGL()));
        GL gl = drawable.getGL();
        System.err.println("INIT GL IS: " + gl.getClass().getName());       
        gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
        gl.glShadeModel(GL.GL_FLAT);
     }

    public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
        GL gl = drawable.getGL();
        gl.glViewport(0, 0, width, height);
        gl.glMatrixMode(GL.GL_PROJECTION);
        gl.glLoadIdentity();
        gl.glOrtho(-1000,15000,-1000,15000,-1,1);
    }
   
    public void display(GLAutoDrawable drawable) {
        GL gl = drawable.getGL();
        GLU glu = new GLU();
        GLUT glut = new GLUT();       
        int font18 = GLUT.BITMAP_HELVETICA_18;
        int font10 = GLUT.BITMAP_HELVETICA_10;
        int font_a = GLUT.BITMAP_8_BY_13;
               
        // Draw Rectange
        gl.glClear(GL.GL_COLOR_BUFFER_BIT);
        gl.glColor3f(1, 0, 0);
        gl.glRecti(100, 100, 1500, 1500);
       
        // Draw Line
        gl.glBegin(GL.GL_LINES);
        gl.glVertex2i(7500,7500);
        gl.glVertex2i(14000,14000);
        gl.glEnd();
       
        // Draw Text
        gl.glColor3f(0.0f, 1.0f, 0.0f);
        gl.glRasterPos3f(1000.0f,1000.0f,0.0f);
        glut.glutBitmapString(font18, "TEST18");
       
        gl.glRasterPos3f(6000.0f,8000.0f,0.0f);
        glut.glutBitmapString(font10, "TEST10");
       
        gl.glRasterPos3f(8000.0f,12000.0f,0.0f);
        glut.glutBitmapString(font_a, "TEST_A");
       
        gl.glColor3f(0.0f, 0.0f, 0.0f);
     }
   
    public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {
    }
2  Java Game APIs & Engines / JOGL Development / Re: JOGL Project Template available for NetBeans 5 on: 2006-11-09 21:31:01
We are currently moving to a new server and hosting provider and I am upgrading to the final JSR. Please take a look next weekend.

Thanx for the template and the update.  It helps a lot.

Andy
3  Java Game APIs & Engines / JOGL Development / Re: JOGL Project Template available for NetBeans 5 on: 2006-11-08 16:37:41
Has this link moved?  It worked a couple weeks ago but I have not been able to get there in the past couple days.

Thanx.  Andy
4  Java Game APIs & Engines / JOGL Development / Re: glOrtho and wacky Mouse on: 2006-11-06 01:20:26
Hi,

Since you have a simple glOrtho projection you can do the math yourself. You can also use gluUnproject routine do make the conversion. Search this forum to find some samples.
Hope it helps.

Turquoise - thanx for the gluUnproject help.  I found an example and got it working.

Andy
5  Java Game APIs & Engines / JOGL Development / glOrtho and wacky Mouse on: 2006-11-02 21:37:14
Hi.  I've found lotsa info close to what I want, but what I need is very simple.  I started with the SimpleJOGL program from the Netbeans template and created a virtual coordinate test program.  My program will draw a rectangle and a line within the virtual system (-1000,-1000 to 15000,15000), but I can't figure out how to get the mouse to return X,Y based on the virtual system.  Currently this program returns the X,Y of the screen with 0,0 in the upper left hand corner and with lower right as 600,400.  What call do I need to make to tell the mouse to return virtual coordinates in with the getX and getY?

Thanx.
Andy

import java.awt.*;
import java.awt.event.*;
import javax.media.opengl.*;
import com.sun.opengl.util.*;
import javax.media.opengl.glu.GLU;
/**
 * VirtualJOGL.java <BR>
 * author: Brian Paul (converted to Java by Ron Cemer and Sven Goethel) <P>
 *
 * This version is equal to Brian Paul's version 1.2 1999/10/21
 */

public class VirtualJOGL implements GLEventListener {   
    private static final int SIZE = 160;
    private MouseMotionAdapter mouseMotionListener = new MouseMotionAdapter() {
        public void mouseDragged(MouseEvent e) {
            motionMethod(e, e.getX(), e.getY());
        }
       
        public void mouseMoved(MouseEvent e) {
            passiveMotionMethod(e, e.getX(), e.getY());
        }
    };
   
    private MouseAdapter mouseListener = new MouseAdapter() {
        public void mousePressed(MouseEvent e) {
            mouseMethod(e, e.getModifiers(), true, e.getX(), e.getY());
        }
       
        public void mouseReleased(MouseEvent e) {
            mouseMethod(e, e.getModifiers(), false, e.getX(), e.getY());
        }
    };
   
    private void passiveMotionMethod(MouseEvent e, int x, int y) {
    }
   
    private void motionMethod(MouseEvent e, int x, int y) {
    }
    private void mouseMethod(MouseEvent e, int mods, boolean press,
            int x, int y) {
        if (press) {
            System.out.print("Mouse Clicked : ");
            System.out.print(x);
            System.out.print(" ");
            System.out.print(y);
            System.out.println(" ");
        }
    }
   
   
    public static void main(String[] args) {
        Frame frame = new Frame("Virtual JOGL Application");
        GLCanvas canvas = new GLCanvas();
       
        canvas.addGLEventListener(new VirtualJOGL());
        frame.add(canvas);
        frame.setSize(600, 400);
        final Animator animator = new Animator(canvas);
        frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                // Run this on another thread than the AWT event queue to
                // make sure the call to Animator.stop() completes before
                // exiting
                new Thread(new Runnable() {
                    public void run() {
                        animator.stop();
                        System.exit(0);
                    }
                }).start();
            }
        });
        // Center frame
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
        animator.start();
    }
   
    public void init(GLAutoDrawable drawable) {
        // Use debug pipeline
        // drawable.setGL(new DebugGL(drawable.getGL()));
       
        GL gl = drawable.getGL();
        System.err.println("INIT GL IS: " + gl.getClass().getName());
       
        gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
        gl.glShadeModel(GL.GL_FLAT);
       
        drawable.addMouseMotionListener(mouseMotionListener);
        drawable.addMouseListener(mouseListener);       
    }
   
    /**
     *
     * @param drawable
     * @param x
     * @param y
     * @param width
     * @param height
     */
    public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
        GL gl = drawable.getGL();
        gl.glViewport(0, 0, width, height);
        gl.glMatrixMode(GL.GL_PROJECTION);
        gl.glLoadIdentity();
        gl.glOrtho(-1000,15000,-1000,15000,-1,1);       
    }
   
    public void display(GLAutoDrawable drawable) {
        GL gl = drawable.getGL();
       
        gl.glClear(GL.GL_COLOR_BUFFER_BIT);
        gl.glColor3f(1, 0, 0);
        gl.glRecti(100, 100, 1500, 1500);
       
        gl.glBegin(GL.GL_LINES);
        gl.glVertex2i(7500,7500);
        gl.glVertex2i(14000,14000);
        gl.glEnd();
       
       
        gl.glColor3f(0.0f, 0.0f, 0.0f);
       
    }
   
    public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {
    }
}

Pages: [1]
 

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

The first screenshot will be displayed as a thumbnail.

CopyableCougar4 (24 views)
2014-08-22 19:31:30

atombrot (34 views)
2014-08-19 09:29:53

Tekkerue (30 views)
2014-08-16 06:45:27

Tekkerue (28 views)
2014-08-16 06:22:17

Tekkerue (18 views)
2014-08-16 06:20:21

Tekkerue (27 views)
2014-08-16 06:12:11

Rayexar (65 views)
2014-08-11 02:49:23

BurntPizza (41 views)
2014-08-09 21:09:32

BurntPizza (33 views)
2014-08-08 02:01:56

Norakomi (42 views)
2014-08-06 19:49:38
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

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

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

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

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

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

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

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