From http://www.jwz.org/xscreensaver/xscreensaver-5.35.tar.gz
[xscreensaver] / hacks / glx / normals.h
1 /* normals, Copyright (c) 2002-2012 Jamie Zawinski <jwz@jwz.org>
2  *
3  * Permission to use, copy, modify, distribute, and sell this software and its
4  * documentation for any purpose is hereby granted without fee, provided that
5  * the above copyright notice appear in all copies and that both that
6  * copyright notice and this permission notice appear in supporting
7  * documentation.  No representations are made about the suitability of this
8  * software for any purpose.  It is provided "as is" without express or 
9  * implied warranty.
10  *
11  * Compute normal vectors for arbitrary triangles.
12  */
13
14 #ifndef __NORMALS_H__
15 #define __NORMALS_H__
16
17 #ifdef HAVE_CONFIG_H
18 # include "config.h"
19 #endif /* HAVE_CONFIG_H */
20
21 #ifndef HAVE_JWXYZ
22 # include <GL/gl.h>
23 #endif
24
25 #ifdef HAVE_ANDROID
26 # include <GLES/gl.h>
27 #endif
28
29 #ifdef HAVE_JWZGLES
30 # include "jwzgles.h"
31 #endif /* HAVE_JWZGLES */
32
33 typedef struct {
34   double x,y,z;
35 } XYZ;
36
37 /* Calculate the unit normal at p given two other points p1,p2 on the
38    surface. The normal points in the direction of p1 crossproduct p2
39  */
40 extern XYZ calc_normal (XYZ p, XYZ p1, XYZ p2);
41
42 /* Call glNormal3f() with a normal of the indicated triangle.
43  */
44 extern void do_normal (GLfloat x1, GLfloat y1, GLfloat z1,
45                        GLfloat x2, GLfloat y2, GLfloat z2,
46                        GLfloat x3, GLfloat y3, GLfloat z3);
47
48 #endif /* __NORMALS_H__ */