include/common.h
author Radek Brich <radek.brich@devl.cz>
Fri, 02 May 2008 13:27:47 +0200
branchpyrit
changeset 91 9d66d323c354
parent 86 ce6abe0aeeae
child 92 9af5c039b678
permissions -rw-r--r--
packetize Phong shader new scons config options: simd=(yes|no) - allow/suppress explicit SSE force_flags=(yes|no) - force use of specified flags instead of autodetected profile=(yes|no) - enable gcc's profiling (-pg option) check for pthread.h header, don't try to build without it add fourth Vector3 component for better memory aligning rename Vector3 to Vector partialy SSE-ize Vector class (only fully vertical operations) build static lib and python module in distinctive directories to avoid collision of library file names on some platforms
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34
28f6e8b9d5d1 quaternion moved to extra header file
Radek Brich <radek.brich@devl.cz>
parents: 30
diff changeset
     1
/*
44
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 37
diff changeset
     2
 * common.h: common functions and definitions
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 37
diff changeset
     3
 *
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 37
diff changeset
     4
 * This file is part of Pyrit Ray Tracer.
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 37
diff changeset
     5
 *
48
a4913301c626 begin moving subsampling and oversampling to Sampler
Radek Brich <radek.brich@devl.cz>
parents: 44
diff changeset
     6
 * Copyright 2006, 2007, 2008  Radek Brich
34
28f6e8b9d5d1 quaternion moved to extra header file
Radek Brich <radek.brich@devl.cz>
parents: 30
diff changeset
     7
 *
44
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 37
diff changeset
     8
 * 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
     9
 * 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
    10
 * 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
    11
 * 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
    12
 * 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
    13
 * furnished to do so, subject to the following conditions:
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 37
diff changeset
    14
 *
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 37
diff changeset
    15
 * 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
    16
 * all copies or substantial portions of the Software.
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 37
diff changeset
    17
 *
3763b26244f0 MIT license for sources
Radek Brich <radek.brich@devl.cz>
parents: 37
diff changeset
    18
 * 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
    19
 * 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
    20
 * 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
    21
 * 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
    22
 * 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
    23
 * 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
    24
 * THE SOFTWARE.
34
28f6e8b9d5d1 quaternion moved to extra header file
Radek Brich <radek.brich@devl.cz>
parents: 30
diff changeset
    25
 */
28f6e8b9d5d1 quaternion moved to extra header file
Radek Brich <radek.brich@devl.cz>
parents: 30
diff changeset
    26
15
a0a3e334744f C++ demos: prepare infrastructure, add spheres_shadow.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    27
#ifndef COMMON_H
a0a3e334744f C++ demos: prepare infrastructure, add spheres_shadow.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    28
#define COMMON_H
a0a3e334744f C++ demos: prepare infrastructure, add spheres_shadow.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    29
20
f22952603f29 new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents: 15
diff changeset
    30
#include <stdio.h>
f22952603f29 new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents: 15
diff changeset
    31
#include <stdarg.h>
15
a0a3e334744f C++ demos: prepare infrastructure, add spheres_shadow.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    32
#include <float.h>
52
a6413a3d741d new implementation of sample_queue
Radek Brich <radek.brich@devl.cz>
parents: 48
diff changeset
    33
#include <pthread.h>
78
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents: 52
diff changeset
    34
#include <string>
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents: 52
diff changeset
    35
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents: 52
diff changeset
    36
using namespace std;
15
a0a3e334744f C++ demos: prepare infrastructure, add spheres_shadow.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    37
22
76b7bd51d64a new make infrastructure
Radek Brich <radek.brich@devl.cz>
parents: 20
diff changeset
    38
#ifdef PYRIT_DOUBLE
76b7bd51d64a new make infrastructure
Radek Brich <radek.brich@devl.cz>
parents: 20
diff changeset
    39
# define Float double
76b7bd51d64a new make infrastructure
Radek Brich <radek.brich@devl.cz>
parents: 20
diff changeset
    40
# define Eps DBL_EPSILON
76b7bd51d64a new make infrastructure
Radek Brich <radek.brich@devl.cz>
parents: 20
diff changeset
    41
# define Inf DBL_MAX
76b7bd51d64a new make infrastructure
Radek Brich <radek.brich@devl.cz>
parents: 20
diff changeset
    42
#else
76b7bd51d64a new make infrastructure
Radek Brich <radek.brich@devl.cz>
parents: 20
diff changeset
    43
# define Float float
76b7bd51d64a new make infrastructure
Radek Brich <radek.brich@devl.cz>
parents: 20
diff changeset
    44
# define Eps 1e-6
76b7bd51d64a new make infrastructure
Radek Brich <radek.brich@devl.cz>
parents: 20
diff changeset
    45
# define Inf FLT_MAX
76b7bd51d64a new make infrastructure
Radek Brich <radek.brich@devl.cz>
parents: 20
diff changeset
    46
#endif
15
a0a3e334744f C++ demos: prepare infrastructure, add spheres_shadow.cc
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    47
91
9d66d323c354 packetize Phong shader
Radek Brich <radek.brich@devl.cz>
parents: 86
diff changeset
    48
#ifndef NO_SSE
9d66d323c354 packetize Phong shader
Radek Brich <radek.brich@devl.cz>
parents: 86
diff changeset
    49
// SSE intrinsics
9d66d323c354 packetize Phong shader
Radek Brich <radek.brich@devl.cz>
parents: 86
diff changeset
    50
#include <xmmintrin.h>
9d66d323c354 packetize Phong shader
Radek Brich <radek.brich@devl.cz>
parents: 86
diff changeset
    51
86
ce6abe0aeeae BBox - RayPacket intersection
Radek Brich <radek.brich@devl.cz>
parents: 83
diff changeset
    52
const __m128 mZero = _mm_set_ps1(0.);
ce6abe0aeeae BBox - RayPacket intersection
Radek Brich <radek.brich@devl.cz>
parents: 83
diff changeset
    53
const __m128 mOne = _mm_set_ps1(1.);
91
9d66d323c354 packetize Phong shader
Radek Brich <radek.brich@devl.cz>
parents: 86
diff changeset
    54
const __m128 mTwo = _mm_set_ps1(2.);
86
ce6abe0aeeae BBox - RayPacket intersection
Radek Brich <radek.brich@devl.cz>
parents: 83
diff changeset
    55
const __m128 mEps = _mm_set_ps1(Eps);
ce6abe0aeeae BBox - RayPacket intersection
Radek Brich <radek.brich@devl.cz>
parents: 83
diff changeset
    56
const __m128 mMEps = _mm_set_ps1(-Eps);
ce6abe0aeeae BBox - RayPacket intersection
Radek Brich <radek.brich@devl.cz>
parents: 83
diff changeset
    57
const __m128 mInf = _mm_set_ps1(Inf);
ce6abe0aeeae BBox - RayPacket intersection
Radek Brich <radek.brich@devl.cz>
parents: 83
diff changeset
    58
const __m128 mAllSet = _mm_cmplt_ps(mZero, mOne);
ce6abe0aeeae BBox - RayPacket intersection
Radek Brich <radek.brich@devl.cz>
parents: 83
diff changeset
    59
91
9d66d323c354 packetize Phong shader
Radek Brich <radek.brich@devl.cz>
parents: 86
diff changeset
    60
inline const __m128 _mm_fastpow(const __m128& base, const __m128& exponent)
9d66d323c354 packetize Phong shader
Radek Brich <radek.brich@devl.cz>
parents: 86
diff changeset
    61
{
9d66d323c354 packetize Phong shader
Radek Brich <radek.brich@devl.cz>
parents: 86
diff changeset
    62
    __m128 denom = _mm_mul_ps( exponent, base);
9d66d323c354 packetize Phong shader
Radek Brich <radek.brich@devl.cz>
parents: 86
diff changeset
    63
    denom = _mm_sub_ps( exponent, denom);
9d66d323c354 packetize Phong shader
Radek Brich <radek.brich@devl.cz>
parents: 86
diff changeset
    64
    denom = _mm_add_ps( base, denom);
9d66d323c354 packetize Phong shader
Radek Brich <radek.brich@devl.cz>
parents: 86
diff changeset
    65
    return _mm_mul_ps( base, _mm_rcp_ps(denom));
9d66d323c354 packetize Phong shader
Radek Brich <radek.brich@devl.cz>
parents: 86
diff changeset
    66
}
9d66d323c354 packetize Phong shader
Radek Brich <radek.brich@devl.cz>
parents: 86
diff changeset
    67
#endif
9d66d323c354 packetize Phong shader
Radek Brich <radek.brich@devl.cz>
parents: 86
diff changeset
    68
30
33f95441790e pyrit_verbosity: new variable for controlling amount of output, see common.h
Radek Brich <radek.brich@devl.cz>
parents: 22
diff changeset
    69
/* verbosity level:
33f95441790e pyrit_verbosity: new variable for controlling amount of output, see common.h
Radek Brich <radek.brich@devl.cz>
parents: 22
diff changeset
    70
0: only errors (E)
33f95441790e pyrit_verbosity: new variable for controlling amount of output, see common.h
Radek Brich <radek.brich@devl.cz>
parents: 22
diff changeset
    71
1: major status messages (*)
33f95441790e pyrit_verbosity: new variable for controlling amount of output, see common.h
Radek Brich <radek.brich@devl.cz>
parents: 22
diff changeset
    72
2: minor status, progress (-)
33f95441790e pyrit_verbosity: new variable for controlling amount of output, see common.h
Radek Brich <radek.brich@devl.cz>
parents: 22
diff changeset
    73
3: debug messages (D)
52
a6413a3d741d new implementation of sample_queue
Radek Brich <radek.brich@devl.cz>
parents: 48
diff changeset
    74
4: thread debug
30
33f95441790e pyrit_verbosity: new variable for controlling amount of output, see common.h
Radek Brich <radek.brich@devl.cz>
parents: 22
diff changeset
    75
default = 2
33f95441790e pyrit_verbosity: new variable for controlling amount of output, see common.h
Radek Brich <radek.brich@devl.cz>
parents: 22
diff changeset
    76
*/
33f95441790e pyrit_verbosity: new variable for controlling amount of output, see common.h
Radek Brich <radek.brich@devl.cz>
parents: 22
diff changeset
    77
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
    78
33f95441790e pyrit_verbosity: new variable for controlling amount of output, see common.h
Radek Brich <radek.brich@devl.cz>
parents: 22
diff changeset
    79
inline 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
    80
{
52
a6413a3d741d new implementation of sample_queue
Radek Brich <radek.brich@devl.cz>
parents: 48
diff changeset
    81
	static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
30
33f95441790e pyrit_verbosity: new variable for controlling amount of output, see common.h
Radek Brich <radek.brich@devl.cz>
parents: 22
diff changeset
    82
	if (pyrit_verbosity >= vlevel)
33f95441790e pyrit_verbosity: new variable for controlling amount of output, see common.h
Radek Brich <radek.brich@devl.cz>
parents: 22
diff changeset
    83
	{
52
a6413a3d741d new implementation of sample_queue
Radek Brich <radek.brich@devl.cz>
parents: 48
diff changeset
    84
		if (pyrit_verbosity >= 4)
a6413a3d741d new implementation of sample_queue
Radek Brich <radek.brich@devl.cz>
parents: 48
diff changeset
    85
			pthread_mutex_lock(&mutex);
a6413a3d741d new implementation of sample_queue
Radek Brich <radek.brich@devl.cz>
parents: 48
diff changeset
    86
30
33f95441790e pyrit_verbosity: new variable for controlling amount of output, see common.h
Radek Brich <radek.brich@devl.cz>
parents: 22
diff changeset
    87
		va_list ap;
33f95441790e pyrit_verbosity: new variable for controlling amount of output, see common.h
Radek Brich <radek.brich@devl.cz>
parents: 22
diff changeset
    88
		va_start(ap, format);
33f95441790e pyrit_verbosity: new variable for controlling amount of output, see common.h
Radek Brich <radek.brich@devl.cz>
parents: 22
diff changeset
    89
		vprintf(format, ap);
33f95441790e pyrit_verbosity: new variable for controlling amount of output, see common.h
Radek Brich <radek.brich@devl.cz>
parents: 22
diff changeset
    90
		va_end(ap);
33f95441790e pyrit_verbosity: new variable for controlling amount of output, see common.h
Radek Brich <radek.brich@devl.cz>
parents: 22
diff changeset
    91
		fflush(stdout);
52
a6413a3d741d new implementation of sample_queue
Radek Brich <radek.brich@devl.cz>
parents: 48
diff changeset
    92
a6413a3d741d new implementation of sample_queue
Radek Brich <radek.brich@devl.cz>
parents: 48
diff changeset
    93
		if (pyrit_verbosity >= 4)
a6413a3d741d new implementation of sample_queue
Radek Brich <radek.brich@devl.cz>
parents: 48
diff changeset
    94
			pthread_mutex_unlock(&mutex);
30
33f95441790e pyrit_verbosity: new variable for controlling amount of output, see common.h
Radek Brich <radek.brich@devl.cz>
parents: 22
diff changeset
    95
	}
20
f22952603f29 new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents: 15
diff changeset
    96
}
f22952603f29 new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents: 15
diff changeset
    97
37
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
    98
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
    99
{
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   100
	if (a <= b)
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   101
	{
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   102
		if (a <= c)
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   103
			return a;
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   104
		else
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   105
			return c;
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   106
	}
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
	{
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   109
		if (b <= c)
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   110
			return b;
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   111
		else
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   112
			return c;
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   113
	}
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   114
}
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   115
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   116
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
   117
{
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   118
	if (a >= b)
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   119
	{
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   120
		if (a >= c)
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   121
			return a;
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   122
		else
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   123
			return c;
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   124
	}
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   125
	else
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   126
	{
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   127
		if (b >= c)
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   128
			return b;
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
			return c;
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   131
	}
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   132
}
5f954c0d34fc octree traversal rewritten to avoid recursion
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
   133
78
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents: 52
diff changeset
   134
inline void trim(string& s)
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents: 52
diff changeset
   135
{
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents: 52
diff changeset
   136
	const char *ws = " \n";
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents: 52
diff changeset
   137
	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
   138
	if (pos != string::npos)
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents: 52
diff changeset
   139
	{
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents: 52
diff changeset
   140
		s.erase(pos + 1);
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents: 52
diff changeset
   141
		pos = s.find_first_not_of(ws);
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents: 52
diff changeset
   142
		if (pos != string::npos)
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents: 52
diff changeset
   143
			s.erase(0, pos);
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
	else
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents: 52
diff changeset
   146
		s.erase(s.begin(), s.end());
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents: 52
diff changeset
   147
}
9569e9f35374 move shapes to extra source file
Radek Brich <radek.brich@devl.cz>
parents: 52
diff changeset
   148
20
f22952603f29 new C++ demo: realtime.cc (real-time scene viewer using SDL)
Radek Brich <radek.brich@devl.cz>
parents: 15
diff changeset
   149
#endif