/docs/MyDocs

To get this branch, use:
bzr branch http://darksoft.org/webbzr/docs/MyDocs

« back to all changes in this revision

Viewing changes to Development/libraries/opengl/example/functions.h

  • Committer: Suren A. Chilingaryan
  • Date: 2009-04-09 03:21:08 UTC
  • Revision ID: csa@dside.dyndns.org-20090409032108-w4edamdh4adrgdu3
import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
void delay(ms) {
 
2
    struct timespec ts;
 
3
    ts.tv_sec = ms / 1000;
 
4
    ts.tv_nsec = (ms % 1000) * 1000000;
 
5
    nanosleep(&ts, NULL);
 
6
}
 
7
 
 
8
void normalize(float *v) {    
 
9
   GLfloat d = sqrt(v[0]*v[0]+v[1]*v[1]+v[2]*v[2]); 
 
10
   if (d == 0.0) { puts("zero vector"); exit(1); }
 
11
   v[0] /= d; v[1] /= d; v[2] /= d; 
 
12
}
 
13
 
 
14
void normcrossprod(float *v1, float *v2, float *out) 
 
15
 
16
   GLint i, j; 
 
17
   GLfloat length;
 
18
 
 
19
   out[0] = v1[1]*v2[2] - v1[2]*v2[1]; 
 
20
   out[1] = v1[2]*v2[0] - v1[0]*v2[2]; 
 
21
   out[2] = v1[0]*v2[1] - v1[1]*v2[0]; 
 
22
   normalize(out); 
 
23
}