2012-03-15 23:58:37 +00:00
|
|
|
//
|
|
|
|
|
// KREngine-common.h
|
|
|
|
|
// KREngine
|
|
|
|
|
//
|
|
|
|
|
// Created by Kearwood Gilbert on 12-03-15.
|
|
|
|
|
// Copyright (c) 2012 Kearwood Software. All rights reserved.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-12-20 22:08:41 +00:00
|
|
|
#ifndef KRENGINE_COMMON_H
|
|
|
|
|
#define KRENGINE_COMMON_H
|
2012-03-15 23:58:37 +00:00
|
|
|
|
2012-10-19 23:17:43 +00:00
|
|
|
#define KRENGINE_MAX_TEXTURE_UNITS 8
|
|
|
|
|
|
2012-12-20 22:08:41 +00:00
|
|
|
float const PI = 3.141592653589793f;
|
|
|
|
|
float const D2R = PI * 2 / 360;
|
|
|
|
|
|
2013-01-11 03:21:19 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <set>
|
|
|
|
|
#include <list>
|
|
|
|
|
#include <map>
|
|
|
|
|
#include <stack>
|
|
|
|
|
#include <queue>
|
|
|
|
|
#include <iostream>
|
|
|
|
|
#include <sstream>
|
|
|
|
|
#include <fstream>
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <sys/mman.h>
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
#include <time.h>
|
|
|
|
|
#include <limits>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <iostream>
|
|
|
|
|
#include <math.h>
|
|
|
|
|
|
2013-01-24 13:52:26 -08:00
|
|
|
#include <boost/tokenizer.hpp>
|
|
|
|
|
#include <boost/algorithm/string/predicate.hpp>
|
|
|
|
|
|
2013-01-11 03:21:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
using std::vector;
|
|
|
|
|
using std::string;
|
|
|
|
|
using std::set;
|
|
|
|
|
using std::list;
|
|
|
|
|
using std::map;
|
|
|
|
|
using std::stack;
|
|
|
|
|
using std::queue;
|
2012-03-15 23:58:37 +00:00
|
|
|
|
|
|
|
|
#ifdef __APPLE__
|
|
|
|
|
#include "TargetConditionals.h"
|
2013-01-11 03:21:19 +00:00
|
|
|
#include <Accelerate/Accelerate.h>
|
2012-03-15 23:58:37 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if TARGET_OS_IPHONE
|
|
|
|
|
|
2013-01-11 03:21:19 +00:00
|
|
|
#include <OpenGLES/ES2/gl.h>
|
|
|
|
|
#include <OpenGLES/ES2/glext.h>
|
2012-03-15 23:58:37 +00:00
|
|
|
|
2012-10-25 03:15:28 +00:00
|
|
|
|
2012-03-15 23:58:37 +00:00
|
|
|
#else
|
|
|
|
|
|
2013-01-11 03:21:19 +00:00
|
|
|
#include <OpenGL/gl3.h>
|
|
|
|
|
#include <OpenGL/gl3ext.h>
|
2012-12-28 06:25:57 +00:00
|
|
|
|
|
|
|
|
// OpenGL ES 2.0 mapping to OpenGL 3.2 mappings
|
|
|
|
|
#define glDepthRangef glDepthRange
|
|
|
|
|
#define glClearDepthf glClearDepth
|
|
|
|
|
#define glDeleteQueriesEXT glDeleteQueries
|
|
|
|
|
#define glGenQueriesEXT glGenQueries
|
|
|
|
|
#define glBeginQueryEXT glBeginQuery
|
|
|
|
|
#define glEndQueryEXT glEndQuery
|
|
|
|
|
#define glGetQueryObjectuivEXT glGetQueryObjectuiv
|
|
|
|
|
#define GL_ANY_SAMPLES_PASSED_EXT GL_ANY_SAMPLES_PASSED
|
|
|
|
|
#define GL_QUERY_RESULT_EXT GL_QUERY_RESULT
|
2012-03-15 23:58:37 +00:00
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
2013-01-11 03:21:19 +00:00
|
|
|
#include <AudioToolbox/AudioToolbox.h>
|
|
|
|
|
#include <AudioToolbox/AudioFile.h>
|
|
|
|
|
#include <AudioToolbox/ExtendedAudioFile.h>
|
|
|
|
|
#include <OpenAL/al.h>
|
|
|
|
|
#include <OpenAL/alc.h>
|
2013-01-09 22:37:23 +00:00
|
|
|
#if TARGET_OS_IPHONE
|
2013-01-11 03:21:19 +00:00
|
|
|
#include <OpenAL/oalMacOSX_OALExtensions.h>
|
2013-01-09 22:37:23 +00:00
|
|
|
#else
|
2013-01-11 03:21:19 +00:00
|
|
|
#include <OpenAL/MacOSX_OALExtensions.h>
|
2013-01-09 22:37:23 +00:00
|
|
|
#endif
|
2012-03-15 23:58:37 +00:00
|
|
|
|
|
|
|
|
#endif
|
2012-09-13 20:09:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
#define GLDEBUG(x) \
|
|
|
|
|
x; \
|
|
|
|
|
{ \
|
|
|
|
|
GLenum e; \
|
|
|
|
|
while( (e=glGetError()) != GL_NO_ERROR) \
|
|
|
|
|
{ \
|
|
|
|
|
fprintf(stderr, "Error at line number %d, in file %s. glGetError() returned %i for call %s\n",__LINE__, __FILE__, e, #x ); \
|
|
|
|
|
} \
|
2012-12-20 22:08:41 +00:00
|
|
|
}
|
|
|
|
|
|
2013-01-23 12:43:43 -08:00
|
|
|
#define ALDEBUG(x) \
|
|
|
|
|
x; \
|
|
|
|
|
{ \
|
|
|
|
|
GLenum e; \
|
|
|
|
|
while( (e=alGetError()) != AL_NO_ERROR) \
|
|
|
|
|
{ \
|
|
|
|
|
fprintf(stderr, "Error at line number %d, in file %s. alGetError() returned %i for call %s\n",__LINE__, __FILE__, e, #x ); \
|
|
|
|
|
} \
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2013-01-05 04:04:58 +00:00
|
|
|
#define KRMIN(x,y) ((x) < (y) ? (x) : (y))
|
|
|
|
|
#define KRMAX(x,y) ((x) > (y) ? (x) : (y))
|
2013-01-24 23:57:55 -08:00
|
|
|
#define KRALIGN(x) ((x + 3) & ~0x03)
|
2012-12-20 22:08:41 +00:00
|
|
|
|
|
|
|
|
#include "KRVector3.h"
|
|
|
|
|
#include "KRVector2.h"
|