Index: trunk/src/core/random.cc
===================================================================
--- trunk/src/core/random.cc	(revision 487)
+++ trunk/src/core/random.cc	(revision 503)
@@ -19,5 +19,11 @@
 #define NV_MT_TWIST(u, v)  ( (NV_MT_MIXBITS(u, v) >> 1) ^ ( (v) & 1UL ? mt_matrix_a : 0UL) )
 
-void random::mt_init( uint32 seed )
+nv::random& random::get()
+{
+	static random default_rng;
+	return default_rng;
+}
+
+void random_mersenne::mt_init( uint32 seed )
 {
 	m_state[0] = static_cast<uint32>( seed & mt_full_mask );
@@ -34,5 +40,5 @@
 
 
-void random::mt_update()
+void random_mersenne::mt_update()
 {
 	uint32 *p = m_state;
@@ -51,5 +57,5 @@
 
 
-uint32 random::mt_uint32()
+uint32 random_mersenne::mt_uint32()
 {
 	uint32 r;
@@ -70,36 +76,22 @@
 }
 
-random::random( random::seed_type seed /*= 0 */ )
+random_mersenne::random_mersenne( random_mersenne::seed_type seed /*= 0 */ )
 	: m_next( nullptr ), m_remaining( 0 ), m_seeded( 0 )
 {
-	mt_init( seed == 0 ? randomized_seed() : seed );
-}
-
-random::seed_type random::set_seed( random::seed_type seed /*= 0 */ )
-{
-	if ( seed == 0 ) seed = randomized_seed();
+	mt_init( seed );
+}
+
+random_mersenne::seed_type random_mersenne::set_seed( random_mersenne::seed_type seed /*= 0 */ )
+{
 	mt_init( seed );
 	return seed;
 }
 
-nv::random& random::get()
-{
-	static random default_rng;
-	return default_rng;
-}
-
-random::result_type random::rand()
+random_mersenne::result_type random_mersenne::rand()
 {
 	return mt_uint32();
 }
 
-uint32 random::urand( uint32 val )
-{
-	uint32 x, max = mt_full_mask - ( mt_full_mask % val );
-	while ( ( x = rand() ) >= max );
-	return x / ( max / val );
-}
-
-random::seed_type random::randomized_seed()
+random_base::seed_type random_base::randomized_seed()
 {
 	// TODO: this seems off, as it might often seed the same, use general time 
@@ -108,5 +100,5 @@
 }
 
-nv::vec2 nv::random::precise_unit_vec2()
+nv::vec2 nv::random_base::precise_unit_vec2()
 {
 	f32 angle = frand( math::pi<f32>() * 2.f );
@@ -114,5 +106,5 @@
 }
 
-nv::vec3 nv::random::precise_unit_vec3()
+nv::vec3 nv::random_base::precise_unit_vec3()
 {
 	f32 cos_theta = frange( -1.0f, 1.0f );
@@ -126,5 +118,5 @@
 }
 
-nv::vec2 nv::random::fast_disk_point()
+nv::vec2 nv::random_base::fast_disk_point()
 {
 	f32 r1 = frand();
@@ -135,5 +127,5 @@
 }
 
-nv::vec2 nv::random::precise_disk_point()
+nv::vec2 nv::random_base::precise_disk_point()
 {
 	f32 r = sqrt( frand() );
@@ -142,5 +134,5 @@
 }
 
-nv::vec3 nv::random::fast_sphere_point()
+nv::vec3 nv::random_base::fast_sphere_point()
 {
 	f32 rad     = frand();
@@ -156,5 +148,5 @@
 }
 
-nv::vec3 nv::random::precise_sphere_point()
+nv::vec3 nv::random_base::precise_sphere_point()
 {
 	f32 radius = pow( frand(), 1.f/3.f );
@@ -169,5 +161,5 @@
 }
 
-nv::vec2 nv::random::precise_ellipse_point( const vec2& radii )
+nv::vec2 nv::random_base::precise_ellipse_point( const vec2& radii )
 {
 	vec2 p = range( -radii, radii );
@@ -184,5 +176,5 @@
 }
 
-nv::vec3 nv::random::precise_ellipsoid_point( const vec3& radii )
+nv::vec3 nv::random_base::precise_ellipsoid_point( const vec3& radii )
 {
 	vec3 p = range( -radii, radii );
@@ -199,5 +191,5 @@
 }
 
-nv::vec2 nv::random::fast_hollow_disk_point( f32 iradius, f32 oradius )
+nv::vec2 nv::random_base::fast_hollow_disk_point( f32 iradius, f32 oradius )
 {
 	f32 idist2 = iradius * iradius;
@@ -207,10 +199,10 @@
 }
 
-nv::vec2 nv::random::precise_hollow_disk_point( f32 iradius, f32 oradius )
+nv::vec2 nv::random_base::precise_hollow_disk_point( f32 iradius, f32 oradius )
 {
 	return fast_hollow_disk_point( iradius, oradius );
 }
 
-nv::vec3 nv::random::fast_hollow_sphere_point( f32 iradius, f32 oradius )
+nv::vec3 nv::random_base::fast_hollow_sphere_point( f32 iradius, f32 oradius )
 {
 	f32 idist3 = iradius * iradius * iradius;
@@ -220,5 +212,5 @@
 }
 
-nv::vec3 nv::random::precise_hollow_sphere_point( f32 iradius, f32 oradius )
+nv::vec3 nv::random_base::precise_hollow_sphere_point( f32 iradius, f32 oradius )
 {
 	return fast_hollow_sphere_point( iradius, oradius );
@@ -226,5 +218,5 @@
 
 
-nv::vec2 nv::random::fast_hollow_ellipse_point( const vec2& iradii, const vec2& oradii )
+nv::vec2 nv::random_base::fast_hollow_ellipse_point( const vec2& iradii, const vec2& oradii )
 {
 	vec2 iradii2 = iradii * iradii;
@@ -241,10 +233,10 @@
 }
 
-nv::vec2 nv::random::precise_hollow_ellipse_point( const vec2& iradii, const vec2& oradii )
+nv::vec2 nv::random_base::precise_hollow_ellipse_point( const vec2& iradii, const vec2& oradii )
 {
 	return fast_hollow_ellipse_point( iradii, oradii );
 }
 
-nv::vec3 nv::random::fast_hollow_ellipsoid_point( const vec3& iradii, const vec3& oradii )
+nv::vec3 nv::random_base::fast_hollow_ellipsoid_point( const vec3& iradii, const vec3& oradii )
 {
 	vec3 iradii2 = iradii * iradii;
@@ -267,7 +259,32 @@
 }
 
-nv::vec3 nv::random::precise_hollow_ellipsoid_point( const vec3& iradii, const vec3& oradii )
+nv::vec3 nv::random_base::precise_hollow_ellipsoid_point( const vec3& iradii, const vec3& oradii )
 {
 	return fast_hollow_ellipsoid_point( iradii, oradii );
 }
 
+nv::random_xor128::random_xor128( seed_type seed /*= randomized_seed() */ )
+{
+	set_seed( seed );
+}
+
+nv::random_base::seed_type nv::random_xor128::set_seed( seed_type seed /*= 0 */ )
+{
+	uint32 s = 4294967296 - seed;
+	m_state[0] = 123456789 * s;
+	m_state[1] = 362436069 * s;
+	m_state[2] = 521288629 * s;
+	m_state[3] = 88675123 * s;
+	return seed;
+}
+
+nv::random_base::result_type nv::random_xor128::rand()
+{
+	uint32 t = m_state[0];
+	t ^= t << 11;
+	t ^= t >> 8;
+	m_state[0] = m_state[1]; m_state[1] = m_state[2]; m_state[2] = m_state[3];
+	m_state[3] ^= m_state[3] >> 19;
+	m_state[3] ^= t;
+	return m_state[3];
+}
Index: trunk/src/core/types.cc
===================================================================
--- trunk/src/core/types.cc	(revision 503)
+++ trunk/src/core/types.cc	(revision 503)
@@ -0,0 +1,198 @@
+#include "nv/core/types.hh"
+
+#include "nv/interface/clear_state.hh"
+#include "nv/interface/render_state.hh"
+
+using namespace nv;
+
+void nv::register_core_types( type_database* db )
+{
+	db->create_type<bool>();
+	db->create_type<char>();
+	db->create_type<uint8>();
+	db->create_type<sint8>();
+	db->create_type<uint16>();
+	db->create_type<sint16>();
+	db->create_type<uint32>();
+	db->create_type<sint32>();
+	db->create_type<uint64>();
+	db->create_type<sint64>();
+	db->create_type<f32>();
+	db->create_type<f64>();
+	db->create_type<vec2>();
+	db->create_type<vec3>();
+	db->create_type<vec4>();
+	db->create_type<ivec2>();
+	db->create_type<ivec3>();
+	db->create_type<ivec4>();
+
+	db->create_type<color_mask>()
+		.field( "red",   &color_mask::red )
+		.field( "green", &color_mask::green )
+		.field( "blue",  &color_mask::blue )
+		.field( "alpha", &color_mask::alpha )
+		;
+
+	db->create_type<scissor_test>()
+		.field( "enabled", &scissor_test::enabled )
+		.field( "pos",     &scissor_test::pos )
+		.field( "dim",     &scissor_test::dim )
+		;
+
+	db->create_type<buffer_mask>()
+		.value( "NO_BUFFER",              buffer_mask::NO_BUFFER )
+		.value( "COLOR_BUFFER",           buffer_mask::COLOR_BUFFER )
+		.value( "DEPTH_BUFFER",           buffer_mask::DEPTH_BUFFER )
+		.value( "STENCIL_BUFFER",         buffer_mask::STENCIL_BUFFER )
+		.value( "COLOR_AND_DEPTH_BUFFER", buffer_mask::COLOR_AND_DEPTH_BUFFER )
+		.value( "ALL_BUFFERS",            buffer_mask::ALL_BUFFERS )
+		;
+
+	db->create_type<clear_state>()
+		.field( "scissor_test",              &clear_state::scissor_test )
+		.field( "color_mask",                &clear_state::color_mask )
+		.field( "depth_mask",                &clear_state::depth_mask )
+		.field( "front_stencil_mask",        &clear_state::front_stencil_mask )
+		.field( "back_stencil_mask",         &clear_state::back_stencil_mask )
+		.field( "buffers",                   &clear_state::buffers )
+		.field( "color",                     &clear_state::color )
+		.field( "depth",                     &clear_state::depth )
+		.field( "stencil",                   &clear_state::stencil )
+		;
+
+	db->create_type<depth_test::function_type>()
+		.value( "NEVER",            depth_test::function_type::NEVER )
+		.value( "LESS",             depth_test::function_type::LESS )
+		.value( "EQUAL",            depth_test::function_type::EQUAL )
+		.value( "LESS_OR_EQUAL",    depth_test::function_type::LESS_OR_EQUAL )
+		.value( "GREATER",          depth_test::function_type::GREATER )
+		.value( "NOT_EQUAL",        depth_test::function_type::NOT_EQUAL )
+		.value( "GREATER_OR_EQUAL", depth_test::function_type::GREATER_OR_EQUAL )
+		.value( "ALWAYS",           depth_test::function_type::ALWAYS )
+		;
+
+	db->create_type<depth_test>()
+		.field( "enabled", &depth_test::enabled )
+		.field( "function", &depth_test::function )
+		;
+
+	db->create_type<polygon_mode::fill_type>()
+		.value( "POINT", polygon_mode::fill_type::POINT )
+		.value( "LINE",  polygon_mode::fill_type::LINE )
+		.value( "FILL",  polygon_mode::fill_type::FILL )
+		;
+
+	db->create_type<polygon_mode>()
+		.field( "fill", &polygon_mode::fill )
+		;
+
+	db->create_type<blending::factor>()
+		.value( "ZERO",                     blending::factor::ZERO )
+		.value( "ONE",                      blending::factor::ONE )
+		.value( "SRC_COLOR",                blending::factor::SRC_COLOR )
+		.value( "SRC_ALPHA",                blending::factor::SRC_ALPHA )
+		.value( "DST_COLOR",                blending::factor::DST_COLOR )
+		.value( "DST_ALPHA",                blending::factor::DST_ALPHA )
+		.value( "CONSTANT_COLOR",           blending::factor::CONSTANT_COLOR )
+		.value( "CONSTANT_ALPHA",           blending::factor::CONSTANT_ALPHA )
+		.value( "ONE_MINUS_SRC_COLOR",      blending::factor::ONE_MINUS_SRC_COLOR )
+		.value( "ONE_MINUS_SRC_ALPHA",      blending::factor::ONE_MINUS_SRC_ALPHA )
+		.value( "ONE_MINUS_DST_COLOR",      blending::factor::ONE_MINUS_DST_COLOR )
+		.value( "ONE_MINUS_DST_ALPHA",      blending::factor::ONE_MINUS_DST_ALPHA )
+		.value( "ONE_MINUS_CONSTANT_COLOR", blending::factor::ONE_MINUS_CONSTANT_COLOR )
+		.value( "ONE_MINUS_CONSTANT_ALPHA", blending::factor::ONE_MINUS_CONSTANT_ALPHA )
+		.value( "SRC_ALPHA_SATURATE",       blending::factor::SRC_ALPHA_SATURATE )
+		;
+
+	db->create_type<blending::equation>()
+		.value( "ADD",              blending::equation::ADD )
+		.value( "MINIMUM",          blending::equation::MINIMUM )
+		.value( "MAXIMUM",          blending::equation::MAXIMUM )
+		.value( "SUBTRACT",         blending::equation::SUBTRACT )
+		.value( "REVERSE_SUBTRACT", blending::equation::REVERSE_SUBTRACT )
+		;
+
+	db->create_type<blending>()
+		.field( "enabled",          &blending::enabled )
+		.field( "src_rgb_factor",   &blending::src_rgb_factor )
+		.field( "src_alpha_factor", &blending::src_alpha_factor )
+		.field( "dst_rgb_factor",   &blending::dst_rgb_factor )
+		.field( "dst_alpha_factor", &blending::dst_alpha_factor )
+		.field( "rgb_equation",     &blending::rgb_equation )
+		.field( "alpha_equation",   &blending::alpha_equation )
+		.field( "color",            &blending::color )
+		;
+
+	db->create_type<stencil_test_face::operation>()
+		.value( "ZERO",           stencil_test_face::operation::ZERO )
+		.value( "INVERT",         stencil_test_face::operation::INVERT )
+		.value( "KEEP",           stencil_test_face::operation::KEEP )
+		.value( "REPLACE",        stencil_test_face::operation::REPLACE )
+		.value( "INCREMENT",      stencil_test_face::operation::INCREMENT )
+		.value( "DECREMENT",      stencil_test_face::operation::DECREMENT )
+		.value( "INCREMENT_WRAP", stencil_test_face::operation::INCREMENT_WRAP )
+		.value( "DECREMENT_WRAP", stencil_test_face::operation::DECREMENT_WRAP )
+		;
+
+	db->create_type<stencil_test_face::function_type>()
+		.value( "NEVER",            stencil_test_face::function_type::NEVER )
+		.value( "LESS",             stencil_test_face::function_type::LESS )
+		.value( "EQUAL",            stencil_test_face::function_type::EQUAL )
+		.value( "LESS_OR_EQUAL",    stencil_test_face::function_type::LESS_OR_EQUAL )
+		.value( "GREATER",          stencil_test_face::function_type::GREATER )
+		.value( "NOT_EQUAL",        stencil_test_face::function_type::NOT_EQUAL )
+		.value( "GREATER_OR_EQUAL", stencil_test_face::function_type::GREATER_OR_EQUAL )
+		.value( "ALWAYS",           stencil_test_face::function_type::ALWAYS )
+		;
+
+	db->create_type<stencil_test_face>()
+		.field( "op_fail",       &stencil_test_face::op_fail )
+		.field( "op_depth_pass", &stencil_test_face::op_depth_pass )
+		.field( "op_depth_fail", &stencil_test_face::op_depth_fail )
+		.field( "function",      &stencil_test_face::function )
+		.field( "ref_value",     &stencil_test_face::ref_value )
+		.field( "mask",          &stencil_test_face::mask )
+		;
+
+	db->create_type<stencil_test>()
+		.field( "enabled",       &stencil_test::enabled )
+		.field( "front_face",    &stencil_test::front_face )
+		.field( "back_face",     &stencil_test::back_face )
+		;
+
+	db->create_type<culling::face_type>()
+		.value( "FRONT",          culling::face_type::FRONT )
+		.value( "BACK",           culling::face_type::BACK )
+		.value( "FRONT_AND_BACK", culling::face_type::FRONT_AND_BACK )
+		;
+
+	db->create_type<culling::order_type>()
+		.value( "CW",  culling::order_type::CW )
+		.value( "CCW", culling::order_type::CCW )
+		;
+
+	db->create_type<culling>()
+		.field( "enabled", &culling::enabled )
+		.field( "face",    &culling::face )
+		.field( "order",   &culling::order )
+		;
+
+	db->create_type<depth_range>()
+		.field( "near", &depth_range::near )
+		.field( "far",  &depth_range::far )
+		;
+
+	db->create_type<render_state>()
+		.field( "stencil_test", &render_state::stencil_test )
+		.field( "depth_test",   &render_state::depth_test )
+		.field( "scissor_test", &render_state::scissor_test )
+		.field( "depth_range",  &render_state::depth_range )
+		.field( "blending",     &render_state::blending )
+		.field( "culling",      &render_state::culling )
+		.field( "color_mask",   &render_state::color_mask )
+		.field( "polygon_mode", &render_state::polygon_mode )
+		.field( "multisample",  &render_state::multisample )
+		.field( "depth_mask",   &render_state::depth_mask )
+		;
+}
+
