ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libgender/util.h
(Generate patch)

Comparing libgender/util.h (file contents):
Revision 1.38 by root, Sun Oct 10 19:50:37 2004 UTC vs.
Revision 1.39 by root, Mon Oct 11 00:05:48 2004 UTC

1#ifndef UTIL_H 1#ifndef UTIL_H
2#define UTIL_H 2#define UTIL_H
3 3
4#include <cmath> 4#include <cmath>
5#include <cfloat> 5#include <cfloat>
6#include <cstdlib>
6#include <vector> 7#include <vector>
7#include <string> 8#include <string>
8 9
9#include "opengl.h" 10#include "opengl.h"
10 11
18extern CGparameter mv, mvp, lightpos; 19extern CGparameter mv, mvp, lightpos;
19extern CGprofile vsh_profile, fsh_profile; 20extern CGprofile vsh_profile, fsh_profile;
20 21
21typedef long long soffs; // 32 bit 22typedef long long soffs; // 32 bit
22typedef unsigned long long uoffs; 23typedef unsigned long long uoffs;
23#define OFFS_BITS 31 24#define OFFS_BITS 63
24#define SOFFS_MIN (soffs)-(1LL << (OFFS_BITS - 2)) 25#define SOFFS_MIN (soffs)-(1LL << (OFFS_BITS - 2))
25#define SOFFS_MAX (soffs)+(1LL << (OFFS_BITS - 2)) 26#define SOFFS_MAX (soffs)+(1LL << (OFFS_BITS - 2))
26#define MAXEXTENT (1ULL << (OFFS_BITS - 1)) 27#define MAXEXTENT (1ULL << (OFFS_BITS - 1))
28
29#define ABS(n) ((n) < 0 ? -(n) : (n))
27 30
28struct sector 31struct sector
29{ 32{
30 soffs x, y, z; 33 soffs x, y, z;
31 34
70 return p + (dst - src); 73 return p + (dst - src);
71} 74}
72 75
73inline sector abs (const sector &s) 76inline sector abs (const sector &s)
74{ 77{
75 return sector (abs (s.x), abs (s.y), abs (s.z)); 78 return sector (ABS (s.x), ABS (s.y), ABS (s.z));
76} 79}
77 80
78struct vec3 81struct vec3
79{ 82{
80 GLfloat x, y, z; 83 GLfloat x, y, z;
108inline GLfloat dot (const vec3 &a, const vec3 &b) 111inline GLfloat dot (const vec3 &a, const vec3 &b)
109{ 112{
110 return a.x * b.x + a.y * b.y + a.z * b.z; 113 return a.x * b.x + a.y * b.y + a.z * b.z;
111} 114}
112 115
113inline const GLfloat abs (const vec3 &v) 116inline const GLfloat norm (const vec3 &v)
114{ 117{
115 return sqrtf (dot (v, v)); 118 return sqrtf (dot (v, v));
116} 119}
117 120
118struct matrix 121struct matrix
248extern skedjuhlar main_scheduler; 251extern skedjuhlar main_scheduler;
249*/ 252*/
250 253
251namespace gl 254namespace gl
252{ 255{
253 void draw_box (const view &ctx, const sector &a, const sector &b); 256 void draw_bbox (const view &ctx, const sector &a, const sector &b);
254 257
255 extern int nesting; 258 extern int nesting;
256 void errchk (const char *name, const char *args, const char *file, int line); 259 void errchk (const char *name, const char *args, const char *file, int line);
257} 260}
258 261

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines