Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 9 of 9

Thread: delete image

  1. #1
    Guest

    delete image

    is there a way to delete a polygon that has been drawn to the screen. I want to be able to move it and delete the polygon from its old position but i cant call glClear as this will clear other polygons which I want to remain.

  2. #2
    Intern Newbie
    Join Date
    Mar 2002
    Posts
    34

    Re: delete image

    it would be better to just move it over using glTranslate(x, y, z)
    specifying numbers for x, y and z for how much you'd like to move it in each direction.
    Good luck!

  3. #3
    Guest

    Re: delete image

    yes i do this but when i translate it i end up with 2 polygons and not 1 because im not calling glClear

  4. #4
    Member Regular Contributor
    Join Date
    Jan 2002
    Location
    Kingston, Jamaica, W.I.
    Posts
    282

    Re: delete image

    No. There isn't a way as far as I know. A scene in OpenGL is additive, meaning you can add to the scene but you can't subtract. As such animators, etc. redraw the whole scene each time they want it to change. So that's what you'll have to do to get your shape moved.

    Altenatively, you can redraw the background that was "under" the image over it, basically treating it like a sprite. I really have no idea how effective that would be though.

  5. #5
    Senior Member OpenGL Pro
    Join Date
    Feb 2002
    Location
    Bonn, Germany
    Posts
    1,633

    Re: delete image

    Might be a job for the KTX_buffer_region extension. Should be pretty fast. But please note that that's not the way to do proper scene animation. As soon as you need to move your viewpoint it will stop working.

  6. #6
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,070

    Re: delete image

    I think your problem is that you are not setting up your scene correctly.
    You should be re-drawing the whole scene each time you move a object! And changing just the location of the object being moved.

    Correct me if I am wrong but you are trying to move one object and leave the others stationary in your scene? But each time move the object a copy of the old object stays in the previous spot. Doing the above will correct that.

    Originally posted by red:
    is there a way to delete a polygon that has been drawn to the screen. I want to be able to move it and delete the polygon from its old position but i cant call glClear as this will clear other polygons which I want to remain.


    [This message has been edited by nexusone (edited 03-05-2002).]

  7. #7
    Guest

    Re: delete image

    ill try that so, what would be the best way to save information about all the objects, could i do it in a stack and just redraw the entire stack each time?

  8. #8
    Member Regular Contributor
    Join Date
    Jan 2002
    Location
    Kingston, Jamaica, W.I.
    Posts
    282

    Re: delete image

    Normally all your drawing is in code. Typically for windows it's in the Paint function, or for glut it's your display callback. Thus everytime your screen is refreshed the code is called and the scene redrawn. So if you store the location of your objects in variables and refer to these variables in your drawing code, the image will automatically update each time the object is moved then the screen is redrawn.

    If you are only changing a small part of the scene, then you might want to put the rest in a display list. Display lists show much faster than their equivalent in code.

  9. #9
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,070

    Re: delete image

    Here is a example of how I handle it, though there are more advanced way's to do this.

    You have a varible array called Objects
    Each object in the array will have information about the object, like position, rotate, data to draw.

    Here is a simple example:

    Drawscene()
    {
    int i;
    for(i=0; i < number_of_objects;i++)
    {
    glTranslate(Objects[i].x, Objects[i].y, Objects[i].z);
    glRotate(Objects[i].x_axis, 1, 0, 0);
    glRotate(Objects[i].y_axis, 1, 0, 0);
    glRotate(Objects[i].z_axis, 1, 0, 0);
    DrawObject(Objects[i].ObjectData);
    }
    glutSwapBuffers();
    }

    UpdateScene()
    {
    int i;
    for(i=0; i < number_of_objects;i++)
    {
    if (Objects[i].status == 1) Only update objects that are moving. So we say moving objects have a status of 1, non-moving have a status of 0.
    {
    Update position
    }
    }
    }


    Originally posted by red:
    ill try that so, what would be the best way to save information about all the objects, could i do it in a stack and just redraw the entire stack each time?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •