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 5 of 5

Thread: Implementing clipping in 3D Space

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2012
    Posts
    3

    Implementing clipping in 3D Space

    I would like to implement the Cohen-Sutherland Algorithm with dynamic clipping volume in 3D Space. (i.e. with 27 regions). Assume I have somthing like this:

    Code :
     glBegin(GL_LINES);
        glVertex3f(x1, y1, z1);
        glVertex3f(x2, y2, z2);
        glEnd();

    1. Is clipping automatically done as default? If yes, how can I deactivate it to use my own algorithm?
    2. I couldn't find an implementation for Sutherland in 3D Space. Do you know where I can find it?

    Principally any algorithm would be fine as long as it does 3D clipping.
    Thanks for your help!

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,128
    You can't. Clipping is fixed functionality in OpenGL.

  3. #3
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,948
    Is clipping automatically done as default? If yes, how can I deactivate it to use my own algorithm?
    Why would you want to? First, your algorithm won't be faster. Second, OpenGL's clipping does a different job; it's all about clipping vertices to the viewport, which may not be the entire visible screen. Third, most hardware doesn't even do "clipping", using a guardband optimization to avoid the actual clipping of lines/triangles in most cases. So there's nothing really to turn off.

    Or, to put it another way, you don't need to manually clip your lines to the viewport. You should only do clipping if you're clipping to some other space.

  4. #4
    Junior Member Newbie
    Join Date
    Oct 2012
    Posts
    3
    I have to do this, because it is a university project. It doesn't have to be an optimal solution, just something that works. Basically, the requirement is to check if lines are in the viewport cuboid before feeding them glVertex3f(). Hence, the algorithm for the solution has to check if there's an intersection between the lines that should be drawn and the lines of the viewport, all in 3D space. I don't have an idea how to implement this, as I'm a beginner to computer graphics.

  5. #5
    Advanced Member Frequent Contributor
    Join Date
    Apr 2010
    Posts
    746
    Please read the Forum Posting Guidelines, specifically point 6 of section "Before you post".

Posting Permissions

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