How does OpenGL do clipping?
The OpenGL spec states that vertices are clipped into the range -wc <=
xc <= wc, -wc <= yc <= wc, -wc <= zc <= wc, where wc is the clip w
coordinate, xc is the clip x coordinate, etc.
I presumed that this process was done using a 3D implementation of
Hodgman-Sutherland, but this appears to be incorrect.
I'm looking for an expert on this exact subject that can sort out my
confusion. Assume I'm implementing my own OpenGL in software. |
Request for Question Clarification by
maniac-ga
on
02 Oct 2005 19:57 PDT
Hello Inkyblinky,
You may want to describe a little more fully "which" clipping you are
attempting to perform. The clipping done by the sample implementation
of Open GL at
http://oss.sgi.com/projects/ogl-sample/
is very complex (wc main/gfx/opengl/glcore/*clip* - results in 1830
lines of code). There are lots of special cases (e.g., an arbitrary
polygon being clipped against a plane, resulting in multiple polys,
different algorithms when fog is present) that may need to be
implemented - depending on your need.
Could you explain a little more fully the scope of your question so I
can prepare a proper answer based on a review of the source code.
A side question - based on the last sentence - I might ask why the
[free] sample implementation is not adequate for your needs?
--Maniac
|
Clarification of Question by
inkyblinky-ga
on
03 Oct 2005 13:04 PDT
I need to clip a triangle to the view volume defined by the equations
given above (e.g., -wc <= x <= wc, etc.). I'm looking for a clear
discussion of the general theory, not "this is what the opengl
reference rasterizer does." I want to understand why hodgman
sutherland and cohen sutherland both seem to be inadequate to the
task, and get a pointer to an algorithm (hopefully in Computer
Graphics, Principles and Practice) that will clip for me.
|
Clarification of Question by
inkyblinky-ga
on
03 Oct 2005 13:14 PDT
...or stated another way, how do you clip a triangle in homogeneous
coordinates to the view volume, which is also specified in homogeneous
coordinates.
|