Page 1 of 4 1234 LastLast
Results 1 to 10 of 38

Thread: clearing windows

  1. #1
    Senior Member Regular Contributor
    Join Date
    Jan 2013
    Posts
    170

    Question clearing windows

    I am unsure of how to use glScissor and glViewport to clear a portion of the window.

  2. #2
    Senior Member OpenGL Lord
    Join Date
    Mar 2015
    Posts
    6,676
    Quote Originally Posted by pbivens View Post
    I am unsure of how to use glScissor and glViewport to clear a portion of the window.
    Well, you can't use glViewport to clear part of a window; [url=https://www.opengl.org/wiki/Framebuffer#Buffer_clearingframebuffer clearing commands[/url] aren't affected by the viewport transform.

    The scissor test is respected by rendering commands. What exactly are you unsure about in how to use scissoring?

  3. #3
    Senior Member Regular Contributor
    Join Date
    Jan 2013
    Posts
    170
    well I want to use glScissor to clear a polygon that I am texturing.

  4. #4
    Senior Member Regular Contributor
    Join Date
    Jan 2013
    Posts
    170
    is there any command I can use to clear a polygon?

  5. #5
    Senior Member OpenGL Lord
    Join Date
    Mar 2015
    Posts
    6,676
    What do you mean by "clear a polygon?" Clearing is something that happens to the screen. By the time you've put a polygon on the screen, it's not a polygon; it's just a bunch of pixels.

    If you want to render a scene without one particular polygon in it, then that's what you need to do. You can't undo a scene after the fact; you should just clear the screen and render everything else.

  6. #6
    Senior Member Regular Contributor
    Join Date
    Jan 2013
    Posts
    170
    well I want to erase a polygon that I have rendered without clearing the entire screen I thought glScissor could work for me.

  7. #7
    Senior Member OpenGL Lord
    Join Date
    Mar 2015
    Posts
    6,676
    Quote Originally Posted by pbivens View Post
    well I want to erase a polygon that I have rendered without clearing the entire screen I thought glScissor could work for me.
    Not unless that polygon is an axis-aligned square. Also, even if you could, if there was something behind that polygon, this would not cause it to appear.

    Remember: OpenGL is just a fancy triangle drawing system. Once it's drawn, it's not a polygon; it's just a bunch of pixels. If you overwrite pixels, then their values are lost.

  8. #8
    Senior Member Regular Contributor
    Join Date
    Jan 2013
    Posts
    170
    so can I use glScissor? I am a little confused.

  9. #9
    Senior Member OpenGL Lord
    Join Date
    Mar 2015
    Posts
    6,676
    I honestly don't know how I can possibly explain it more explicitly.

    The scissor test designates an axis-aligned rectangular area of the window. When the test is enabled, all attempts by rendering commands to write to pixels outside of that region will fail. Thus only pixels inside of that area will be affected by that rendering command.

    Framebuffer clearing functions are rendering commands. Therefore, they are affected by the scissor test.

    Given the two above facts, it naturally concludes that you can use the scissor test and clearing commands to clear an axis-aligned rectangular portion of the window, rather than the entire window.

    You want to clear a polygon. The above gives you the ability to clear an axis-aligned rectangular area of the window.

    Therefore, you can only use the above feature to clear a polygon if that polygon is "an axis-aligned rectangular area of the window". If that polygon is a triangle, non-axis-aligned rectangle, an arbitrary quadrilateral, or any other kind of polygon, then you cannot use the scissor test and framebuffer clearing to clear it.

  10. #10
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    3,109
    Quote Originally Posted by pbivens View Post
    well I want to erase a polygon that I have rendered without clearing the entire screen
    Then draw the exact same polygon again (with depth tests disabled), in whatever colour constitutes "clear" (e.g. your background colour).

Page 1 of 4 1234 LastLast

Similar Threads

  1. Clearing SSBO
    By Mustard in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 04-15-2013, 03:35 AM
  2. clearing
    By ajbiv in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 01-24-2009, 02:00 PM
  3. Clearing buffers?
    By Dr Dogg in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 02-20-2004, 05:05 AM
  4. Clearing the buffer
    By tclay in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 10-18-2000, 08:07 AM
  5. Clearing the window
    By J.Warrick in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 06-03-2000, 08:20 AM

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