Results 1 to 6 of 6

Thread: Does freeglut allow you to draw in top of other?

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2011
    Posts
    27

    Does freeglut allow you to draw in top of other?

    I have white image. I am trying to draw another image in top of it.
    But I cannot see it.
    And is there a way to erase a drawing? Not from the code

  2. #2
    Member Contributor
    Join Date
    Sep 2010
    Posts
    74

    Re: Does freeglut allow you to draw in top of other?

    To "erase", use glClear(GL_COLOR_BUFFER_BIT), and swap buffers if using double buffering.

  3. #3
    Junior Member Newbie
    Join Date
    Dec 2011
    Posts
    27

    Re: Does freeglut allow you to draw in top of other?

    But that deletes everything. However i want to delete just a single part. How can I do that?

  4. #4
    Senior Member OpenGL Lord
    Join Date
    Mar 2015
    Posts
    6,671

    Re: Does freeglut allow you to draw in top of other?

    You redraw everything except that part you don't want to see anymore. This is how the vast majority of OpenGL applications operates.

  5. #5
    Junior Member Newbie
    Join Date
    Dec 2011
    Posts
    27

    Re: Does freeglut allow you to draw in top of other?

    true.
    but what I am trying to do is let the user change the color of the object. Unfortunately, I could not learn picking. So, I thought i would use if statements like if x>122&amp;&amp; x< 213 return 1. same for y. So I would know which object was clicked. And then I called a popupmenu function for the user to choose color. Then I decided to redraw the colored object on top of other. If i erase all and draw again it will not work because I have different functions for drawing not colored things and colored things.
    anyway I will try.
    If you dont get this then I can provide a better explanation with code

  6. #6
    V-man
    Guest

    Re: Does freeglut allow you to draw in top of other?

    If you want to do color picking, you have 2 choices. Either you use the back buffer or a RenderBuffer. Assuming you want to use the back buffer.

    Whichever you choose, all you need to do is
    glCear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENIL_BUFFER_BIT);
    RenderObjectsWithUniqueColor();
    //Read back color under the mouse
    uint thecolor;
    glReadPixels(x, y, 1, 1, GL_BGRA, GL_UNSIGNED_BYTE, thecolor);

    //And clear again
    glCear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENIL_BUFFER_BIT);
    RenderObjects();
    SwapBuffers();

Similar Threads

  1. FreeGLUT on VirtualBox
    By 8Observer8 in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 05-23-2017, 03:33 AM
  2. freeglut.dll
    By sumsar in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 07-20-2013, 02:00 PM
  3. Glut or Freeglut?
    By robgeek in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 01-24-2013, 03:44 PM
  4. troubles with freeglut.lib
    By animaks in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 07-04-2012, 10:27 PM
  5. What is freeglut.lib?
    By AliceNarcissus in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 02-24-2005, 10:32 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