src/common.cc
author Radek Brich <radek.brich@devl.cz>
Tue, 06 May 2008 09:39:58 +0200
branchpyrit
changeset 93 96d65f841791
permissions -rw-r--r--
more build script tuning make all float constants single precision solve many warnings from msvc and gcc with various -W... flags add common.cc file for dbgmsg() function witch apparently cannot be inlined fix python module building with msvc, add manifest file handling remove forgotten RenderrowData class add stanford models download script for windows (.bat)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
93
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     1
/*
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     2
 * common.cc: common functions and definitions
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     3
 *
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     4
 * This file is part of Pyrit Ray Tracer.
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     5
 *
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     6
 * Copyright 2008  Radek Brich
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     7
 *
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     8
 * Permission is hereby granted, free of charge, to any person obtaining a copy
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     9
 * of this software and associated documentation files (the "Software"), to deal
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    10
 * in the Software without restriction, including without limitation the rights
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    11
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    12
 * copies of the Software, and to permit persons to whom the Software is
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    13
 * furnished to do so, subject to the following conditions:
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    14
 *
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    15
 * The above copyright notice and this permission notice shall be included in
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    16
 * all copies or substantial portions of the Software.
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    17
 *
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    18
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    19
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    20
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    21
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    22
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    23
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    24
 * THE SOFTWARE.
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    25
 */
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    26
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    27
#include "common.h"
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    28
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    29
#include <stdarg.h>
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    30
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    31
int pyrit_verbosity = 2;
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    32
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    33
void dbgmsg(const int vlevel, const char *format, ...)
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    34
{
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    35
	static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    36
	if (pyrit_verbosity >= vlevel)
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    37
	{
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    38
		if (pyrit_verbosity >= 4)
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    39
			pthread_mutex_lock(&mutex);
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    40
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    41
		va_list ap;
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    42
		va_start(ap, format);
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    43
		vprintf(format, ap);
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    44
		va_end(ap);
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    45
		fflush(stdout);
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    46
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    47
		if (pyrit_verbosity >= 4)
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    48
			pthread_mutex_unlock(&mutex);
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    49
	}
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    50
}