ARWrapper
Provides a C++ wrapper around ARToolKit and exposes a C and JNI API
 All Classes Files Functions Variables Typedefs Enumerations Enumerator
Platform.h
Go to the documentation of this file.
1 /*
2  * Platform.h
3  * ARToolKit5
4  *
5  * This file is part of ARToolKit.
6  *
7  * ARToolKit is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Lesser General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * ARToolKit 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 Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with ARToolKit. If not, see <http://www.gnu.org/licenses/>.
19  *
20  * As a special exception, the copyright holders of this library give you
21  * permission to link this library with independent modules to produce an
22  * executable, regardless of the license terms of these independent modules, and to
23  * copy and distribute the resulting executable under terms of your choice,
24  * provided that you also meet, for each linked independent module, the terms and
25  * conditions of the license of that module. An independent module is a module
26  * which is neither derived from nor based on this library. If you modify this
27  * library, you may extend this exception to your version of the library, but you
28  * are not obligated to do so. If you do not wish to do so, delete this exception
29  * statement from your version.
30  *
31  * Copyright 2015 Daqri, LLC.
32  * Copyright 2011-2015 ARToolworks, Inc.
33  *
34  * Author(s): Julian Looser, Philip Lamb
35  *
36  */
37 
38 #ifndef PLATFORM_H
39 #define PLATFORM_H
40 
41 // Determine the platform on which the code is being built
42 
43 #if defined _WIN32 || defined _WIN64
44 
45 // Include Windows API.
46 # ifndef WIN32_LEAN_AND_MEAN
47 # define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
48 # endif
49 # include <sdkddkver.h> // Minimum supported version. See http://msdn.microsoft.com/en-us/library/windows/desktop/aa383745.aspx
50 # include <windows.h>
51 # if defined(WINAPI_FAMILY)
52 # if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) // Windows Phone 8.1 and later.
53 # if (_WIN32_WINNT >= 0x0603) // (_WIN32_WINNT_WINBLUE)
54 # define TARGET_PLATFORM_WINRT 1
55 # else
56 # error ARToolKit for Windows Phone requires Windows Phone 8.1 or later. Please compile with Visual Studio 2013 or later with Windows Phone 8.1 SDK installed and with _WIN32_WINNT=0x0603 in your project compiler settings (setting /D_WIN32_WINNT=0x0603).
57 # endif
58 # elif (WINAPI_FAMILY == WINAPI_FAMILY_PC_APP) // Windows Store 8.1 and later.
59 # if (_WIN32_WINNT >= 0x0603) // (_WIN32_WINNT_WINBLUE)
60 # define TARGET_PLATFORM_WINRT 1
61 # else
62 # error ARToolKit for Windows Store requires Windows 8.1 or later. Please compile with Visual Studio 2013 or later with Windows 8.1 SDK installed and with _WIN32_WINNT=0x0603 in your project compiler settings (setting /D_WIN32_WINNT=0x0603).
63 # endif
64 # else
65 # define TARGET_PLATFORM_WINDOWS 1
66 # endif
67 # else
68 # define TARGET_PLATFORM_WINDOWS 1
69 # endif
70 
71 #elif __APPLE__
72 
73 # include <TargetConditionals.h>
74 # include <AvailabilityMacros.h>
75 # if TARGET_IPHONE_SIMULATOR
76 # elif TARGET_OS_IPHONE
77 # define TARGET_PLATFORM_IOS 1
78 # elif TARGET_OS_MAC
79 # define TARGET_PLATFORM_OSX 1
80 # endif
81 
82 #elif defined ANDROID
83 
84 # define TARGET_PLATFORM_ANDROID 1
85 
86 #elif __linux__
87 
88 # define TARGET_PLATFORM_LINUX 1
89 
90 #else
91 
92 # error Unsupported platform.
93 
94 #endif
95 
96 // Configure preprocessor definitions for current platform
97 
98 #if TARGET_PLATFORM_WINDOWS
99 
100 # define EXPORT_API __declspec(dllexport)
101 # define CALL_CONV __stdcall
102 # define LOGI(...) fprintf(stdout, __VA_ARGS__)
103 # define LOGE(...) fprintf(stderr, __VA_ARGS__)
104 
105 #elif TARGET_PLATFORM_WINRT
106 
107 # ifndef LIBARWRAPPER_STATIC
108 # ifdef LIBARWRAPPER_EXPORTS
109 # define EXPORT_API __declspec(dllexport)
110 # else
111 # define EXPORT_API __declspec(dllimport)
112 # endif
113 # else
114 # define EXPORT_API extern
115 # endif
116 # define CALL_CONV __stdcall
117 # define LOGI(...) fprintf(stdout, __VA_ARGS__)
118 # define LOGE(...) fprintf(stderr, __VA_ARGS__)
119 
120 #elif TARGET_PLATFORM_OSX || TARGET_PLATFORM_IOS || TARGET_PLATFORM_LINUX
121 
122 # define EXPORT_API
123 # define CALL_CONV
124 # define LOGI(...) fprintf(stdout, __VA_ARGS__)
125 # define LOGE(...) fprintf(stderr, __VA_ARGS__)
126 
127 #elif TARGET_PLATFORM_ANDROID
128 
129 # define EXPORT_API
130 # define CALL_CONV
131 # define LOGI(...) __android_log_print(ANDROID_LOG_INFO,"libARWrapper",__VA_ARGS__)
132 # define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,"libARWrapper",__VA_ARGS__)
133 
134 // Utility preprocessor directive so only one change needed if Java class name changes
135 # define JNIFUNCTION(sig) Java_org_artoolkit_ar_base_NativeInterface_##sig
136 
137 #endif
138 
139 typedef void (CALL_CONV *PFN_LOGCALLBACK)(const char* msg);
140 
141 
142 #endif // !PLATFORM_H