Home | History | Annotate | Download | only in opengl
      1 /*
      2 **
      3 ** Copyright 2007, The Android Open Source Project
      4 **
      5 ** Licensed under the Apache License, Version 2.0 (the "License");
      6 ** you may not use this file except in compliance with the License.
      7 ** You may obtain a copy of the License at
      8 **
      9 **     http://www.apache.org/licenses/LICENSE-2.0
     10 **
     11 ** Unless required by applicable law or agreed to in writing, software
     12 ** distributed under the License is distributed on an "AS IS" BASIS,
     13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14 ** See the License for the specific language governing permissions and
     15 ** limitations under the License.
     16 */
     17 
     18 /* Based on the public domain code:
     19  * Generic Convex Polygon Scan Conversion and Clipping
     20  * by Paul Heckbert
     21  * from "Graphics Gems", Academic Press, 1990
     22  */
     23 
     24 
     25 #ifndef POLY_HDR
     26 #define POLY_HDR
     27 
     28 namespace android {
     29 
     30 #define POLY_NMAX 10		/* max #sides to a polygon; change if needed */
     31 /* note that poly_clip, given an n-gon as input, might output an (n+6)gon */
     32 /* POLY_NMAX=10 is thus appropriate if input polygons are triangles or quads */
     33 
     34 typedef struct {		/* A POLYGON VERTEX */
     35     float sx, sy, sz, sw;	/* screen space position (sometimes homo.) */
     36 } Poly_vert;
     37 
     38 typedef struct {		/* A POLYGON */
     39     int n;			/* number of sides */
     40     Poly_vert vert[POLY_NMAX];	/* vertices */
     41 } Poly;
     42 
     43 #define POLY_CLIP_OUT 0		/* polygon entirely outside box */
     44 #define POLY_CLIP_PARTIAL 1	/* polygon partially inside */
     45 #define POLY_CLIP_IN 2		/* polygon entirely inside box */
     46 
     47 int	poly_clip_to_frustum(Poly *p1);
     48 
     49 } // namespace android
     50 
     51 #endif
     52