本文整理汇总了C++中ConfigFile::getNum方法的典型用法代码示例。如果您正苦于以下问题:C++ ConfigFile::getNum方法的具体用法?C++ ConfigFile::getNum怎么用?C++ ConfigFile::getNum使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfigFile
的用法示例。
在下文中一共展示了ConfigFile::getNum方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
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;
//.........这里部分代码省略.........