Results 1 to 5 of 5

Thread: add item

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2011
    Location
    Επιλέξτε κατηγορία
    Posts
    4

    add item

    In OpenGl, I want to add some shapes (Cylinders) on an already drawn jpanel..In particular, I want to draw a cylinder, based on a value aquired from the user (the value corresponds to the height of the cylinder).
    But each time, I want to add a new cylinder on the previously painted jpanel
    Do I have to repaint the whole jpanel, or is there a way to add only the specific object (cylinder) on the previously painted jpanel?

  2. #2
    Senior Member OpenGL Lord
    Join Date
    Mar 2015
    Posts
    6,674

    Re: add item

    What is a "jpanel"?

  3. #3
    Junior Member Newbie
    Join Date
    Mar 2011
    Location
    Επιλέξτε κατηγορία
    Posts
    4

    Re: add item

    java use jpanel and canvas for drawing the items...i dont know where c does the same...Opengl is the same for both of them

  4. #4
    Newbie OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,789

    Re: add item

    In a single-buffered context you only have to add the cylinder, and it's recommended that you call glFlush or glFinish after doing so.

    In a double-buffered context you can either (1) use glDrawBuffer (GL_FRONT) and just add the cylinder as above, or (2) redraw the entire scene, including the cylinder.

    (1) is NOT recommended as it can cause certain graphics cards to explode. Well, not explode, but they could hang your OS or cause the Windows Vista/7 DWM to restart. This is mainly Intel, so if you need to run on Intel be aware of it.

    (2) should not be a big problem for you if you have your main scene manager/render loop set up correctly. At the most basic level you should be maintaining a list of objects to be drawn, so all you would need to do is create a cylinder object and insert it in the right place, then call your redraw method.

  5. #5
    Junior Member Newbie
    Join Date
    Mar 2011
    Location
    Επιλέξτε κατηγορία
    Posts
    4

    Re: add item

    my problem is that when i call my function which is
    Code :
           public void cylinder() {
            gl = drawable.getGL();
            gl.glScaled(0.7, 0.7, 0.7);
            gl.glColor4f(1f, 0.5f, 1f, 1f);
            gl.glTranslatef(1f, 0f, 1f);
            GLUquadric jog = glu.gluNewQuadric();
            gl.glRotatef(-90.0f, 1.0f, 0.0f, 0.0f);
            glu.gluDisk(jog, 0.0, 1.0, 32, 1);
            glu.gluCylinder(jog, 1.0f, 1.0, 2.0, 32, 1);
            gl.glTranslatef(0.0f, 0.0f, 2.0f);
            glu.gluDisk(jog, 0.0, 1.0, 32, 1);
            gl.glTranslatef(0.0f, 0.0f, -2.0f);
            gl.glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
            glu.gluDeleteQuadric(jog);
        }

    i have exception here gl = drawable.getGL();

    java.lang.NullPointerException

    i cant really understant where is the problem...i try to fix it but i have no result.

Similar Threads

  1. Work Item synchronization
    By Xman176 in forum OpenCL
    Replies: 3
    Last Post: 02-25-2017, 02:47 AM
  2. Android 3D Item not well displayed
    By romainb in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 02-06-2017, 01:36 AM
  3. Work-item cooperation possible?
    By ThomyS in forum OpenCL
    Replies: 4
    Last Post: 09-15-2016, 02:58 AM
  4. Work Item
    By toneburst in forum OpenCL
    Replies: 2
    Last Post: 11-17-2010, 02:49 AM
  5. Item I would like to see in the next version
    By coolcajun in forum COLLADA
    Replies: 1
    Last Post: 07-11-2007, 05:06 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