include/common.h
author Radek Brich <radek.brich@devl.cz>
Sun, 31 May 2009 23:06:03 +0200
branchpyrit
changeset 100 c005054bf4c1
parent 98 64638385798a
child 104 2274a07510c1
permissions -rw-r--r--
new build target 'vcproj' - generate Visual C++ Studio project files; fix GCC warnings in intersect_packet()
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
94
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
     1
/**
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
     2
 * @file  common.h
4c8abb8977dc update README
Radek Brich <radek.brich@devl.cz>
parents: 93
diff changeset
     3
 * @brief Common functions and definitions
44
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 37
diff changeset
     4
 *
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 37
diff changeset
     5
 * This file is part of Pyrit Ray Tracer.
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 37
diff changeset
     6
 *
48
a4913301c626 begin moving subsampling and oversampling to Sampler
Radek Brich <radek.brich@devl.cz>
parents: 44
diff changeset
     7
 * Copyright 2006, 2007, 2008  Radek Brich
34
28f6e8b9d5d1 quaternion moved to extra header file
Radek Brich <radek.brich@devl.cz>
parents: 30
diff changeset
     8
 *
44
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 37
diff changeset
     9
 * Permission is hereby granted, free of charge, to any person obtaining a copy
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 37
diff changeset
    10
 * of this software and associated documentation files (the "Software"), to deal
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 37
diff changeset
    11
 * in the Software without restriction, including without limitation the rights
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 37
diff changeset
    12
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 37
diff changeset
    13
 * copies of the Software, and to permit persons to whom the Software is
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 37
diff changeset
    14
 * furnished to do so, subject to the following conditions:
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 37
diff changeset
    15
 *
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 37
diff changeset
    16
 * The above copyright notice and this permission notice shall be included in
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 37
diff changeset
    17
 * all copies or substantial portions of the Software.
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 37
diff changeset
    18
 *
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 37
diff changeset
    19
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 37
diff changeset
    20
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 37
diff changeset
    21
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 37
diff changeset
    22
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 37
diff changeset
    23
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 37
diff changeset
    24
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 37
diff changeset
    25
 * THE SOFTWARE.
34
28f6e8b9d5d1 quaternion moved to extra header file
Radek Brich <radek.brich@devl.cz>
parents: 30
diff changeset
    26
 */
28f6e8b9d5d1 quaternion moved to extra header file
Radek Brich <radek.brich@devl.cz>
parents: 30
diff changeset
    27
15
a0a3e334744f C++ demos: prepare infrastructure, add spheres_shadow.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    28
#ifndef COMMON_H
a0a3e334744f C++ demos: prepare infrastructure, add spheres_shadow.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    29
#define COMMON_H
a0a3e334744f C++ demos: prepare infrastructure, add spheres_shadow.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    30
92
9af5c039b678 add MSVC compiler support, make it default for Windows
Radek Brich <radek.brich@devl.cz>
parents: 91
diff changeset
    31
#include "config.h"
9af5c039b678 add MSVC compiler support, make it default for Windows
Radek Brich <radek.brich@devl.cz>
parents: 91
diff changeset
    32
20
f22952603f29 new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents: 15
diff changeset
    33
#include <stdio.h>
92
9af5c039b678 add MSVC compiler support, make it default for Windows
Radek Brich <radek.brich@devl.cz>
parents: 91
diff changeset
    34
#include <math.h>
15
a0a3e334744f C++ demos: prepare infrastructure, add spheres_shadow.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    35
#include <float.h>
52
a6413a3d741d new implementation of sample_queue
Radek Brich <radek.brich@devl.cz>
parents: 48
diff changeset
    36
#include <pthread.h>
78
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents: 52
diff changeset
    37
#include <string>
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents: 52
diff changeset
    38
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents: 52
diff changeset
    39
using namespace std;
15
a0a3e334744f C++ demos: prepare infrastructure, add spheres_shadow.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    40
100
c005054bf4c1 new build target 'vcproj' - generate Visual C++ Studio project files; fix GCC warnings in intersect_packet()
Radek Brich <radek.brich@devl.cz>
parents: 98
diff changeset
    41
#ifndef MSVC
c005054bf4c1 new build target 'vcproj' - generate Visual C++ Studio project files; fix GCC warnings in intersect_packet()
Radek Brich <radek.brich@devl.cz>
parents: 98
diff changeset
    42
# include <stdint.h>
c005054bf4c1 new build target 'vcproj' - generate Visual C++ Studio project files; fix GCC warnings in intersect_packet()
Radek Brich <radek.brich@devl.cz>
parents: 98
diff changeset
    43
#else
c005054bf4c1 new build target 'vcproj' - generate Visual C++ Studio project files; fix GCC warnings in intersect_packet()
Radek Brich <radek.brich@devl.cz>
parents: 98
diff changeset
    44
#ifndef _SDL_config_win32_h
c005054bf4c1 new build target 'vcproj' - generate Visual C++ Studio project files; fix GCC warnings in intersect_packet()
Radek Brich <radek.brich@devl.cz>
parents: 98
diff changeset
    45
/* these stdint.h typedefs are not available in MSVC
c005054bf4c1 new build target 'vcproj' - generate Visual C++ Studio project files; fix GCC warnings in intersect_packet()
Radek Brich <radek.brich@devl.cz>
parents: 98
diff changeset
    46
 * but are defined in SDL_config_win32.h */
c005054bf4c1 new build target 'vcproj' - generate Visual C++ Studio project files; fix GCC warnings in intersect_packet()
Radek Brich <radek.brich@devl.cz>
parents: 98
diff changeset
    47
typedef __int8				int8_t;
c005054bf4c1 new build target 'vcproj' - generate Visual C++ Studio project files; fix GCC warnings in intersect_packet()
Radek Brich <radek.brich@devl.cz>
parents: 98
diff changeset
    48
typedef __int16				int16_t;
c005054bf4c1 new build target 'vcproj' - generate Visual C++ Studio project files; fix GCC warnings in intersect_packet()
Radek Brich <radek.brich@devl.cz>
parents: 98
diff changeset
    49
typedef __int32				int32_t;
c005054bf4c1 new build target 'vcproj' - generate Visual C++ Studio project files; fix GCC warnings in intersect_packet()
Radek Brich <radek.brich@devl.cz>
parents: 98
diff changeset
    50
typedef __int64				int64_t;
c005054bf4c1 new build target 'vcproj' - generate Visual C++ Studio project files; fix GCC warnings in intersect_packet()
Radek Brich <radek.brich@devl.cz>
parents: 98
diff changeset
    51
typedef unsigned __int8		uint8_t;
c005054bf4c1 new build target 'vcproj' - generate Visual C++ Studio project files; fix GCC warnings in intersect_packet()
Radek Brich <radek.brich@devl.cz>
parents: 98
diff changeset
    52
typedef unsigned __int16	uint16_t;
c005054bf4c1 new build target 'vcproj' - generate Visual C++ Studio project files; fix GCC warnings in intersect_packet()
Radek Brich <radek.brich@devl.cz>
parents: 98
diff changeset
    53
typedef unsigned __int32	uint32_t;
c005054bf4c1 new build target 'vcproj' - generate Visual C++ Studio project files; fix GCC warnings in intersect_packet()
Radek Brich <radek.brich@devl.cz>
parents: 98
diff changeset
    54
typedef unsigned __int64	uint64_t;
c005054bf4c1 new build target 'vcproj' - generate Visual C++ Studio project files; fix GCC warnings in intersect_packet()
Radek Brich <radek.brich@devl.cz>
parents: 98
diff changeset
    55
#endif
c005054bf4c1 new build target 'vcproj' - generate Visual C++ Studio project files; fix GCC warnings in intersect_packet()
Radek Brich <radek.brich@devl.cz>
parents: 98
diff changeset
    56
#endif
c005054bf4c1 new build target 'vcproj' - generate Visual C++ Studio project files; fix GCC warnings in intersect_packet()
Radek Brich <radek.brich@devl.cz>
parents: 98
diff changeset
    57
c005054bf4c1 new build target 'vcproj' - generate Visual C++ Studio project files; fix GCC warnings in intersect_packet()
Radek Brich <radek.brich@devl.cz>
parents: 98
diff changeset
    58
22
76b7bd51d64a new make infrastructure
Radek Brich <radek.brich@devl.cz>
parents: 20
diff changeset
    59
#ifdef PYRIT_DOUBLE
76b7bd51d64a new make infrastructure
Radek Brich <radek.brich@devl.cz>
parents: 20
diff changeset
    60
# define Float double
76b7bd51d64a new make infrastructure
Radek Brich <radek.brich@devl.cz>
parents: 20
diff changeset
    61
# define Eps DBL_EPSILON
76b7bd51d64a new make infrastructure
Radek Brich <radek.brich@devl.cz>
parents: 20
diff changeset
    62
# define Inf DBL_MAX
93
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents: 92
diff changeset
    63
# define PI M_PI
22
76b7bd51d64a new make infrastructure
Radek Brich <radek.brich@devl.cz>
parents: 20
diff changeset
    64
#else
76b7bd51d64a new make infrastructure
Radek Brich <radek.brich@devl.cz>
parents: 20
diff changeset
    65
# define Float float
95
ca7d4c665531 build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents: 94
diff changeset
    66
# define Eps 2e-6f
22
76b7bd51d64a new make infrastructure
Radek Brich <radek.brich@devl.cz>
parents: 20
diff changeset
    67
# define Inf FLT_MAX
93
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents: 92
diff changeset
    68
# define PI (float)M_PI
22
76b7bd51d64a new make infrastructure
Radek Brich <radek.brich@devl.cz>
parents: 20
diff changeset
    69
#endif
15
a0a3e334744f C++ demos: prepare infrastructure, add spheres_shadow.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    70
92
9af5c039b678 add MSVC compiler support, make it default for Windows
Radek Brich <radek.brich@devl.cz>
parents: 91
diff changeset
    71
// enable M_* constants in MSVC
9af5c039b678 add MSVC compiler support, make it default for Windows
Radek Brich <radek.brich@devl.cz>
parents: 91
diff changeset
    72
#define _USE_MATH_DEFINES
91
9d66d323c354 packetize Phong shader
Radek Brich <radek.brich@devl.cz>
parents: 86
diff changeset
    73
95
ca7d4c665531 build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents: 94
diff changeset
    74
#ifdef MSVC
ca7d4c665531 build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents: 94
diff changeset
    75
#define NORETURN __declspec(noreturn)
ca7d4c665531 build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents: 94
diff changeset
    76
#else
ca7d4c665531 build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents: 94
diff changeset
    77
#define NORETURN __attribute__((noreturn))
ca7d4c665531 build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents: 94
diff changeset
    78
#endif
ca7d4c665531 build script fixes, add ldflags build option
Radek Brich <radek.brich@devl.cz>
parents: 94
diff changeset
    79
98
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
    80
/**
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
    81
 * verbosity level
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
    82
 *
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
    83
 * - 0: only errors and warnings (E, W)
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
    84
 * - 1: major status messages (*)
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
    85
 * - 2: minor status, progress (-)
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
    86
 * - 3: debug messages (D)
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
    87
 * - 4: thread debug
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
    88
 *
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
    89
 * default is 2
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
    90
 */
30
33f95441790e pyrit_verbosity: new variable for controlling amount of output, see common.h
Radek Brich <radek.brich@devl.cz>
parents: 22
diff changeset
    91
extern int pyrit_verbosity;
33f95441790e pyrit_verbosity: new variable for controlling amount of output, see common.h
Radek Brich <radek.brich@devl.cz>
parents: 22
diff changeset
    92
98
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
    93
/**
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
    94
 * print status or debugging message
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
    95
 * @param[in] vlevel    verbosity level of the message
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
    96
 * @see pyrit_verbosity
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
    97
 */
93
96d65f841791 more build script tuning
Radek Brich <radek.brich@devl.cz>
parents: 92
diff changeset
    98
void dbgmsg(const int vlevel, const char *format, ...);
20
f22952603f29 new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents: 15
diff changeset
    99
98
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
   100
/** template for minimum of three numbers */
37
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   101
template<typename Type> const Type &min3(const Type &a, const Type &b, const Type &c)
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   102
{
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   103
	if (a <= b)
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   104
	{
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   105
		if (a <= c)
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   106
			return a;
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   107
		else
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   108
			return c;
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   109
	}
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   110
	else
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   111
	{
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   112
		if (b <= c)
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   113
			return b;
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   114
		else
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   115
			return c;
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   116
	}
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   117
}
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   118
98
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
   119
/** template for maximum of three numbers */
37
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   120
template<typename Type> const Type &max3(const Type &a, const Type &b, const Type &c)
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   121
{
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   122
	if (a >= b)
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   123
	{
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   124
		if (a >= c)
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   125
			return a;
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   126
		else
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   127
			return c;
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   128
	}
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   129
	else
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   130
	{
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   131
		if (b >= c)
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   132
			return b;
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   133
		else
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   134
			return c;
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   135
	}
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   136
}
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   137
98
64638385798a add sections about demos to README
Radek Brich <radek.brich@devl.cz>
parents: 95
diff changeset
   138
/** trim whitespace from beginning and end of string */
78
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents: 52
diff changeset
   139
inline void trim(string& s)
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents: 52
diff changeset
   140
{
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents: 52
diff changeset
   141
	const char *ws = " \n";
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents: 52
diff changeset
   142
	string::size_type pos = s.find_last_not_of(ws);
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents: 52
diff changeset
   143
	if (pos != string::npos)
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents: 52
diff changeset
   144
	{
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents: 52
diff changeset
   145
		s.erase(pos + 1);
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents: 52
diff changeset
   146
		pos = s.find_first_not_of(ws);
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents: 52
diff changeset
   147
		if (pos != string::npos)
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents: 52
diff changeset
   148
			s.erase(0, pos);
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents: 52
diff changeset
   149
	}
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents: 52
diff changeset
   150
	else
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents: 52
diff changeset
   151
		s.erase(s.begin(), s.end());
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents: 52
diff changeset
   152
}
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents: 52
diff changeset
   153
20
f22952603f29 new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents: 15
diff changeset
   154
#endif