Changeset 2781 for GTP/trunk/App/Demos/Vis/CHC_revisited
- Timestamp:
- 06/19/08 22:57:08 (17 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/CHC_revisited
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/CHC_revisited/BinaryLoader.cpp
r2776 r2781 15 15 16 16 17 BinaryLoader::~BinaryLoader() 18 { 19 /** delete all maps. 20 */ 21 std::map<int, Texture *>::iterator it, it_end = mTextureTable.end(); 22 23 for (it = mTextureTable.begin(); it != it_end; ++ it) 24 { 25 Texture *tex = (*it).second; 26 delete tex; 27 } 28 29 std::map<int, Material *>::iterator nit, nit_end = mMaterialTable.end(); 30 31 for (nit = mMaterialTable.begin(); nit != nit_end; ++ nit) 32 { 33 Material *mat = (*nit).second; 34 delete mat; 35 } 36 37 38 std::map<int, Geometry *>::iterator git, git_end = mGeometryTable.end(); 39 40 for (git = mGeometryTable.begin(); git != git_end; ++git) 41 { 42 Geometry *geom = (*git).second; 43 delete geom; 44 } 45 } 46 17 47 //SceneEntity *BinaryLoader::LoadSceneEntity(igzstream &str) 18 48 SceneEntity *BinaryLoader::LoadSceneEntity(ifstream &str) … … 119 149 str.read(reinterpret_cast<char *>(&mat->mDiffuseColor), sizeof(Vector3)); 120 150 str.read(reinterpret_cast<char *>(&mat->mSpecularColor), sizeof(Vector3)); 121 122 /*RgbColor dum;123 str.read(reinterpret_cast<char *>(&dum), sizeof(RgbColor));124 str.read(reinterpret_cast<char *>(&dum), sizeof(RgbColor));125 str.read(reinterpret_cast<char *>(&dum), sizeof(RgbColor));126 */127 151 } 128 152 … … 169 193 texcoords = NULL; 170 194 171 for (int i = 0; i < vertexCount; i += 3) 172 { 173 Triangle3 tri(vertices[i], vertices[i + 1], vertices[i + 2]); 174 Vector3 n = tri.GetNormal(); 175 176 normals[i + 0] = n; 177 normals[i + 1] = n; 178 normals[i + 2] = n; 179 } 180 181 return new Geometry(vertices, normals, texcoords, vertexCount); 195 return new Geometry(vertices, normals, texcoords, vertexCount, false); 182 196 } 183 197 -
GTP/trunk/App/Demos/Vis/CHC_revisited/BinaryLoader.h
r2776 r2781 25 25 public: 26 26 27 ~BinaryLoader(); 28 27 29 bool Load(const std::string &filename, SceneEntityContainer &geometry); 28 30 -
GTP/trunk/App/Demos/Vis/CHC_revisited/Camera.cpp
r2780 r2781 35 35 mRight = -Normalize(CrossProd(mDirection, mUp)); 36 36 37 38 float k = tan(mFovy/2); 37 /*float k = tan(mFovy/2); 39 38 mUp *= k; 40 mRight *= k*mWidth/mHeight; 39 mRight *= k*mWidth/mHeight;*/ 41 40 } 42 41 -
GTP/trunk/App/Demos/Vis/CHC_revisited/Geometry.cpp
r2776 r2781 11 11 Vector3 *normals, 12 12 float *texcoords, 13 int numVertices): 13 int numVertices, 14 bool delData): 14 15 mVertices(vertices), 15 16 mNormals(normals), … … 19 20 { 20 21 Prepare(); 22 23 if (delData) 24 { 25 delete [] mVertices; mVertices = NULL; 26 delete [] mNormals; mNormals = NULL; 27 if (!mTexCoords) delete [] mTexCoords; mTexCoords = NULL; 28 } 21 29 } 22 30 31 Geometry::~Geometry() 32 { 33 if (!mVertices) delete [] mVertices; 34 if (!mNormals) delete [] mNormals; 35 if (!mTexCoords) delete [] mTexCoords; 23 36 37 // delete vbo 38 glDeleteBuffersARB(1, &mVboId); 39 } 40 41 24 42 void Geometry::Prepare() 25 43 { -
GTP/trunk/App/Demos/Vis/CHC_revisited/Geometry.h
r2776 r2781 19 19 /** Constructor taking an array of triangles. 20 20 */ 21 Geometry(Vector3 *vertices, Vector3 *normals, float *texcoords, int numVertices); 21 Geometry(Vector3 *vertices, Vector3 *normals, float *texcoords, int numVertices, bool delData); 22 ~Geometry(); 22 23 /** Render the geometry 23 24 */ -
GTP/trunk/App/Demos/Vis/CHC_revisited/OcclusionQuery.cpp
r2776 r2781 64 64 65 65 QueryHandler::QueryHandler(): mCurrentQueryIdx(0) 66 {} 66 { 67 Allocate(1000); 68 } 67 69 68 70 … … 102 104 103 105 106 void QueryHandler::Allocate(int n) 107 { 108 unsigned int *ids = new unsigned int[n]; 109 glGenQueriesARB(n, ids); 110 111 for (int i = 0; i < n; ++ i) 112 { 113 OcclusionQuery *q = new OcclusionQuery(ids[i]); 114 mOcclusionQueries.push_back(q); 115 } 116 117 mCurrentQueryIdx = n; 118 delete [] ids; 119 } 120 104 121 105 122 } // namespace -
GTP/trunk/App/Demos/Vis/CHC_revisited/OcclusionQuery.h
r2776 r2781 16 16 class OcclusionQuery 17 17 { 18 friend class QueryHandler; 19 18 20 public: 19 21 /** constructor requesting an opengl occlusion query. … … 46 48 */ 47 49 inline int GetSize() const { return (int)mNodes.size();} 50 48 51 49 52 protected: 50 53 51 54 OcclusionQuery(unsigned int id): mQueryId(id) { } 55 52 56 /////// 53 57 //-- members … … 77 81 78 82 protected: 83 84 /** allocates n queries in advance 85 */ 86 void Allocate(int n); 87 88 89 //////////////// 79 90 80 91 int mCurrentQueryIdx; -
GTP/trunk/App/Demos/Vis/CHC_revisited/chcdemo.cpp
r2780 r2781 117 117 int main(int argc, char* argv[]) 118 118 { 119 int returnCode = 0; 120 121 #ifdef _CRT_SET 122 123 //Now just call this function at the start of your program and if you're 124 //compiling in debug mode (F5), any leaks will be displayed in the Output 125 //window when the program shuts down. If you're not in debug mode this will 126 //be ignored. Use it as you will! 127 //note: from GDNet Direct [3.8.04 - 3.14.04] void detectMemoryLeaks() { 128 129 _CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF|_CRTDBG_ALLOC_MEM_DF); 130 _CrtSetReportMode(_CRT_ASSERT,_CRTDBG_MODE_FILE); 131 _CrtSetReportFile(_CRT_ASSERT,_CRTDBG_FILE_STDERR); 132 #endif 133 134 119 135 camera = new Camera(winWidth, winHeight); 120 136 camera->SetNear(nearDist);
Note: See TracChangeset
for help on using the changeset viewer.