Angel 3.2
A 2D Game Prototyping Engine
Common.h
Go to the documentation of this file.
1 
2 // Copyright (C) 2008-2013, Shane Liesegang
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are met:
7 //
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of the copyright holder nor the names of any
14 // contributors may be used to endorse or promote products derived from
15 // this software without specific prior written permission.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 // POSSIBILITY OF SUCH DAMAGE.
29 
35 #pragma once
36 
37 #if defined(WIN32)
38  #define WIN32_LEAN_AND_MEAN
39  #include <windows.h>
40  #include <direct.h>
41  #include <hash_map>
42  #define hashmap_ns stdext
43  #include <GL/gl.h>
44  #include <GL/glu.h>
45 #elif defined(__APPLE__)
46  #include "TargetConditionals.h"
47  #if ANGEL_MOBILE
48  #include <OpenGLES/ES1/gl.h>
49  #include "glu.h"
50  #include <sys/time.h>
51  #import <Availability.h>
52  #ifndef __IPHONE_5_0
53  #warning "This project uses features only available in iPhone SDK 5.0 and later."
54  #endif
55  #ifdef __OBJC__
56  #import <Foundation/Foundation.h>
57  #import <UIKit/UIKit.h>
58  #else
59  #include <CoreFoundation/CoreFoundation.h>
60  #endif
61  #else
62  #include <OpenGL/gl.h>
63  #include <OpenGL/glu.h>
64  #ifndef __OBJC__
65  #include <CoreFoundation/CoreFoundation.h>
66  #endif
67  #endif
68 #endif
69 #if defined(__APPLE__) || defined(__linux__)
70  #include <ext/hash_map>
71 
72  //GCC is picky about what types are allowed to be used as indices to hashes.
73  // Defining this here lets us use std::strings to index, which is useful.
74  #define hashmap_ns __gnu_cxx
75  namespace hashmap_ns
76  {
77  template<> struct hash< std::string >
78  {
79  size_t operator()( const std::string& x ) const
80  {
81  return hash< const char* >()( x.c_str() );
82  }
83  };
84  }
85  #if ANGEL_MOBILE
86  // making up for OpenGL|ES missing pieces
87  #define glColor3f(r,g,b) glColor4f(r,g,b,1.0f)
88  #define GL_CLAMP GL_CLAMP_TO_EDGE
89  #endif
90 #endif
91 
92 #if !ANGEL_MOBILE
93  #define GLFW_INCLUDE_GLU
94  #include <GLFW/glfw3.h>
95 #endif
96 
97 #include <math.h>
98 #include <iostream>
99 #include <string>
100 #include <vector>
101 #include <set>
102 #include <map>
103