Fix various compiler warnings.

This commit is contained in:
Brecht Van Lommel 2015-08-12 22:17:27 +02:00
parent 2a97c17549
commit b098609186
29 changed files with 123 additions and 131 deletions

View File

@ -2781,7 +2781,7 @@ CLEW_FUN_EXPORT PFNCLGETGLCONTEXTINFOKHR __clewGetGLContextInfoKH
#define CLEW_ERROR_ATEXIT_FAILED -2 //!< Error code for failing to queue the closing of the dynamic library to atexit()
//! \brief Load OpenCL dynamic library and set function entry points
int clewInit ();
int clewInit (void);
//! \brief Convert an OpenCL error code to its string equivalent
const char* clewErrorString (cl_int error);

View File

@ -72,7 +72,7 @@ void name(RendererServices *, int id, void *data) \
#define CCLOSURE_PREPARE_STATIC(name, classname) static CCLOSURE_PREPARE(name, classname)
#define CLOSURE_FLOAT3_PARAM(st, fld) \
{ TypeDesc::TypeVector, reckless_offsetof(st, fld), NULL, sizeof(OSL::Vec3) }
{ TypeDesc::TypeVector, (int)reckless_offsetof(st, fld), NULL, sizeof(OSL::Vec3) }
#define TO_VEC3(v) OSL::Vec3(v.x, v.y, v.z)
#define TO_COLOR3(v) OSL::Color3(v.x, v.y, v.z)

View File

@ -172,7 +172,7 @@ int SimulationObject::initializeLbmSimulation(ntlRenderGlobals *glob)
mpLbm->setParticleTracer( mpParts );
if(mpElbeemSettings) {
// set further settings from API struct init
if(mpElbeemSettings->outputPath) this->mOutFilename = string(mpElbeemSettings->outputPath);
this->mOutFilename = string(mpElbeemSettings->outputPath);
mpLbm->initDomainTrafo( mpElbeemSettings->surfaceTrafo );
mpLbm->setSmoothing(1.0 * mpElbeemSettings->surfaceSmoothing, 1.0 * mpElbeemSettings->surfaceSmoothing);
mpLbm->setIsoSubdivs(mpElbeemSettings->surfaceSubdivs);

View File

@ -128,18 +128,9 @@ public:
private:
//void initContextCGLEW()
/** The window containing the OpenGL view */
NSWindow *m_window;
/** The openGL view */
NSOpenGLView *m_openGLView;
const int m_contextProfileMask;
const int m_contextMajorVersion;
const int m_contextMinorVersion;
const int m_contextFlags;
const int m_contextResetNotificationStrategy;
/** The OpenGL drawing context */
NSOpenGLContext *m_openGLContext;

View File

@ -58,16 +58,9 @@ GHOST_ContextCGL::GHOST_ContextCGL(
int contextFlags,
int contextResetNotificationStrategy)
: GHOST_Context(stereoVisual, numOfAASamples),
m_window(window),
m_openGLView(openGLView),
m_contextProfileMask(contextProfileMask),
m_contextMajorVersion(contextMajorVersion),
m_contextMinorVersion(contextMinorVersion),
m_contextFlags(contextFlags),
m_contextResetNotificationStrategy(contextResetNotificationStrategy),
m_openGLContext(nil)
{
assert(window != nil);
assert(openGLView != nil);
}

View File

@ -284,7 +284,7 @@ extern "C" int GHOST_HACK_getFirstFile(char buf[FIRSTFILEBUFLG])
* CocoaAppDelegate
* ObjC object to capture applicationShouldTerminate, and send quit event
**/
@interface CocoaAppDelegate : NSObject {
@interface CocoaAppDelegate : NSObject <NSFileManagerDelegate> {
GHOST_SystemCocoa *systemCocoa;
}
- (void)setSystemCocoa:(GHOST_SystemCocoa *)sysCocoa;

View File

@ -187,7 +187,7 @@ inline MTRand::uint32 MTRand::randInt()
if( left == 0 ) reload();
--left;
register uint32 s1;
uint32 s1;
s1 = *pNext++;
s1 ^= (s1 >> 11);
s1 ^= (s1 << 7) & 0x9d2c5680UL;
@ -232,9 +232,9 @@ inline void MTRand::seed( uint32 *const bigSeed, const uint32 seedLength )
// in each element are discarded.
// Just call seed() if you want to get array from /dev/urandom
initialize(19650218UL);
register int i = 1;
register uint32 j = 0;
register int k = ( (uint32)N > seedLength ? (uint32)N : seedLength );
int i = 1;
uint32 j = 0;
int k = ( (uint32)N > seedLength ? (uint32)N : seedLength );
for( ; k; --k )
{
state[i] =
@ -273,9 +273,9 @@ inline void MTRand::seed()
if( urandom )
{
uint32 bigSeed[N];
register uint32 *s = bigSeed;
register int i = N;
register bool success = true;
uint32 *s = bigSeed;
int i = N;
bool success = true;
while( success && i-- )
success = fread( s++, sizeof(uint32), 1, urandom );
fclose(urandom);
@ -294,9 +294,9 @@ inline void MTRand::initialize( const uint32 seed )
// See Knuth TAOCP Vol 2, 3rd Ed, p.106 for multiplier.
// In previous versions, most significant bits (MSBs) of the seed affect
// only MSBs of the state array. Modified 9 Jan 2002 by Makoto Matsumoto.
register uint32 *s = state;
register uint32 *r = state;
register int i = 1;
uint32 *s = state;
uint32 *r = state;
int i = 1;
*s++ = seed & 0xffffffffUL;
for( ; i < N; ++i )
{
@ -310,8 +310,8 @@ inline void MTRand::reload()
{
// Generate N new values in state
// Made clearer and faster by Matthew Bellew (matthew.bellew@home.com)
register uint32 *p = state;
register int i;
uint32 *p = state;
int i;
for( i = N - M; i--; ++p )
*p = twist( p[M], p[0], p[1] );
for( i = M; --i; ++p )
@ -350,9 +350,9 @@ inline MTRand::uint32 MTRand::hash( time_t t, clock_t c )
inline void MTRand::save( uint32* saveArray ) const
{
register uint32 *sa = saveArray;
register const uint32 *s = state;
register int i = N;
uint32 *sa = saveArray;
const uint32 *s = state;
int i = N;
for( ; i--; *sa++ = *s++ ) {}
*sa = left;
}
@ -360,9 +360,9 @@ inline void MTRand::save( uint32* saveArray ) const
inline void MTRand::load( uint32 *const loadArray )
{
register uint32 *s = state;
register uint32 *la = loadArray;
register int i = N;
uint32 *s = state;
uint32 *la = loadArray;
int i = N;
for( ; i--; *s++ = *la++ ) {}
left = *la;
pNext = &state[N-left];
@ -371,8 +371,8 @@ inline void MTRand::load( uint32 *const loadArray )
inline std::ostream& operator<<( std::ostream& os, const MTRand& mtrand )
{
register const MTRand::uint32 *s = mtrand.state;
register int i = mtrand.N;
const MTRand::uint32 *s = mtrand.state;
int i = mtrand.N;
for( ; i--; os << *s++ << "\t" ) {}
return os << mtrand.left;
}
@ -380,8 +380,8 @@ inline std::ostream& operator<<( std::ostream& os, const MTRand& mtrand )
inline std::istream& operator>>( std::istream& is, MTRand& mtrand )
{
register MTRand::uint32 *s = mtrand.state;
register int i = mtrand.N;
MTRand::uint32 *s = mtrand.state;
int i = mtrand.N;
for( ; i--; is >> *s++ ) {}
is >> mtrand.left;
mtrand.pNext = &mtrand.state[mtrand.N-mtrand.left];

View File

@ -34,8 +34,13 @@
#endif
#if defined(__GNUC__) || defined(__clang__)
#if defined(__cplusplus) && (__cplusplus > 199711L)
#define BLI_array_alloca(arr, realsize) \
(decltype(arr))alloca(sizeof(*arr) * (realsize))
#else
#define BLI_array_alloca(arr, realsize) \
(typeof(arr))alloca(sizeof(*arr) * (realsize))
#endif
#else
#define BLI_array_alloca(arr, realsize) \
alloca(sizeof(*arr) * (realsize))

View File

@ -46,9 +46,9 @@ extern "C" {
# define MINLINE static inline
# if (defined(__APPLE__) && defined(__ppc__))
/* static inline __attribute__ here breaks osx ppc gcc42 build */
# define MALWAYS_INLINE static __attribute__((always_inline))
# define MALWAYS_INLINE static __attribute__((always_inline)) __attribute__((unused))
# else
# define MALWAYS_INLINE static inline __attribute__((always_inline))
# define MALWAYS_INLINE static inline __attribute__((always_inline)) __attribute__((unused))
# endif
# endif
#else

View File

@ -623,9 +623,9 @@ extern "C" {
#else
# if (defined(__APPLE__) && defined(__ppc__))
/* static inline __attribute__ here breaks osx ppc gcc42 build */
# define BLI_INLINE static __attribute__((always_inline))
# define BLI_INLINE static __attribute__((always_inline)) __attribute__((__unused__))
# else
# define BLI_INLINE static inline __attribute__((always_inline))
# define BLI_INLINE static inline __attribute__((always_inline)) __attribute__((__unused__))
# endif
#endif

View File

@ -333,7 +333,8 @@ void BLI_filelist_entry_datetime_to_string(
const struct stat *st, const int64_t ts, const bool compact,
char r_time[FILELIST_DIRENTRY_TIME_LEN], char r_date[FILELIST_DIRENTRY_DATE_LEN])
{
const struct tm *tm = localtime(st ? &st->st_mtime : &ts);
time_t ts_mtime = ts;
const struct tm *tm = localtime(st ? &st->st_mtime : &ts_mtime);
const time_t zero = 0;
/* Prevent impossible dates in windows. */

View File

@ -262,7 +262,7 @@ static BMOpDefine bmo_bisect_edges_def = {
/* slots_in */
{{"edges", BMO_OP_SLOT_ELEMENT_BUF, {BM_EDGE}}, /* input edges */
{"cuts", BMO_OP_SLOT_INT}, /* number of cuts */
{"edge_percents", BMO_OP_SLOT_MAPPING, {BMO_OP_SLOT_SUBTYPE_MAP_FLT}},
{"edge_percents", BMO_OP_SLOT_MAPPING, {(int)BMO_OP_SLOT_SUBTYPE_MAP_FLT}},
{{'\0'}},
},
/* slots_out */
@ -322,7 +322,7 @@ static BMOpDefine bmo_find_doubles_def = {
{{'\0'}},
},
/* slots_out */
{{"targetmap.out", BMO_OP_SLOT_MAPPING, {BMO_OP_SLOT_SUBTYPE_MAP_ELEM}},
{{"targetmap.out", BMO_OP_SLOT_MAPPING, {(int)BMO_OP_SLOT_SUBTYPE_MAP_ELEM}},
{{'\0'}},
},
bmo_find_doubles_exec,
@ -401,7 +401,7 @@ static BMOpDefine bmo_pointmerge_facedata_def = {
"pointmerge_facedata",
/* slots_in */
{{"verts", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT}}, /* input vertices */
{"vert_snap", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT | BMO_OP_SLOT_SUBTYPE_ELEM_IS_SINGLE}}, /* snap vertex */
{"vert_snap", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT | (int)BMO_OP_SLOT_SUBTYPE_ELEM_IS_SINGLE}}, /* snap vertex */
{{'\0'}},
},
{{{'\0'}}}, /* no output */
@ -474,7 +474,7 @@ static BMOpDefine bmo_weld_verts_def = {
"weld_verts",
/* slots_in */
/* maps welded vertices to verts they should weld to */
{{"targetmap", BMO_OP_SLOT_MAPPING, {BMO_OP_SLOT_SUBTYPE_MAP_ELEM}},
{{"targetmap", BMO_OP_SLOT_MAPPING, {(int)BMO_OP_SLOT_SUBTYPE_MAP_ELEM}},
{{'\0'}},
},
{{{'\0'}}}, /* no output */
@ -819,8 +819,8 @@ static BMOpDefine bmo_transform_def = {
static BMOpDefine bmo_object_load_bmesh_def = {
"object_load_bmesh",
/* slots_in */
{{"scene", BMO_OP_SLOT_PTR, {BMO_OP_SLOT_SUBTYPE_PTR_SCENE}},
{"object", BMO_OP_SLOT_PTR, {BMO_OP_SLOT_SUBTYPE_PTR_OBJECT}},
{{"scene", BMO_OP_SLOT_PTR, {(int)BMO_OP_SLOT_SUBTYPE_PTR_SCENE}},
{"object", BMO_OP_SLOT_PTR, {(int)BMO_OP_SLOT_SUBTYPE_PTR_OBJECT}},
{{'\0'}},
},
{{{'\0'}}}, /* no output */
@ -839,9 +839,9 @@ static BMOpDefine bmo_bmesh_to_mesh_def = {
/* slots_in */
{
/* pointer to a mesh structure to fill in */
{"mesh", BMO_OP_SLOT_PTR, {BMO_OP_SLOT_SUBTYPE_PTR_MESH}},
{"mesh", BMO_OP_SLOT_PTR, {(int)BMO_OP_SLOT_SUBTYPE_PTR_MESH}},
/* pointer to an object structure */
{"object", BMO_OP_SLOT_PTR, {BMO_OP_SLOT_SUBTYPE_PTR_OBJECT}},
{"object", BMO_OP_SLOT_PTR, {(int)BMO_OP_SLOT_SUBTYPE_PTR_OBJECT}},
{"skip_tessface", BMO_OP_SLOT_BOOL}, /* don't calculate mfaces */
{{'\0'}},
},
@ -861,9 +861,9 @@ static BMOpDefine bmo_mesh_to_bmesh_def = {
/* slots_in */
{
/* pointer to a Mesh structure */
{"mesh", BMO_OP_SLOT_PTR, {BMO_OP_SLOT_SUBTYPE_PTR_MESH}},
{"mesh", BMO_OP_SLOT_PTR, {(int)BMO_OP_SLOT_SUBTYPE_PTR_MESH}},
/* pointer to an Object structure */
{"object", BMO_OP_SLOT_PTR, {BMO_OP_SLOT_SUBTYPE_PTR_OBJECT}},
{"object", BMO_OP_SLOT_PTR, {(int)BMO_OP_SLOT_SUBTYPE_PTR_OBJECT}},
{"use_shapekey", BMO_OP_SLOT_BOOL}, /* load active shapekey coordinates into verts */
{{'\0'}},
},
@ -1035,7 +1035,7 @@ static BMOpDefine bmo_extrude_face_region_def = {
"extrude_face_region",
/* slots_in */
{{"geom", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT | BM_EDGE | BM_FACE}}, /* edges and faces */
{"edges_exclude", BMO_OP_SLOT_MAPPING, {BMO_OP_SLOT_SUBTYPE_MAP_EMPTY}},
{"edges_exclude", BMO_OP_SLOT_MAPPING, {(int)BMO_OP_SLOT_SUBTYPE_MAP_EMPTY}},
{"use_keep_orig", BMO_OP_SLOT_BOOL}, /* keep original geometry */
{"use_select_history", BMO_OP_SLOT_BOOL}, /* pass to duplicate */
{{'\0'}},
@ -1170,7 +1170,7 @@ static BMOpDefine bmo_triangulate_def = {
/* slots_out */
{{"edges.out", BMO_OP_SLOT_ELEMENT_BUF, {BM_EDGE}},
{"faces.out", BMO_OP_SLOT_ELEMENT_BUF, {BM_FACE}},
{"face_map.out", BMO_OP_SLOT_MAPPING, {BMO_OP_SLOT_SUBTYPE_MAP_ELEM}},
{"face_map.out", BMO_OP_SLOT_MAPPING, {(int)BMO_OP_SLOT_SUBTYPE_MAP_ELEM}},
{{'\0'}},
},
bmo_triangulate_exec,
@ -1215,8 +1215,8 @@ static BMOpDefine bmo_subdivide_edges_def = {
{"along_normal", BMO_OP_SLOT_FLT},
{"cuts", BMO_OP_SLOT_INT},
{"seed", BMO_OP_SLOT_INT},
{"custom_patterns", BMO_OP_SLOT_MAPPING, {BMO_OP_SLOT_SUBTYPE_MAP_INTERNAL}}, /* uses custom pointers */
{"edge_percents", BMO_OP_SLOT_MAPPING, {BMO_OP_SLOT_SUBTYPE_MAP_FLT}},
{"custom_patterns", BMO_OP_SLOT_MAPPING, {(int)BMO_OP_SLOT_SUBTYPE_MAP_INTERNAL}}, /* uses custom pointers */
{"edge_percents", BMO_OP_SLOT_MAPPING, {(int)BMO_OP_SLOT_SUBTYPE_MAP_FLT}},
{"quad_corner_type", BMO_OP_SLOT_INT}, /* quad corner type, see bmesh_operators.h */
{"use_grid_fill", BMO_OP_SLOT_BOOL}, /* fill in fully-selected faces with a grid */
@ -1322,7 +1322,7 @@ static BMOpDefine bmo_duplicate_def = {
/* slots_in */
{{"geom", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT | BM_EDGE | BM_FACE}},
/* destination bmesh, if NULL will use current on */
{"dest", BMO_OP_SLOT_PTR, {BMO_OP_SLOT_SUBTYPE_PTR_BMESH}},
{"dest", BMO_OP_SLOT_PTR, {(int)BMO_OP_SLOT_SUBTYPE_PTR_BMESH}},
{"use_select_history", BMO_OP_SLOT_BOOL},
{{'\0'}},
},
@ -1331,11 +1331,11 @@ static BMOpDefine bmo_duplicate_def = {
{"geom.out", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT | BM_EDGE | BM_FACE}},
/* facemap maps from source faces to dupe
* faces, and from dupe faces to source faces */
{"vert_map.out", BMO_OP_SLOT_MAPPING, {BMO_OP_SLOT_SUBTYPE_MAP_ELEM}},
{"edge_map.out", BMO_OP_SLOT_MAPPING, {BMO_OP_SLOT_SUBTYPE_MAP_ELEM}},
{"face_map.out", BMO_OP_SLOT_MAPPING, {BMO_OP_SLOT_SUBTYPE_MAP_ELEM}},
{"boundary_map.out", BMO_OP_SLOT_MAPPING, {BMO_OP_SLOT_SUBTYPE_MAP_ELEM}},
{"isovert_map.out", BMO_OP_SLOT_MAPPING, {BMO_OP_SLOT_SUBTYPE_MAP_ELEM}},
{"vert_map.out", BMO_OP_SLOT_MAPPING, {(int)BMO_OP_SLOT_SUBTYPE_MAP_ELEM}},
{"edge_map.out", BMO_OP_SLOT_MAPPING, {(int)BMO_OP_SLOT_SUBTYPE_MAP_ELEM}},
{"face_map.out", BMO_OP_SLOT_MAPPING, {(int)BMO_OP_SLOT_SUBTYPE_MAP_ELEM}},
{"boundary_map.out", BMO_OP_SLOT_MAPPING, {(int)BMO_OP_SLOT_SUBTYPE_MAP_ELEM}},
{"isovert_map.out", BMO_OP_SLOT_MAPPING, {(int)BMO_OP_SLOT_SUBTYPE_MAP_ELEM}},
{{'\0'}},
},
bmo_duplicate_exec,
@ -1354,14 +1354,14 @@ static BMOpDefine bmo_split_def = {
/* slots_in */
{{"geom", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT | BM_EDGE | BM_FACE}},
/* destination bmesh, if NULL will use current one */
{"dest", BMO_OP_SLOT_PTR, {BMO_OP_SLOT_SUBTYPE_PTR_BMESH}},
{"dest", BMO_OP_SLOT_PTR, {(int)BMO_OP_SLOT_SUBTYPE_PTR_BMESH}},
{"use_only_faces", BMO_OP_SLOT_BOOL}, /* when enabled. don't duplicate loose verts/edges */
{{'\0'}},
},
/* slots_out */
{{"geom.out", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT | BM_EDGE | BM_FACE}},
{"boundary_map.out", BMO_OP_SLOT_MAPPING, {BMO_OP_SLOT_SUBTYPE_MAP_ELEM}},
{"isovert_map.out", BMO_OP_SLOT_MAPPING, {BMO_OP_SLOT_SUBTYPE_MAP_ELEM}},
{"boundary_map.out", BMO_OP_SLOT_MAPPING, {(int)BMO_OP_SLOT_SUBTYPE_MAP_ELEM}},
{"isovert_map.out", BMO_OP_SLOT_MAPPING, {(int)BMO_OP_SLOT_SUBTYPE_MAP_ELEM}},
{{'\0'}},
},
bmo_split_exec,

View File

@ -273,7 +273,7 @@ void GaussianBlurReferenceOperation::executePixel(float output[4], int x, int y,
float *gausstaby, *gausstabcentx;
int i, j;
float *src;
register float sum, val;
float sum, val;
float rval, gval, bval, aval;
int imgx = getWidth();
int imgy = getHeight();

View File

@ -150,6 +150,7 @@ void RenderLayersBaseProg::executePixelSampled(float output[4], float x, float y
expected_element_size = 4;
}
else {
expected_element_size = 0;
BLI_assert(!"Something horribly wrong just happened");
}
BLI_assert(expected_element_size == actual_element_size);

View File

@ -59,8 +59,6 @@ extern "C" {
/* ****************** */
/* Graphviz Debugging */
static SpinLock lock;
#define NL "\r\n"
/* Only one should be enabled, defines whether graphviz nodes

View File

@ -1095,6 +1095,7 @@ static bool copy_particle_systems_to_object(Scene *scene, Object *ob_from, Parti
break;
default:
/* should not happen */
from_mat = to_mat = NULL;
BLI_assert(false);
break;
}

View File

@ -304,7 +304,7 @@ void fsmenu_insert_entry(struct FSMenu *fsmenu, FSMenuCategory category, const c
for (; tfsm; tfsm = tfsm->next) {
if (STREQ(tfsm->path, fsm_iter->path)) {
if (tfsm->name && tfsm->name[0]) {
if (tfsm->name[0]) {
name = tfsm->name;
}
break;

View File

@ -147,7 +147,7 @@ float Noise::smoothNoise2(Vec2f& vec)
{
int bx0, bx1, by0, by1, b00, b10, b01, b11;
float rx0, rx1, ry0, ry1, *q, sx, sy, a, b, t, u, v;
register int i, j;
int i, j;
SETUP(vec.x(), bx0, bx1, rx0, rx1);
SETUP(vec.y(), by0, by1, ry0, ry1);
@ -186,7 +186,7 @@ float Noise::smoothNoise3(Vec3f& vec)
{
int bx0, bx1, by0, by1, bz0, bz1, b00, b10, b01, b11;
float rx0, rx1, ry0, ry1, rz0, rz1, *q, sy, sz, a, b, c, d, t, u, v;
register int i, j;
int i, j;
SETUP(vec.x(), bx0, bx1, rx0, rx1);
SETUP(vec.y(), by0, by1, ry0, ry1);

View File

@ -419,12 +419,7 @@ Stroke::Stroke(const Stroke& iBrother)
_textureId = iBrother._textureId;
_textureStep = iBrother._textureStep;
for (int a = 0; a < MAX_MTEX; a++) {
if (iBrother._mtex) {
_mtex[a] = iBrother._mtex[a];
}
else {
_mtex[a] = NULL;
}
_mtex[a] = iBrother._mtex[a];
}
_nodeTree = iBrother._nodeTree;
_tips = iBrother._tips;

View File

@ -314,13 +314,13 @@ void GPU_mist_update_values(int type, float start, float dist, float inten, floa
void GPU_horizon_update_color(float color[3]);
void GPU_ambient_update_color(float color[3]);
typedef struct GPUParticleInfo
struct GPUParticleInfo
{
float scalprops[4];
float location[3];
float velocity[3];
float angular_velocity[3];
} GPUParticleInfo;
};
#ifdef WITH_OPENSUBDIV
struct DerivedMesh;

View File

@ -166,7 +166,7 @@ const char* gpuErrorString(GLenum err)
static void APIENTRY gpu_debug_proc(
GLenum source, GLenum type, GLuint UNUSED(id),
GLenum UNUSED(severity), GLsizei UNUSED(length),
const GLchar *message, const GLvoid *UNUSED(userParm))
const GLchar *message, GLvoid *UNUSED(userParm))
{
if (source == GL_DEBUG_SOURCE_API && type == GL_DEBUG_TYPE_ERROR) {
fprintf(stderr, "GL: %s\n", message);

View File

@ -38,6 +38,7 @@
#include <Image.h>
#include <Common.h>
#if 0
// Get approximate luminance.
inline static uint colorLuminance(Color32 c)
{
@ -49,6 +50,7 @@
{
return (c0.r - c1.r) * (c0.r - c1.r) + (c0.g - c1.g) * (c0.g - c1.g) + (c0.b - c1.b) * (c0.b - c1.b);
}
#endif
/// Default constructor.
@ -86,8 +88,8 @@ void ColorBlock::init(const Image *img, uint x, uint y)
void ColorBlock::init(uint w, uint h, const uint *data, uint x, uint y)
{
const uint bw = min(w - x, 4U);
const uint bh = min(h - y, 4U);
const uint bw = MIN(w - x, 4U);
const uint bh = MIN(h - y, 4U);
// Blocks that are smaller than 4x4 are handled by repeating the pixels.
// @@ Thats only correct when block size is 1, 2 or 4, but not with 3. :(
@ -107,8 +109,8 @@ void ColorBlock::init(uint w, uint h, const uint *data, uint x, uint y)
void ColorBlock::init(uint w, uint h, const float *data, uint x, uint y)
{
const uint bw = min(w - x, 4U);
const uint bh = min(h - y, 4U);
const uint bw = MIN(w - x, 4U);
const uint bh = MIN(h - y, 4U);
// Blocks that are smaller than 4x4 are handled by repeating the pixels.
// @@ Thats only correct when block size is 1, 2 or 4, but not with 3. :(
@ -124,10 +126,10 @@ void ColorBlock::init(uint w, uint h, const float *data, uint x, uint y)
const uint idx = ((y + by) * w + x + bx);
Color32 & c = color(e, i);
c.r = uint8(255 * clamp(data[idx + 0 * srcPlane], 0.0f, 1.0f)); // @@ Is this the right way to quantize floats to bytes?
c.g = uint8(255 * clamp(data[idx + 1 * srcPlane], 0.0f, 1.0f));
c.b = uint8(255 * clamp(data[idx + 2 * srcPlane], 0.0f, 1.0f));
c.a = uint8(255 * clamp(data[idx + 3 * srcPlane], 0.0f, 1.0f));
c.r = uint8(255 * CLAMP(data[idx + 0 * srcPlane], 0.0f, 1.0f)); // @@ Is this the right way to quantize floats to bytes?
c.g = uint8(255 * CLAMP(data[idx + 1 * srcPlane], 0.0f, 1.0f));
c.b = uint8(255 * CLAMP(data[idx + 2 * srcPlane], 0.0f, 1.0f));
c.a = uint8(255 * CLAMP(data[idx + 3 * srcPlane], 0.0f, 1.0f));
}
}
}

View File

@ -28,14 +28,14 @@
#ifndef __COMMON_H__
#define __COMMON_H__
#ifndef min
#define min(a,b) ((a) <= (b) ? (a) : (b))
#ifndef MIN
#define MIN(a,b) ((a) <= (b) ? (a) : (b))
#endif
#ifndef max
#define max(a,b) ((a) >= (b) ? (a) : (b))
#ifndef MAX
#define MAX(a,b) ((a) >= (b) ? (a) : (b))
#endif
#ifndef clamp
#define clamp(x,a,b) min(max((x), (a)), (b))
#ifndef CLAMP
#define CLAMP(x,a,b) MIN(MAX((x), (a)), (b))
#endif
template<typename T>

View File

@ -83,7 +83,7 @@ static const uint FOURCC_RXGB = DDS_MAKEFOURCC('R', 'X', 'G', 'B');
static const uint FOURCC_ATI1 = DDS_MAKEFOURCC('A', 'T', 'I', '1');
static const uint FOURCC_ATI2 = DDS_MAKEFOURCC('A', 'T', 'I', '2');
static const uint FOURCC_A2XY = DDS_MAKEFOURCC('A', '2', 'X', 'Y');
//static const uint FOURCC_A2XY = DDS_MAKEFOURCC('A', '2', 'X', 'Y');
static const uint FOURCC_DX10 = DDS_MAKEFOURCC('D', 'X', '1', '0');
@ -107,25 +107,25 @@ static const uint D3DFMT_X8B8G8R8 = 33;
static const uint D3DFMT_G16R16 = 34;
static const uint D3DFMT_A2R10G10B10 = 35;
static const uint D3DFMT_A16B16G16R16 = 36;
//static const uint D3DFMT_A16B16G16R16 = 36;
// Palette formats.
static const uint D3DFMT_A8P8 = 40;
static const uint D3DFMT_P8 = 41;
//static const uint D3DFMT_A8P8 = 40;
//static const uint D3DFMT_P8 = 41;
// Luminance formats.
static const uint D3DFMT_L8 = 50;
static const uint D3DFMT_A8L8 = 51;
static const uint D3DFMT_A4L4 = 52;
//static const uint D3DFMT_A8L8 = 51;
//static const uint D3DFMT_A4L4 = 52;
static const uint D3DFMT_L16 = 81;
// Floating point formats
static const uint D3DFMT_R16F = 111;
static const uint D3DFMT_G16R16F = 112;
static const uint D3DFMT_A16B16G16R16F = 113;
static const uint D3DFMT_R32F = 114;
static const uint D3DFMT_G32R32F = 115;
static const uint D3DFMT_A32B32G32R32F = 116;
//static const uint D3DFMT_R16F = 111;
//static const uint D3DFMT_G16R16F = 112;
//static const uint D3DFMT_A16B16G16R16F = 113;
//static const uint D3DFMT_R32F = 114;
//static const uint D3DFMT_G32R32F = 115;
//static const uint D3DFMT_A32B32G32R32F = 116;
static const uint DDSD_CAPS = 0x00000001U;
static const uint DDSD_PIXELFORMAT = 0x00001000U;
@ -1102,8 +1102,8 @@ void DirectDrawSurface::mipmap(Image *img, uint face, uint mipmap)
// Compute width and height.
for (uint m = 0; m < mipmap; m++)
{
w = max(1U, w / 2);
h = max(1U, h / 2);
w = MAX(1U, w / 2);
h = MAX(1U, h / 2);
}
img->allocate(w, h);
@ -1223,9 +1223,9 @@ void DirectDrawSurface::readBlockImage(Image *img)
readBlock(&block);
// Write color block.
for (uint y = 0; y < min(4U, h-4*by); y++)
for (uint y = 0; y < MIN(4U, h-4*by); y++)
{
for (uint x = 0; x < min(4U, w-4*bx); x++)
for (uint x = 0; x < MIN(4U, w-4*bx); x++)
{
img->pixel(4*bx+x, 4*by+y) = block.color(x, y);
}
@ -1240,7 +1240,7 @@ static Color32 buildNormal(uint8 x, uint8 y)
float ny = 2 * (y / 255.0f) - 1;
float nz = 0.0f;
if (1 - nx*nx - ny*ny > 0) nz = sqrt(1 - nx*nx - ny*ny);
uint8 z = clamp(int(255.0f * (nz + 1) / 2.0f), 0, 255);
uint8 z = CLAMP(int(255.0f * (nz + 1) / 2.0f), 0, 255);
return Color32(x, y, z);
}
@ -1379,9 +1379,9 @@ uint DirectDrawSurface::mipmapSize(uint mipmap) const
for (uint m = 0; m < mipmap; m++)
{
w = max(1U, w / 2);
h = max(1U, h / 2);
d = max(1U, d / 2);
w = MAX(1U, w / 2);
h = MAX(1U, h / 2);
d = MAX(1U, d / 2);
}
if (header.pf.flags & DDPF_FOURCC)

View File

@ -246,8 +246,8 @@ int FlipDXTCImage(unsigned int width, unsigned int height, unsigned int levels,
// mip levels are contiguous.
data += block_bytes * blocks;
mip_width = max(1U, mip_width >> 1);
mip_height = max(1U, mip_height >> 1);
mip_width = MAX(1U, mip_width >> 1);
mip_height = MAX(1U, mip_height >> 1);
}
return 1;

View File

@ -1079,11 +1079,18 @@ static char *rna_def_property_length_func(FILE *f, StructRNA *srna, PropertyRNA
fprintf(f, " return %s(ptr);\n", manualfunc);
}
else {
rna_print_data_get(f, dp);
if (dp->dnalengthname)
fprintf(f, " return (data->%s == NULL) ? 0 : data->%s;\n", dp->dnaname, dp->dnalengthname);
if (dp->dnaarraylength <= 1 || dp->dnalengthname)
rna_print_data_get(f, dp);
if (dp->dnaarraylength > 1)
fprintf(f, " return ");
else
fprintf(f, " return (data->%s == NULL) ? 0 : %d;\n", dp->dnaname, dp->dnalengthfixed);
fprintf(f, " return (data->%s == NULL) ? 0 : ", dp->dnaname);
if (dp->dnalengthname)
fprintf(f, "data->%s;\n", dp->dnalengthname);
else
fprintf(f, "%d;\n", dp->dnalengthfixed);
}
fprintf(f, "}\n\n");
}

View File

@ -174,7 +174,7 @@ static eSpace_Type rna_Space_refine_reverse(StructRNA *srna)
if (srna == &RNA_SpaceConsole) return SPACE_CONSOLE;
if (srna == &RNA_SpaceUserPreferences) return SPACE_USERPREF;
if (srna == &RNA_SpaceClipEditor) return SPACE_CLIP;
return -1;
return SPACE_EMPTY;
}
PyObject *pyrna_callback_classmethod_add(PyObject *UNUSED(self), PyObject *args)
@ -220,7 +220,7 @@ PyObject *pyrna_callback_classmethod_add(PyObject *UNUSED(self), PyObject *args)
}
else {
const eSpace_Type spaceid = rna_Space_refine_reverse(srna);
if (spaceid == -1) {
if (spaceid == SPACE_EMPTY) {
PyErr_Format(PyExc_TypeError, "unknown space type '%.200s'", RNA_struct_identifier(srna));
return NULL;
}
@ -283,7 +283,7 @@ PyObject *pyrna_callback_classmethod_remove(PyObject *UNUSED(self), PyObject *ar
}
else {
const eSpace_Type spaceid = rna_Space_refine_reverse(srna);
if (spaceid == -1) {
if (spaceid == SPACE_EMPTY) {
PyErr_Format(PyExc_TypeError, "unknown space type '%.200s'", RNA_struct_identifier(srna));
return NULL;
}

View File

@ -46,7 +46,7 @@
typedef struct QuicktimeCodecTypeDesc {
int codecType;
int rnatmpvalue;
char *codecName;
const char *codecName;
} QuicktimeCodecTypeDesc;
// quicktime movie output functions

View File

@ -49,8 +49,6 @@
// default framerate
const double defFrameRate = 25.0;
// time scale constant
const long timeScale = 1000;
// macro for exception handling and logging
#define CATCH_EXCP catch (Exception & exp) \