]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - contrib/camera/misc.h
Merge branch 'fix-fast' into 'master'
[xonotic/netradiant.git] / contrib / camera / misc.h
1 /*
2    Copyright (C) 1999-2006 Id Software, Inc. and contributors.
3    For a list of contributors, see the accompanying CONTRIBUTORS file.
4
5    This file is part of GtkRadiant.
6
7    GtkRadiant is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11
12    GtkRadiant is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with GtkRadiant; if not, write to the Free Software
19    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20  */
21
22 /*
23    Camera plugin for GtkRadiant
24    Copyright (C) 2002 Splash Damage Ltd.
25  */
26
27 #include "globaldefs.h"
28
29 void Sys_ERROR(char *text, ...);
30
31 char *UnixToDosPath(char *path);
32
33 void ExtractFilePath(const char *path, char *dest);
34
35 const char *ExtractFilename(const char *path);
36
37 bool FileExists(const char *filename);
38
39 int Q_stricmp(const char *s1, const char *s2);
40
41 typedef int fileHandle_t;
42
43 extern "C" {
44 // command buffer
45 void Cbuf_AddText(const char *text);
46 void Cbuf_Execute(void);
47
48 // common
49 #ifndef CDECL
50 #if GDEF_OS_WINDOWS
51 #define CDECL __cdecl
52 #else
53 #define CDECL
54 #endif
55 #endif
56
57 void CDECL Com_Error(int level, const char *error, ...);
58 void CDECL Com_Printf(const char *msg, ...);
59 void CDECL Com_DPrintf(const char *msg, ...);
60 void *Com_Allocate(int bytes);
61 void Com_Dealloc(void *ptr);
62
63 // filesystem
64 int FS_Read(void *buffer, int len, fileHandle_t f);
65 int FS_Write(const void *buffer, int len, fileHandle_t h);
66 int FS_ReadFile(const char *qpath, void **buffer);
67 void FS_FreeFile(void *buffer);
68 int FS_FOpenFileRead(const char *filename, fileHandle_t *file, bool uniqueFILE);
69 fileHandle_t FS_FOpenFileWrite(const char *filename);
70 void FS_FCloseFile(fileHandle_t f);
71 }
72
73 // vectors
74 #define DotProduct4(x, y)        ( ( x )[0] * ( y )[0] + ( x )[1] * ( y )[1] + ( x )[2] * ( y )[2] + ( x )[3] * ( y )[3] )
75 #define VectorSubtract4(a, b, c)  ( ( c )[0] = ( a )[0] - ( b )[0],( c )[1] = ( a )[1] - ( b )[1],( c )[2] = ( a )[2] - ( b )[2],( c )[3] = ( a )[3] - ( b )[3] )
76 #define VectorAdd4(a, b, c)       ( ( c )[0] = ( a )[0] + ( b )[0],( c )[1] = ( a )[1] + ( b )[1],( c )[2] = ( a )[2] + ( b )[2],( c )[3] = ( a )[3] + ( b )[3] )
77 #define VectorCopy4(a, b)        ( ( b )[0] = ( a )[0],( b )[1] = ( a )[1],( b )[2] = ( a )[2],( b )[3] = ( a )[3] )
78 #define VectorScale4(v, s, o)   ( ( o )[0] = ( v )[0] * ( s ),( o )[1] = ( v )[1] * ( s ),( o )[2] = ( v )[2] * ( s ),( o )[3] = ( v )[3] * ( s ) )
79 #define VectorMA4(v, s, b, o)   ( ( o )[0] = ( v )[0] + ( b )[0] * ( s ),( o )[1] = ( v )[1] + ( b )[1] * ( s ),( o )[2] = ( v )[2] + ( b )[2] * ( s ),( o )[3] = ( v )[3] + ( b )[3] * ( s ) )
80
81 #define Vector4Copy(a, b)        ( ( b )[0] = ( a )[0],( b )[1] = ( a )[1],( b )[2] = ( a )[2],( b )[3] = ( a )[3] )
82
83 #define SnapVector(v) {v[0] = (int)v[0]; v[1] = (int)v[1]; v[2] = (int)v[2]; }