Results 1 to 3 of 3

Thread: Why canīt I print a GL_POINTS?

  1. #1
    Member Newbie
    Join Date
    Jul 2009
    Posts
    33

    Why canīt I print a GL_POINTS?

    I am trying to print a point using GL_POINTS, but the point is not beeing printed.

    When I try to output a GL_QUAD, then it works, but not GL_POINTS. What am a doing wrong?

    The reshape() method contains these two lines:
    Code :
    ...
    gl.glLoadIdentity();
    glu.gluOrtho2D(0.0, 500.0, 0.0, 300.0);

    my display() function contains this:
    Code :
    GL gl = drawable.getGL();
    gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
    gl.glLoadIdentity();
     
    gl.glColor3f(1.5f, 1.5f, 1.5f);
    gl.glPointSize(5.0f);
    gl.glBegin(GL.GL_POINTS);
        gl.glVertex2i(20, 150);
    gl.glEnd();

    Have I missed something?

  2. #2
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: Why canīt I print a GL_POINTS?

    gl.glPointSize(5.0f); -> try without point size, check you see a normal 1 pixel point.
    beware from the screen edges, points are clipped before being sized, so stay far from the edges.

  3. #3
    Member Newbie
    Join Date
    Jul 2009
    Posts
    33

    Re: Why canīt I print a GL_POINTS?

    I have tested that but it still doesnīt work.

    Here is the whole code. It works with QUADS but not with POINTS. No point is beeing printed.

    Can you see any error in the code?

    Code :
    import com.sun.opengl.util.Animator;
    import java.awt.Frame;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import java.awt.event.*;
    import javax.media.opengl.GL;
    import javax.media.opengl.GLAutoDrawable;
    import javax.media.opengl.GLCanvas;
    import javax.media.opengl.GLEventListener;
    import javax.media.opengl.glu.GLU;
     
     
    public class SimpleJOGL implements GLEventListener {
     
     
        static Frame frame;
     
        public static void main(String[] args) {
            frame = new Frame("OpenGL Application");
            GLCanvas canvas = new GLCanvas();
     
            canvas.addGLEventListener(new SimpleJOGL());
            frame.add(canvas);
            frame.setSize(640, 480);
     
            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();
            canvas.requestFocus();
        }
     
        public void init(GLAutoDrawable drawable) {
            // Use debug pipeline
            // drawable.setGL(new DebugGL(drawable.getGL()));
     
            GL gl = drawable.getGL();
            gl.glClear(GL.GL_COLOR_BUFFER_BIT);
    	gl.glClear(GL.GL_DEPTH_BUFFER_BIT);
     
            System.err.println("INIT GL IS: " + gl.getClass().getName());
     
            // Enable VSync
            gl.setSwapInterval(1);
     
            // Setup the drawing area and shading mode
            gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
            gl.glShadeModel(GL.GL_SMOOTH); // try setting this to GL_FLAT and see what happens.
            drawable.addKeyListener(new KeyListener());
     
        }
     
        public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
            GL gl = drawable.getGL();
            GLU glu = new GLU();
     
            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();
            gl.glMatrixMode(GL.GL_MODELVIEW);
     
            gl.glLoadIdentity();
            glu.gluOrtho2D(0.0, 500.0, 0.0, 300.0);
     
     
        }
     
        public void display(GLAutoDrawable drawable) {
     
            GL gl = drawable.getGL();
     
            // Clear the drawing area
            gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
            // Reset the current matrix to the "identity"
            gl.glLoadIdentity();
     
            gl.glColor3f(1.5f, 1.5f, 1.5f);
            gl.glPointSize(50.0f);
            gl.glBegin(GL.GL_POINTS);
                gl.glVertex2i(20, 150);
            gl.glEnd();
     
     
            // Flush all drawing operations to the graphics card
            gl.glFlush();
        }
     
        public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {
        }
     
        private class KeyListener extends KeyAdapter
        {
            public void keyPressed(KeyEvent e)
            {
                if(e.getKeyCode() == KeyEvent.VK_ESCAPE)
               {
                   System.exit(0);
               }
        }
     
     
     
    }

Similar Threads

  1. How to print out the data in VBO?
    By SagoO in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 01-14-2011, 03:52 PM
  2. about print help
    By hollandwolf in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 04-28-2004, 01:59 AM
  3. pls help to print
    By arc in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 03-24-2004, 11:02 PM
  4. How to print
    By in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 01-29-2003, 01:59 PM
  5. GL Print
    By Wei in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 11-13-2001, 01:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean