MacOS X targets for Scons, Fix some inlines for clang
This commit is contained in:
parent
8d9b351568
commit
25d872ec48
29
SConscript
29
SConscript
@ -110,9 +110,10 @@ if not conf.CheckCHeader("bzlib.h"):
|
||||
raise SystemExit(1)
|
||||
|
||||
#Check for Lua lib
|
||||
if not conf.CheckLib('lua') and not conf.CheckLib('lua5.1') and not conf.CheckLib('lua51') and not conf.CheckLib('lua-5.1'):
|
||||
print "liblua not found or not installed"
|
||||
raise SystemExit(1)
|
||||
if not GetOption("macosx"):
|
||||
if not conf.CheckLib('lua') and not conf.CheckLib('lua5.1') and not conf.CheckLib('lua51') and not conf.CheckLib('lua-5.1'):
|
||||
print "liblua not found or not installed"
|
||||
raise SystemExit(1)
|
||||
|
||||
env = conf.Finish();
|
||||
|
||||
@ -150,11 +151,27 @@ if(GetOption('lin')):
|
||||
env.Append(CCFLAGS=['-m32'])
|
||||
if(GetOption('macosx')):
|
||||
env.Append(CPPDEFINES=["MACOSX"])
|
||||
env.Append(CCFLAGS=['-I/Library/Frameworks/SDL.framework/Headers'])
|
||||
env.Append(CCFLAGS=['-I/Library/Frameworks/Lua.framework/Headers'])
|
||||
env.Append(LINKFLAGS=['-lfftw3f'])
|
||||
env.Append(LINKFLAGS=['-framework'])
|
||||
env.Append(LINKFLAGS=['SDL'])
|
||||
env.Append(LINKFLAGS=['-framework'])
|
||||
env.Append(LINKFLAGS=['Lua'])
|
||||
env.Append(LINKFLAGS=['-framework']);
|
||||
env.Append(LINKFLAGS=['Cocoa'])
|
||||
#env.Append(LINKFLAGS=['-framework SDL'])
|
||||
#env.Append(LINKFLAGS=['-framework Lua'])
|
||||
#env.Append(LINKFLAGS=['-framework Cocoa'])
|
||||
if GetOption('_64bit'):
|
||||
env.Append(LINKFAGS=['-m64'])
|
||||
env.Append(CCFLAGS=['-m64'])
|
||||
else:
|
||||
env.Append(LINKFLAGS=['-m32'])
|
||||
env.Append(CCFLAGS=['-m32'])
|
||||
|
||||
if GetOption('_64bit'):
|
||||
env.Append(CPPDEFINES=["_64BIT"])
|
||||
env.Append(CCFLAGS=['-I/Library/Frameworks/SDL.framework/Headers -I/Library/Frameworks/Lua.framework/Headers'])
|
||||
env.Append(LINKFLAGS=['-lfftw3f -framework SDL -framework Lua -framework Cocoa'])
|
||||
|
||||
if(GetOption('beta')):
|
||||
env.Append(CPPDEFINES='BETA')
|
||||
@ -209,6 +226,8 @@ elif(GetOption('opengl-renderer')):
|
||||
raise SystemExit(1)
|
||||
|
||||
sources=Glob("src/*.cpp")
|
||||
if(GetOption('macosx')):
|
||||
sources +=["SDLMain.m"]
|
||||
if(GetOption('win')):
|
||||
sources += env.RES('resources/powder-res.rc')
|
||||
sources+=Glob("src/*/*.cpp")
|
||||
|
@ -191,7 +191,10 @@ extern unsigned char ZSIZE;
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define TPT_INLINE _inline
|
||||
#define TPT_NO_INLINE //Remove inlines in visual studio, but only the ones that don't work
|
||||
#define TPT_NO_INLINE
|
||||
#elif defined(__llvm__)
|
||||
#define TPT_INLINE
|
||||
#define TPT_NO_INLINE
|
||||
#else
|
||||
#define TPT_INLINE inline
|
||||
#define TPT_NO_INLINE inline
|
||||
|
@ -34,13 +34,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//#include <iterator>
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define TPT_NO_INLINE //Remove inlines in visual studio, but only the ones that don't work
|
||||
#else
|
||||
#define TPT_NO_INLINE inline
|
||||
#endif
|
||||
|
||||
#include "Config.h"
|
||||
/*
|
||||
|
||||
TODO:
|
||||
|
@ -14,10 +14,10 @@
|
||||
ThumbnailBroker::ThumbnailBroker()
|
||||
{
|
||||
thumbnailQueueRunning = false;
|
||||
thumbnailQueueMutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
//thumbnailQueueMutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
pthread_mutex_init (&thumbnailQueueMutex, NULL);
|
||||
|
||||
listenersMutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
//listenersMutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
pthread_mutex_init (&listenersMutex, NULL);
|
||||
}
|
||||
|
||||
|
@ -34,8 +34,20 @@ GameModel::GameModel():
|
||||
sim = new Simulation();
|
||||
ren = new Renderer(ui::Engine::Ref().g, sim);
|
||||
|
||||
std::fill(activeTools, activeTools+3, (Tool*)NULL);
|
||||
|
||||
std::fill(activeTools, activeTools+3, (Tool*)NULL);
|
||||
|
||||
//Default render prefs
|
||||
std::vector<unsigned int> tempArray;
|
||||
tempArray.push_back(RENDER_FIRE);
|
||||
tempArray.push_back(RENDER_EFFE);
|
||||
tempArray.push_back(RENDER_BASC);
|
||||
ren->SetRenderMode(tempArray);
|
||||
tempArray.clear();
|
||||
|
||||
ren->SetDisplayMode(tempArray);
|
||||
|
||||
ren->SetColourMode(0);
|
||||
|
||||
//Load config into renderer
|
||||
try
|
||||
{
|
||||
@ -60,7 +72,6 @@ GameModel::GameModel():
|
||||
}
|
||||
catch(json::Exception & e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//Load config into simulation
|
||||
|
@ -32,71 +32,7 @@ VideoBuffer::VideoBuffer(VideoBuffer * old):
|
||||
std::copy(old->Buffer, old->Buffer+(old->Width*old->Height), Buffer);
|
||||
};
|
||||
|
||||
VideoBuffer::~VideoBuffer()
|
||||
{
|
||||
delete[] Buffer;
|
||||
};
|
||||
|
||||
TPT_INLINE void VideoBuffer::BlendPixel(int x, int y, int r, int g, int b, int a)
|
||||
{
|
||||
#ifdef PIX32OGL
|
||||
pixel t;
|
||||
if (x<0 || y<0 || x>=Width || y>=Height)
|
||||
return;
|
||||
if (a!=255)
|
||||
{
|
||||
t = Buffer[y*(Width)+x];
|
||||
r = (a*r + (255-a)*PIXR(t)) >> 8;
|
||||
g = (a*g + (255-a)*PIXG(t)) >> 8;
|
||||
b = (a*b + (255-a)*PIXB(t)) >> 8;
|
||||
a = a > PIXA(t) ? a : PIXA(t);
|
||||
}
|
||||
Buffer[y*(Width)+x] = PIXRGBA(r,g,b,a);
|
||||
#else
|
||||
pixel t;
|
||||
if (x<0 || y<0 || x>=Width || y>=Height)
|
||||
return;
|
||||
if (a!=255)
|
||||
{
|
||||
t = Buffer[y*(Width)+x];
|
||||
r = (a*r + (255-a)*PIXR(t)) >> 8;
|
||||
g = (a*g + (255-a)*PIXG(t)) >> 8;
|
||||
b = (a*b + (255-a)*PIXB(t)) >> 8;
|
||||
}
|
||||
Buffer[y*(Width)+x] = PIXRGB(r,g,b);
|
||||
#endif
|
||||
}
|
||||
|
||||
TPT_INLINE void VideoBuffer::SetPixel(int x, int y, int r, int g, int b, int a)
|
||||
{
|
||||
if (x<0 || y<0 || x>=Width || y>=Height)
|
||||
return;
|
||||
#ifdef PIX32OGL
|
||||
Buffer[y*(Width)+x] = PIXRGBA(r,g,b,a);
|
||||
#else
|
||||
Buffer[y*(Width)+x] = PIXRGB((r*a)>>8, (g*a)>>8, (b*a)>>8);
|
||||
#endif
|
||||
}
|
||||
|
||||
TPT_INLINE void VideoBuffer::AddPixel(int x, int y, int r, int g, int b, int a)
|
||||
{
|
||||
pixel t;
|
||||
if (x<0 || y<0 || x>=Width || y>=Height)
|
||||
return;
|
||||
t = Buffer[y*(Width)+x];
|
||||
r = (a*r + 255*PIXR(t)) >> 8;
|
||||
g = (a*g + 255*PIXG(t)) >> 8;
|
||||
b = (a*b + 255*PIXB(t)) >> 8;
|
||||
if (r>255)
|
||||
r = 255;
|
||||
if (g>255)
|
||||
g = 255;
|
||||
if (b>255)
|
||||
b = 255;
|
||||
Buffer[y*(Width)+x] = PIXRGB(r,g,b);
|
||||
}
|
||||
|
||||
TPT_NO_INLINE int VideoBuffer::SetCharacter(int x, int y, int c, int r, int g, int b, int a)
|
||||
int VideoBuffer::SetCharacter(int x, int y, int c, int r, int g, int b, int a)
|
||||
{
|
||||
int i, j, w, bn = 0, ba = 0;
|
||||
char *rp = font_data + font_ptrs[c];
|
||||
@ -116,7 +52,7 @@ TPT_NO_INLINE int VideoBuffer::SetCharacter(int x, int y, int c, int r, int g, i
|
||||
return x + w;
|
||||
}
|
||||
|
||||
TPT_NO_INLINE int VideoBuffer::BlendCharacter(int x, int y, int c, int r, int g, int b, int a)
|
||||
int VideoBuffer::BlendCharacter(int x, int y, int c, int r, int g, int b, int a)
|
||||
{
|
||||
int i, j, w, bn = 0, ba = 0;
|
||||
char *rp = font_data + font_ptrs[c];
|
||||
@ -136,7 +72,7 @@ TPT_NO_INLINE int VideoBuffer::BlendCharacter(int x, int y, int c, int r, int g,
|
||||
return x + w;
|
||||
}
|
||||
|
||||
TPT_NO_INLINE int VideoBuffer::AddCharacter(int x, int y, int c, int r, int g, int b, int a)
|
||||
int VideoBuffer::AddCharacter(int x, int y, int c, int r, int g, int b, int a)
|
||||
{
|
||||
int i, j, w, bn = 0, ba = 0;
|
||||
char *rp = font_data + font_ptrs[c];
|
||||
@ -156,6 +92,11 @@ TPT_NO_INLINE int VideoBuffer::AddCharacter(int x, int y, int c, int r, int g, i
|
||||
return x + w;
|
||||
}
|
||||
|
||||
VideoBuffer::~VideoBuffer()
|
||||
{
|
||||
delete[] Buffer;
|
||||
};
|
||||
|
||||
/**
|
||||
* Common graphics functions, mostly static methods that provide
|
||||
* encoding/decoding of different formats and font metrics
|
||||
|
@ -95,12 +95,67 @@ public:
|
||||
VideoBuffer(const VideoBuffer & old);
|
||||
VideoBuffer(VideoBuffer * old);
|
||||
VideoBuffer(int width, int height);
|
||||
void BlendPixel(int x, int y, int r, int g, int b, int a);
|
||||
void AddPixel(int x, int y, int r, int g, int b, int a);
|
||||
void SetPixel(int x, int y, int r, int g, int b, int a);
|
||||
TPT_INLINE void BlendPixel(int x, int y, int r, int g, int b, int a)
|
||||
{
|
||||
#ifdef PIX32OGL
|
||||
pixel t;
|
||||
if (x<0 || y<0 || x>=Width || y>=Height)
|
||||
return;
|
||||
if (a!=255)
|
||||
{
|
||||
t = Buffer[y*(Width)+x];
|
||||
r = (a*r + (255-a)*PIXR(t)) >> 8;
|
||||
g = (a*g + (255-a)*PIXG(t)) >> 8;
|
||||
b = (a*b + (255-a)*PIXB(t)) >> 8;
|
||||
a = a > PIXA(t) ? a : PIXA(t);
|
||||
}
|
||||
Buffer[y*(Width)+x] = PIXRGBA(r,g,b,a);
|
||||
#else
|
||||
pixel t;
|
||||
if (x<0 || y<0 || x>=Width || y>=Height)
|
||||
return;
|
||||
if (a!=255)
|
||||
{
|
||||
t = Buffer[y*(Width)+x];
|
||||
r = (a*r + (255-a)*PIXR(t)) >> 8;
|
||||
g = (a*g + (255-a)*PIXG(t)) >> 8;
|
||||
b = (a*b + (255-a)*PIXB(t)) >> 8;
|
||||
}
|
||||
Buffer[y*(Width)+x] = PIXRGB(r,g,b);
|
||||
#endif
|
||||
}
|
||||
|
||||
TPT_INLINE void SetPixel(int x, int y, int r, int g, int b, int a)
|
||||
{
|
||||
if (x<0 || y<0 || x>=Width || y>=Height)
|
||||
return;
|
||||
#ifdef PIX32OGL
|
||||
Buffer[y*(Width)+x] = PIXRGBA(r,g,b,a);
|
||||
#else
|
||||
Buffer[y*(Width)+x] = PIXRGB((r*a)>>8, (g*a)>>8, (b*a)>>8);
|
||||
#endif
|
||||
}
|
||||
|
||||
TPT_INLINE void AddPixel(int x, int y, int r, int g, int b, int a)
|
||||
{
|
||||
pixel t;
|
||||
if (x<0 || y<0 || x>=Width || y>=Height)
|
||||
return;
|
||||
t = Buffer[y*(Width)+x];
|
||||
r = (a*r + 255*PIXR(t)) >> 8;
|
||||
g = (a*g + 255*PIXG(t)) >> 8;
|
||||
b = (a*b + 255*PIXB(t)) >> 8;
|
||||
if (r>255)
|
||||
r = 255;
|
||||
if (g>255)
|
||||
g = 255;
|
||||
if (b>255)
|
||||
b = 255;
|
||||
Buffer[y*(Width)+x] = PIXRGB(r,g,b);
|
||||
}
|
||||
int SetCharacter(int x, int y, int c, int r, int g, int b, int a);
|
||||
int BlendCharacter(int x, int y, int c, int r, int g, int b, int a);
|
||||
int AddCharacter(int x, int y, int c, int r, int g, int b, int a);
|
||||
int SetCharacter(int x, int y, int c, int r, int g, int b, int a);
|
||||
~VideoBuffer();
|
||||
};
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "interface/Point.h"
|
||||
#include "interface/Window.h"
|
||||
#include "interface/Panel.h"
|
||||
#include "interface/ContextMenu.h"
|
||||
|
||||
using namespace ui;
|
||||
|
||||
|
@ -129,33 +129,33 @@ public:
|
||||
Snapshot * CreateSnapshot();
|
||||
void Restore(const Snapshot & snap);
|
||||
|
||||
inline int is_blocking(int t, int x, int y);
|
||||
inline int is_boundary(int pt, int x, int y);
|
||||
inline int find_next_boundary(int pt, int *x, int *y, int dm, int *em);
|
||||
inline int pn_junction_sprk(int x, int y, int pt);
|
||||
inline void photoelectric_effect(int nx, int ny);
|
||||
inline unsigned direction_to_map(float dx, float dy, int t);
|
||||
inline int do_move(int i, int x, int y, float nxf, float nyf);
|
||||
inline int try_move(int i, int x, int y, int nx, int ny);
|
||||
inline int eval_move(int pt, int nx, int ny, unsigned *rr);
|
||||
TPT_NO_INLINE int is_blocking(int t, int x, int y);
|
||||
TPT_NO_INLINE int is_boundary(int pt, int x, int y);
|
||||
TPT_NO_INLINE int find_next_boundary(int pt, int *x, int *y, int dm, int *em);
|
||||
TPT_NO_INLINE int pn_junction_sprk(int x, int y, int pt);
|
||||
TPT_NO_INLINE void photoelectric_effect(int nx, int ny);
|
||||
TPT_NO_INLINE unsigned direction_to_map(float dx, float dy, int t);
|
||||
TPT_NO_INLINE int do_move(int i, int x, int y, float nxf, float nyf);
|
||||
TPT_NO_INLINE int try_move(int i, int x, int y, int nx, int ny);
|
||||
TPT_NO_INLINE int eval_move(int pt, int nx, int ny, unsigned *rr);
|
||||
void init_can_move();
|
||||
void create_cherenkov_photon(int pp);
|
||||
void create_gain_photon(int pp);
|
||||
inline void kill_part(int i);
|
||||
TPT_NO_INLINE void kill_part(int i);
|
||||
int flood_prop(int x, int y, size_t propoffset, void * propvalue, StructProperty::PropertyType proptype);
|
||||
int flood_prop_2(int x, int y, size_t propoffset, void * propvalue, StructProperty::PropertyType proptype, int parttype, char * bitmap);
|
||||
int flood_water(int x, int y, int i, int originaly, int check);
|
||||
inline void detach(int i);
|
||||
inline void part_change_type(int i, int x, int y, int t);
|
||||
inline int create_part_add_props(int p, int x, int y, int tv, int rx, int ry);
|
||||
TPT_NO_INLINE void detach(int i);
|
||||
TPT_NO_INLINE void part_change_type(int i, int x, int y, int t);
|
||||
TPT_NO_INLINE int create_part_add_props(int p, int x, int y, int tv, int rx, int ry);
|
||||
//int InCurrentBrush(int i, int j, int rx, int ry);
|
||||
//int get_brush_flags();
|
||||
inline int create_part(int p, int x, int y, int t);
|
||||
inline void delete_part(int x, int y, int flags);
|
||||
TPT_NO_INLINE int create_part(int p, int x, int y, int t);
|
||||
TPT_NO_INLINE void delete_part(int x, int y, int flags);
|
||||
void get_sign_pos(int i, int *x0, int *y0, int *w, int *h);
|
||||
inline int is_wire(int x, int y);
|
||||
inline int is_wire_off(int x, int y);
|
||||
inline void set_emap(int x, int y);
|
||||
TPT_NO_INLINE int is_wire(int x, int y);
|
||||
TPT_NO_INLINE int is_wire_off(int x, int y);
|
||||
TPT_NO_INLINE void set_emap(int x, int y);
|
||||
TPT_NO_INLINE int parts_avg(int ci, int ni, int t);
|
||||
void create_arc(int sx, int sy, int dx, int dy, int midpoints, int variance, int type, int flags);
|
||||
int nearest_part(int ci, int t, int max_d);
|
||||
@ -198,9 +198,9 @@ public:
|
||||
void *transform_save(void *odata, int *size, matrix2d transform, vector2d translate);
|
||||
TPT_NO_INLINE void orbitalparts_get(int block1, int block2, int resblock1[], int resblock2[]);
|
||||
TPT_NO_INLINE void orbitalparts_set(int *block1, int *block2, int resblock1[], int resblock2[]);
|
||||
inline int get_wavelength_bin(int *wm);
|
||||
inline int get_normal(int pt, int x, int y, float dx, float dy, float *nx, float *ny);
|
||||
inline int get_normal_interp(int pt, float x0, float y0, float dx, float dy, float *nx, float *ny);
|
||||
TPT_NO_INLINE int get_wavelength_bin(int *wm);
|
||||
TPT_NO_INLINE int get_normal(int pt, int x, int y, float dx, float dy, float *nx, float *ny);
|
||||
TPT_NO_INLINE int get_normal_interp(int pt, float x0, float y0, float dx, float dy, float *nx, float *ny);
|
||||
void clear_sim();
|
||||
void UpdateParticles();
|
||||
Simulation();
|
||||
|
@ -21,7 +21,7 @@ void Task::Start()
|
||||
done = false;
|
||||
progress = 0;
|
||||
status = "";
|
||||
taskMutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
//taskMutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
before();
|
||||
pthread_mutex_init (&taskMutex, NULL);
|
||||
pthread_create(&doWorkThread, 0, &Task::doWork_helper, this);
|
||||
|
Reference in New Issue
Block a user