Changeset 2768 for GTP/trunk/App/Demos
- Timestamp:
- 06/17/08 23:08:39 (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/Material.h
r2767 r2768 62 62 friend Material RandomMaterial(); 63 63 64 Texture *GetTexture() const { return mTexture; }64 inline Texture *GetTexture() const { return mTexture; } 65 65 66 66 void SetTexture(Texture *texture) { mTexture = texture; } -
GTP/trunk/App/Demos/Vis/CHC_revisited/RenderQueue.cpp
r2767 r2768 5 5 #include "Material.h" 6 6 7 8 using namespace std; 7 9 8 10 … … 13 15 inline static bool IsLower(SceneEntity *ent1, SceneEntity *ent2) 14 16 { 15 if (ent1->GetGeometry()->HasTexture() && ent2->GetGeometry()->HasTexture()) 16 { 17 Texture *t1 = ent1->GetMaterial()->GetTexture(); 18 Texture *t2 = ent1->GetMaterial()->GetTexture(); 17 Texture *t1 = ent1->GetMaterial()->GetTexture(); 18 Texture *t2 = ent2->GetMaterial()->GetTexture(); 19 19 20 return t1->GetByteSize() < t2->GetByteSize(); 21 } 22 else if (ent2->GetGeometry()->HasTexture()) 23 { 24 return true; 25 } 20 int tsize1 = t1 ? t1->GetByteSize() : 0; 21 int tsize2 = t2 ? t2->GetByteSize() : 0; 26 22 27 return false; 23 if (tsize1 == tsize2) 24 return ent1->GetMaterial() < ent2->GetMaterial(); 25 26 return tsize1 < tsize2; 28 27 } 29 30 28 31 29 … … 65 63 { 66 64 Sort(); 67 65 66 //if (!mEntities.empty()) Debug << "rendering render queue" << endl; 68 67 SceneEntityContainer::const_iterator sit, sit_end = mEntities.end(); 69 68 … … 72 71 SceneEntity *ent = *sit; 73 72 ent->Render(mState); 73 74 /*if (ent->GetMaterial()->GetTexture()) 75 Debug << " " << ent->GetMaterial()->GetTexture()->GetWidth(); 76 else 77 Debug << " 0";*/ 74 78 } 75 79 } 76 77 80 78 81 79 82 void RenderQueue::Sort() 80 83 { 81 sort(mEntities.begin(), mEntities.end()); 84 //InitTiming(); 85 //long t1, t2; 86 //t1 = GetTime(); 87 88 sort(mEntities.begin(), mEntities.end(), IsLower); 89 90 //t2 = GetTime(); 91 //cout << "sort: " << TimeDiff(t1, t2) << endl; 82 92 } 83 93 -
GTP/trunk/App/Demos/Vis/CHC_revisited/RenderTraverser.cpp
r2767 r2768 35 35 mIsQueryMode(false), 36 36 mUseOptimization(true), 37 mFrameId(-1) 37 mFrameId(-1), 38 mUseRenderQueue(false) 38 39 { 39 40 } -
GTP/trunk/App/Demos/Vis/CHC_revisited/SceneEntity.h
r2767 r2768 58 58 int GetLastRendered() const; 59 59 60 Material *GetMaterial() const { return mMaterial; }60 inline Material *GetMaterial() const { return mMaterial; } 61 61 62 62 protected: -
GTP/trunk/App/Demos/Vis/CHC_revisited/Texture.cpp
r2767 r2768 1 1 #include "Texture.h" 2 #include "glInterface.h" 3 #include "common.h" 4 5 2 6 #include <IL/il.h> 3 #include "glInterface.h"4 7 #include <assert.h> 5 8 #include <iostream> … … 30 33 { 31 34 startil(); 32 33 if (!ilLoadImage(ILstring(filename.c_str()))) 35 string dummy=filename; 36 37 string::size_type posOfSpace = filename.find("bmp"); 38 39 if (posOfSpace < filename.size()) 40 dummy=string("../textures/trees/bark8.png"); 41 42 if (!ilLoadImage(ILstring(dummy.c_str()))) 34 43 { 35 cerr << "Image load error " << ilGetError() << ": " << filename<< endl;44 cerr << "Image load error " << ilGetError() << ": " << dummy << endl; 36 45 } 37 46 else … … 41 50 42 51 mFormat = FORMAT_RGBA; 52 mByteSize = mHeight * GetRowLength(); 43 53 mImage = malloc(GetByteSize()); 44 54 45 cout << "successfully loaded texture " << filename << endl; 55 Debug << "successfully loaded texture " << filename << " w " << mWidth << " h " << mHeight << endl; 56 46 57 ilCopyPixels(0, 0, 0, mWidth, mHeight, 1, IL_RGBA, IL_UNSIGNED_BYTE, mImage); 47 58 assert(ilGetError() == IL_NO_ERROR); … … 62 73 //glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); 63 74 //glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND); 75 64 76 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 77 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR); 78 79 //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 65 80 //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 66 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR); 81 67 82 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); 68 83 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); 69 84 70 gluBuild2DMipmaps(GL_TEXTURE_2D, 3, mWidth, mHeight, 71 GL_RGBA, GL_UNSIGNED_BYTE, mImage); 72 85 gluBuild2DMipmaps(GL_TEXTURE_2D, 3, mWidth, mHeight, GL_RGBA, GL_UNSIGNED_BYTE, mImage); 73 86 //glTexImage2D(GL_TEXTURE_2D, 0, 3, mWidth, mHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, mImage); 74 87 } … … 129 142 130 143 131 int Texture::GetByteSize() const132 {133 return mHeight * GetRowLength();134 }135 136 137 144 void Texture::Bind() const 138 145 { -
GTP/trunk/App/Demos/Vis/CHC_revisited/Texture.h
r2757 r2768 44 44 int GetPixelSize() const; 45 45 46 in t GetByteSize() const;46 inline int GetByteSize() const; 47 47 /** Bind the texture. 48 48 */ 49 49 void Bind() const; 50 51 50 52 51 53 protected: … … 61 63 std::string mName; 62 64 65 int mByteSize; 63 66 void *mImage; 64 67 }; 68 69 70 inline int Texture::GetByteSize() const 71 { 72 return mByteSize; 73 } 65 74 66 75 } -
GTP/trunk/App/Demos/Vis/CHC_revisited/chc_revisited.vcproj
r2767 r2768 253 253 </File> 254 254 <File 255 RelativePath=".\Timers.cpp"256 >257 </File>258 <File259 RelativePath=".\Timers.h"260 >261 </File>262 <File263 255 RelativePath=".\Triangle3.cpp" 264 256 > -
GTP/trunk/App/Demos/Vis/CHC_revisited/chcdemo.cpp
r2767 r2768 852 852 static long renderTime = traverser->GetStats().mRenderTime; 853 853 854 const float expFactor = 0. 9f;855 856 renderTime = renderTime * expFactor + (1.0f - expFactor) * traverser->GetStats().mRenderTime;854 const float expFactor = 0.5f; 855 856 renderTime = traverser->GetStats().mRenderTime * expFactor + (1.0f - expFactor) * renderTime; 857 857 858 858 if (renderTime) fps /= (float)renderTime;
Note: See TracChangeset
for help on using the changeset viewer.