Changeset 2828 for GTP/trunk/App/Demos/Vis
- Timestamp:
- 07/10/08 11:02:46 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Environment.cpp
r2826 r2828 8 8 { 9 9 10 bool Environment::Read(const string &filename) 10 11 bool Environment::GetFloatParam(std::string &str, float &val) const 11 12 { 13 map<string, string>::const_iterator it = mParams.find(str); 14 15 if (it == mParams.end()) // parameter not found 16 return false; 17 18 val = (float)atof((*it).second.c_str()); 19 12 20 return true; 13 21 } 14 22 15 23 16 void Environment::Init() 24 bool Environment::GetIntParam(std::string &str, int &val) const 17 25 { 18 /*mAssumedVisibleFrames; 19 mMaxBatchSize; 26 map<string, string>::const_iterator it = mParams.find(str); 20 27 21 mTrianglesPerVirtualLeaf; 28 if (it == mParams.end()) // parameter not found 29 return false; 30 31 val = atoi((*it).second.c_str()); 22 32 23 mKeyForwardMotion;24 mKeyRotation; 33 return true; 34 } 25 35 26 mWinWidth;27 mWinHeight;28 36 29 mPosition; 30 */ 31 mUseFullScreen = false; 37 bool Environment::GetBoolParam(std::string &str, bool &val) const 38 { 39 map<string, string>::const_iterator it = mParams.find(str); 40 41 if (it == mParams.end()) // parameter not found 42 return false; 43 44 val = (bool)atoi((*it).second.c_str()); 45 46 return true; 47 } 48 49 50 bool Environment::GetVectorParam(std::string &str, Vector3 &val) const 51 { 52 map<string, string>::const_iterator it = mParams.find(str); 53 54 static vector<string> tokens; 55 tokens.clear(); 56 57 if (it == mParams.end()) // parameter not found 58 return false; 59 60 Tokenize((*it).second, tokens); 61 62 val.x = (float)atof(tokens[1].c_str()); 63 val.y = (float)atof(tokens[2].c_str()); 64 val.z = (float)atof(tokens[3].c_str()); 65 66 return true; 67 } 68 69 70 bool Environment::Read(const string &filename) 71 { 72 FILE *file; 73 if ((file = fopen(filename.c_str(), "rt")) == NULL) 74 return false; 75 76 char str[256]; 77 78 while (fgets(str, 256, file) != NULL) 79 { 80 static vector<string> tokens; 81 tokens.clear(); 82 83 Tokenize(str, tokens, "="); 84 85 // this line is a comment 86 if (tokens[0][0] == '#') 87 continue; 88 89 // store parameter 90 mParams[tokens[0]] = tokens[1]; 91 } 92 93 return true; 94 } 95 96 97 void Environment::Tokenize(const string& str, 98 vector<string> &tokens, 99 const string &delim) const 100 { 101 // skip delimiters the string begins with 102 string::size_type lastPos = str.find_first_not_of(delim, 0); 103 // find next delimiter 104 string::size_type pos = str.find_first_of(delim, lastPos); 105 106 // find tokens until string has been completely parsed 107 while ((string::npos != pos) || (string::npos != lastPos)) 108 { 109 // add new token 110 tokens.push_back(str.substr(lastPos, pos - lastPos)); 111 // skip delimiters, go to start of next token 112 lastPos = str.find_first_not_of(delim, pos); 113 // found next delimiter 114 pos = str.find_first_of(delim, lastPos); 115 } 32 116 } 33 117 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Environment.h
r2826 r2828 6 6 #include <iostream> 7 7 #include <fstream> 8 #include <map> 8 9 9 10 #include "common.h" … … 23 24 */ 24 25 bool Read(const std::string &filename); 25 /** Initialises the environment file with default values. 26 27 bool GetFloatParam(std::string &str, float &val) const; 28 bool GetIntParam(std::string &str, int &val) const; 29 bool GetVectorParam(std::string &str, Vector3 &val) const; 30 bool GetBoolParam(std::string &str, bool &val) const; 31 32 protected: 33 34 /** Parse this string, return tokens separated by given delimiters 26 35 */ 27 void Init();36 void Tokenize(const std::string& str, std::vector<std::string> &tokens, const std::string &delim = " ") const; 28 37 29 30 ////////// 31 //-- members 32 33 int mAssumedVisibleFrames; 34 int mMaxBatchSize; 35 36 int mTrianglesPerVirtualLeaf; 37 38 /// these values get scaled with the frame rate 39 float mKeyForwardMotion; 40 float mKeyRotation; 41 42 int mWinWidth; 43 int mWinHeight; 44 45 Vector3 mPosition; 46 Vector3 mDirection; 47 48 bool mUseFullScreen; 38 std::map<std::string, std::string> mParams; 49 39 }; 50 40 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/PerformanceGraph.cpp
r2827 r2828 6 6 mMaxData(maxData), mCurrentIdx(0) 7 7 { 8 mGraphColor[0] = 1.0f; 9 mGraphColor[1] = 0.0f; 10 mGraphColor[2] = 0.0f; 8 11 } 9 12 … … 88 91 const float scaley = 1.0f / 50.0f; 89 92 90 glColor 4f(1.0f, 0, 0, 1.0f);93 glColor3fv(mGraphColor); 91 94 92 95 glBegin(GL_LINE_STRIP); 93 94 //OUT1("data: " << mData.size());95 96 96 97 for (size_t i = 0; i < mData.size(); ++ i) … … 128 129 mData.clear(); 129 130 } 131 132 133 void PerformanceGraph::SetGraphColor(float *col) 134 { 135 mGraphColor[0] = col[0]; 136 mGraphColor[1] = col[1]; 137 mGraphColor[2] = col[2]; 138 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/PerformanceGraph.h
r2827 r2828 18 18 void Reset(); 19 19 20 void SetGraphColor(float *col); 20 21 21 22 protected: … … 29 30 int mMaxData; 30 31 int mCurrentIdx; 32 float mGraphColor[3]; 31 33 }; 32 34 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r2827 r2828 28 28 #include "glfont2.h" 29 29 #include "PerformanceGraph.h" 30 #include "Environment.h" 30 31 31 32 … … 34 35 35 36 37 static Environment env; 38 39 40 ///////////// 41 //-- textures 36 42 GLuint fbo; 37 43 … … 84 90 85 91 /// these values get scaled with the frame rate 86 conststatic float keyForwardMotion = 30.0f;87 conststatic float keyRotation = 1.5f;92 static float keyForwardMotion = 30.0f; 93 static float keyRotation = 1.5f; 88 94 89 95 /// elapsed time in milliseconds … … 103 109 104 110 // rendertexture 105 conststatic int texWidth = 1024;106 conststatic int texHeight = 768;107 // conststatic int texWidth = 2048;108 // conststatic int texHeight = 2048;111 static int texWidth = 1024; 112 static int texHeight = 768; 113 //static int texWidth = 2048; 114 //static int texHeight = 2048; 109 115 110 116 int renderedObjects = 0; … … 159 165 PerformanceGraph *perfGraph = NULL; 160 166 161 167 bool useFullScreen = false; 168 169 170 // ssao number of samples 162 171 #define NUM_SAMPLES 8 163 172 173 // ssao random spherical samples 164 174 static float samples[NUM_SAMPLES * 2]; 165 175 … … 281 291 int returnCode = 0; 282 292 293 env.Read("src/default.env"); 294 295 env.GetIntParam(string("assumedVisibleFrames"), assumedVisibleFrames); 296 env.GetIntParam(string("maxBatchSize"), maxBatchSize); 297 env.GetIntParam(string("trianglesPerVirtualLeaf"), trianglesPerVirtualLeaf); 298 299 env.GetFloatParam(string("keyForwardMotion"), keyForwardMotion); 300 env.GetFloatParam(string("keyForwardMotion"), keyRotation); 301 302 env.GetIntParam(string("winWidth"), winWidth); 303 env.GetIntParam(string("winHeight"), winHeight); 304 305 env.GetBoolParam(string("useFullScreen"), useFullScreen); 306 307 308 309 /////////////////////////// 310 283 311 camera = new Camera(winWidth, winHeight, fov); 284 312 camera->SetNear(nearDist); … … 295 323 glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); 296 324 297 #if 1 298 glutCreateWindow("FriendlyCulling"); 299 #else 300 glutGameModeString( "1024x768:32@75" ); //the settings for fullscreen mode 301 glutEnterGameMode(); //set glut to fullscreen using the settings in the line above 302 #endif 325 if (!useFullScreen) 326 glutCreateWindow("FriendlyCulling"); 327 else 328 { 329 glutGameModeString( "1024x768:32@75" ); 330 glutEnterGameMode(); 331 } 332 303 333 glutDisplayFunc(Display); 304 334 glutKeyboardFunc(KeyBoard); … … 1064 1094 algTime = algTimer.Elapsedms(); 1065 1095 perfGraph->AddData(algTime); 1096 1097 /*float col[3]; 1098 switch (renderMode) 1099 { 1100 case RenderTraverser::CHCPLUSPLUS: 1101 col[0] = 1.0f; col[1] = 0.0f; col[2] = 0.0f; 1102 break; 1103 case RenderTraverser::CHC: 1104 col[0] = 0.0f; col[1] = 1.0f; col[2] = 1.0f; 1105 break; 1106 case RenderTraverser::STOP_AND_WAIT: 1107 col[0] = 1.0f; col[1] = 1.0f; col[2] = 0.0f; 1108 break; 1109 case RenderTraverser::CULL_FRUSTUM: 1110 col[0] = 1.0f; col[1] = 0.0f; col[2] = 1.0f; 1111 break; 1112 default: 1113 col[0] = 1.0f; col[1] = 0.0f; col[2] = 0.0f; 1114 } 1115 perfGraph->SetGraphColor(col); 1116 */ 1066 1117 perfGraph->Draw(); 1067 1118 }
Note: See TracChangeset
for help on using the changeset viewer.