source: trunk/src/core.h @ 2274

Last change on this file since 2274 was 2274, checked in by sam, 8 years ago

build: provide weak symbols for lol_sdl_main on Visual Studio.

  • Property svn:keywords set to Id
File size: 4.2 KB
Line 
1//
2// Lol Engine
3//
4// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net>
5//   This program is free software; you can redistribute it and/or
6//   modify it under the terms of the Do What The Fuck You Want To
7//   Public License, Version 2, as published by Sam Hocevar. See
8//   http://www.wtfpl.net/ for more details.
9//
10
11//
12// The main header
13// ---------------
14//
15
16#if !defined __LOL_CORE_H__
17#define __LOL_CORE_H__
18
19// CPU features
20#undef LOL_FEATURE_CHEAP_BRANCHES
21#undef LOL_FEATURE_VERY_CHEAP_BRANCHES
22
23#if !defined __CELLOS_LV2__
24#   define LOL_FEATURE_CHEAP_BRANCHES
25#endif
26
27// Optimisation helpers
28#if defined __GNUC__
29#   define __likely(x)   __builtin_expect(!!(x), 1)
30#   define __unlikely(x) __builtin_expect(!!(x), 0)
31#   define INLINEATTR __attribute__((always_inline))
32#   if defined __CELLOS_LV2__ && !defined __SNC__
33#      define FP_USE(x) __asm__("" : "+f" (x))
34#   elif defined __x86_64__
35#      define FP_USE(x) __asm__("" : "+x" (x))
36#   elif defined __i386__ /* FIXME: this isn't good */
37#      define FP_USE(x) __asm__("" : "+m" (x))
38#   else
39#      define FP_USE(x) (void)(x)
40#   endif
41#else
42#   define __likely(x)   x
43#   define __unlikely(x) x
44#   define INLINEATTR
45#   define FP_USE(x) (void)(x)
46#endif
47
48/* Ensure isnan() is present even on systems that don't define it, or
49 * when -ffast-math is being used. */
50#include <cmath>
51#if defined __FAST_MATH__
52#   undef isnan
53#endif
54#if !defined isnan
55#   define isnan isnan
56#   include <stdint.h>
57static inline int isnan(float f)
58{
59    union { float f; uint32_t x; } u = { f };
60    return (u.x << 1) > 0xff000000u;
61}
62#endif
63
64/* If using NaCl or Android, override main() with our version */
65#if defined __native_client__
66#   define main lol_nacl_main
67#elif defined __ANDROID__
68#   define main lol_android_main
69#endif
70
71/* If using SDL, let it override main() but immediately replace
72 * the override with ours, then declare weak symbols to ensure one
73 * of our dummy functions gets replaced by the user's main(). */
74#if defined USE_SDL
75#   include <SDL_main.h>
76#   if defined main && !LOL_DONT_DIVERT_MAIN
77#       undef main
78#       define main lol_sdl_main
79#       if defined _MSC_VER
80int lol_sdl_main();
81int lol_sdl_main_msvc();
82#pragma comment(linker, "/alternatename:?lol_sdl_main@@YAHXZ" \
83                                      "=?lol_sdl_main_msvc@@YAHXZ")
84int lol_sdl_main(int argc, char **argv);
85int lol_sdl_main_msvc(int argc, char **argv);
86#pragma comment(linker, "/alternatename:?lol_sdl_main@@YAHHPEAPEAD@Z" \
87                                      "=?lol_sdl_main_msvc@@YAHHPEAPEAD@Z")
88int lol_sdl_main(int argc, char **argv, char **envp);
89int lol_sdl_main_msvc(int argc, char **argv, char **envp);
90#pragma comment(linker, "/alternatename:?lol_sdl_main@@YAHHPEAPEAD0@Z" \
91                                      "=?lol_sdl_main_msvc@@YAHHPEAPEAD0@Z")
92#       endif
93#   endif
94#endif
95
96// Base types
97#include <lol/base/types.h>
98#include <lol/base/log.h>
99#include <lol/base/assert.h>
100#include <lol/base/array.h>
101#include <lol/base/string.h>
102#include <lol/base/hash.h>
103#include <lol/base/map.h>
104
105#include <lol/math/math.h>
106#include <lol/math/half.h>
107#include <lol/math/real.h>
108#include <lol/math/vector.h>
109#include <lol/math/geometry.h>
110
111#include <lol/sys/init.h>
112#include <lol/sys/thread.h>
113#include <lol/sys/timer.h>
114
115#include <lol/image/color.h>
116
117#include "numeric.h"
118
119// Static classes
120#include "platform.h"
121#include "video.h"
122#include "audio.h"
123#include "scene.h"
124#include "input/input.h"
125#include "input/keyboard.h"
126#include "input/stick.h"
127#include "profiler.h"
128
129// Entities
130#include "entity.h"
131#include "worldentity.h"
132
133#include "camera.h"
134#include "emitter.h"
135#include "font.h"
136#include "gradient.h"
137#include "sample.h"
138#include "sprite.h"
139#include "text.h"
140#include "tileset.h"
141#include "world.h"
142
143// Other objects
144#include "dict.h"
145#include "map.h"
146#include "layer.h"
147#include "gpu/lolfx.h"
148#include "gpu/shader.h"
149#include "gpu/texture.h"
150#include "gpu/indexbuffer.h"
151#include "gpu/vertexbuffer.h"
152#include "gpu/framebuffer.h"
153#include "mesh/mesh.h"
154#include "image/image.h"
155#include "application/application.h"
156#include "easymesh/csgbsp.h"
157#include "easymesh/easymesh.h"
158
159// Managers
160#include "ticker.h"
161#include "forge.h"
162#include "tiler.h"
163#include "sampler.h"
164
165#endif // __LOL_CORE_H__
166
Note: See TracBrowser for help on using the repository browser.