void CStdUtilsTestDlg::OnTestStrings() 
{
	unsigned char iUChar = 1;
	unsigned short iUShort=5;
	int iInt = 10;
	long lLong = 15;
	float fltFloat = (float) 5.3;
	double dblDouble = 7.5;
	bool bBool = true;

try
{
//	LOG_TEMP(StdLogInfo, "Test Val %d, Float: %f", 5403, dblDouble);

	CStdString strVal;

	strVal = (int) iUChar;
	strVal = iUShort;
	strVal = iInt;
	strVal = lLong;
	strVal = fltFloat;
	strVal = dblDouble;

	CStdString strUShort(iUShort), strInt(iInt), strLong(lLong);
	CStdString strFloat(fltFloat), strDouble(dblDouble);
	CStdString strTest1("The Test value is : ");
	CStdString strTest2(" Is the test value.");

	strVal = strTest1 + STR(iInt);
	strVal = strTest1 + STR(lLong);
	strVal = strTest1 + STR(fltFloat);
	strVal = strTest1 + STR(dblDouble);

	strVal = STR(iInt) + strTest2;
	strVal = STR(lLong) + strTest2;
	strVal = STR(fltFloat) + strTest2;
	strVal = STR(dblDouble) + strTest2;

	strVal = "This is a test: " + STR(iInt);
	strVal = "This is a test: " + STR(lLong);
	strVal = "This is a test: " + STR(fltFloat);
	strVal = "This is a test: " + STR(bBool);
	strVal = "This is a test: " + STR("100");

	TRACE_INFO("This is a test. Test Value: " + STR(lLong));
	TRACE_DETAIL("Fitness: " + STR(fltFloat));

	strVal = "This is a test: " + FSTR("%5.2f", fltFloat);

	Test1();
}
catch(CStdErrorInfo oError)
{
	CStdString strError = oError.Log();
	CString strMSError = strError.c_str();
	AfxMessageBox(strMSError);
}
catch(...)
{AfxMessageBox("Unidentified Error");}
}
Esempio n. 2
0
int main( ) {
	config.load( "config.cfg" );
	if( config.error( ) ) {
		puts( "Error loading config." );
		return 1;
	}

	rc::MessageHandler hMessages;
	rc::registerMessageHandler( &hMessages );

	rc::init( "KakaTD", (int)config.getNum("xres"), (int)config.getNum("yres"), (int)config.getNum("zres"), config.getNum("fullscreen") > 0.01f, config.getNum("fov"), config.getNum("near"), config.getNum("far"), (int)config.getNum("depth"), (int)config.getNum("fsaa"), (int)config.getNum("stencil"), (int)config.getNum("accum") );
	handleMessages( );

	rc::Shader::global = "const vec3 lightDir = vec3( 0.5, 0.0, 0.866 );\n";
	if( (int)config.getNum("pcf") ) rc::Shader::global += "#define PCF\n";
	rc::Shader::global += "#define SHADOWMAPSIZE " + strFloat((float)config.getNum("shadowmapres")) + "\n";
	rc::Shader::global += "#line 0\n";

	culling::setup( config.getNum("fov"), config.getNum("xres") / config.getNum("yres"), 60.0f );
	camera::setup( config.getNum("heightSpeed"), config.getNum("heightMoveSmoothness"), (int)config.getNum("moveBorder"), config.getNum("moveSpeed"), config.getNum("lookAngle"), config.getNum("targetHeight") );
	map::setup( config.getString("map").c_str( ) );
	shadows::setup( (int)config.getNum("shadowmapres"), config.getNum("bilinearpcf") > 0.01f );

	rc::Object pickMarker;
	pickMarker.setMesh( rc::getRessource<rc::Mesh>( "media/cube2" ) );
	pickMarker.setTexture( rc::getRessource<rc::Texture>( "media/spawn.png" ) );
	pickMarker.scale( Eigen::Vector3f( 0.01f, 0.01f, 0.01f ) );
	pickMarker.position( Eigen::Vector3f( 0.0f, 0.0f, 0.0f ) );

	rc::Shader* towerShader = rc::getRessource<rc::Shader>( "media/tower.vert;media/tower.frag" );
	towerShader->defaultUniforms.add( rc::uniform::SAMPLER, "shadowMap", &rc::Texture::sampler1 );
	towerShader->defaultUniforms.add( rc::uniform::MAT4 | rc::uniform::FLOAT, "lightMVP", shadows::lightMVP );
	towerShader->defaultUniforms.add( rc::uniform::MAT4 | rc::uniform::FLOAT, "objectMVP", rc::Object::MVP );

	rc::Renderable::finishInitialization( );
	/*for( std::list<rc::Renderable*>::iterator i = rc::Renderable::renderables.begin( ); i != rc::Renderable::renderables.end( ); ++i) {
		printf( "%d\n", (*i)->hash( ) );
	};*/
	puts( "------------------------------------------------- Start ");

	time_t next = clock( );
	int frameCounter = 0;
	double t0 = 0.0, t1 = 0.0;
	glfwSetTime(0.0);
	Eigen::Vector2i pickPos = Eigen::Vector2i( -1, -1 );
	bool lastEnter = false;
	bool lastClick = false;
	do {
		t0 = glfwGetTime();
		//float speed = ((t0.tv_sec - t1.tv_sec) * 1000000 + (t0.tv_usec - t1.tv_usec)) * 0.0001f;
		//shaderTime = (t0.tv_sec * 1000000 + t0.tv_usec) * 0.000001f;
		float speed = (float)(t0 - t1) * 100.0f;
		shaderTime = (float)t0 * 1.0f;
		t1 = t0;

		bool click = glfwGetMouseButton( GLFW_MOUSE_BUTTON_LEFT ) == GLFW_PRESS;
		if( pickPos.x( ) != -1 ) {
			map::GridField* field = map::mapGrid + pickPos.y( )*map::width + pickPos.x( );
			Eigen::Vector3f pos = Eigen::Vector3f( (pickPos.x( ) - map::width * 0.5f) * SPACING, field->type==map::GridField::RAISED?HEIGHT:0.0f, (pickPos.y( ) - map::height * 0.5f) * SPACING );
			pickMarker.position( pos );
			if( click && !lastClick ) {
				rc::Object* temp = new rc::Object;
				temp->setMesh( rc::getRessource<rc::Mesh>( "media/Blitz" ) );
				temp->setShader( rc::getRessource<rc::Shader>( "media/tower.vert;media/tower.frag" ) );
				temp->setTexture( &shadows::shadowMap, rc::Texture::sampler1 );
				temp->position( pos );
				temp->scale( Eigen::Vector3f( 0.024f, 0.024f, 0.03f ) );
				temp->orientation(Eigen::Vector3f(-(float)M_PI / 2.0f, 0.0f, 0.0f));
			}
		}
		lastClick = click;

		camera::update( speed );
		if( rc::getKey( GLFW_KEY_SPACE ) ) {
			camera::camPos = Eigen::Vector3f( 50.0f, 50.0f, -50.0f );
			camera::targetHeight = 50.0f;
		};

		bool enter = rc::getKey( GLFW_KEY_ENTER );
		if( enter && !lastEnter ) {

		};
		lastEnter = enter;

		//puts( "--------------------------------------- Frame ");
		// Rendering
		culling::update( );
		pickPos = picking::update( );
		shadows::update( );
		rc::update( );
		frameCounter++;
		handleMessages( );

		if( next < clock( ) ) {
			char Buf[256];
			sprintf( Buf, "FPS: %d, Rendered: %d, Texture-Switches: %d, Shader-Binds: %d, Polygons: %.3d", frameCounter, rc::Renderable::rendered, rc::Texture::binds, rc::Shader::binds, rc::Mesh::polysDrawn );
			puts( Buf );
			glfwSetWindowTitle( Buf );
			frameCounter = 0;
			next = clock( ) + CLOCKS_PER_SEC;
		};
	} while( rc::windowOpen( ) && !rc::getKey( GLFW_KEY_ESC ) );

	rc::terminate( );
	return 0;
}