Changeset 2768 for GTP/trunk/App


Ignore:
Timestamp:
06/17/08 23:08:39 (16 years ago)
Author:
mattausch
Message:

debug version

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  
    6262  friend Material RandomMaterial(); 
    6363 
    64   Texture *GetTexture() const { return mTexture; } 
     64  inline Texture *GetTexture() const { return mTexture; } 
    6565 
    6666  void SetTexture(Texture *texture) { mTexture = texture; } 
  • GTP/trunk/App/Demos/Vis/CHC_revisited/RenderQueue.cpp

    r2767 r2768  
    55#include "Material.h" 
    66 
     7 
     8using namespace std; 
    79 
    810 
     
    1315inline static bool IsLower(SceneEntity *ent1, SceneEntity *ent2) 
    1416{ 
    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(); 
    1919 
    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; 
    2622 
    27         return false; 
     23        if (tsize1 == tsize2) 
     24                return ent1->GetMaterial() < ent2->GetMaterial(); 
     25 
     26        return tsize1 < tsize2; 
    2827} 
    29  
    3028 
    3129 
     
    6563{ 
    6664        Sort(); 
    67  
     65         
     66        //if (!mEntities.empty()) Debug << "rendering render queue" << endl; 
    6867        SceneEntityContainer::const_iterator sit, sit_end = mEntities.end(); 
    6968 
     
    7271                SceneEntity *ent = *sit; 
    7372                ent->Render(mState); 
     73 
     74                /*if (ent->GetMaterial()->GetTexture()) 
     75                        Debug << " " << ent->GetMaterial()->GetTexture()->GetWidth(); 
     76                else 
     77                        Debug << " 0";*/ 
    7478        } 
    7579} 
    76  
    7780         
    7881 
    7982void RenderQueue::Sort() 
    8083{ 
    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; 
    8292} 
    8393 
  • GTP/trunk/App/Demos/Vis/CHC_revisited/RenderTraverser.cpp

    r2767 r2768  
    3535mIsQueryMode(false), 
    3636mUseOptimization(true), 
    37 mFrameId(-1) 
     37mFrameId(-1), 
     38mUseRenderQueue(false) 
    3839{ 
    3940} 
  • GTP/trunk/App/Demos/Vis/CHC_revisited/SceneEntity.h

    r2767 r2768  
    5858        int GetLastRendered() const; 
    5959 
    60         Material *GetMaterial() const  { return mMaterial; } 
     60        inline Material *GetMaterial() const  { return mMaterial; } 
    6161 
    6262protected: 
  • GTP/trunk/App/Demos/Vis/CHC_revisited/Texture.cpp

    r2767 r2768  
    11#include "Texture.h" 
     2#include "glInterface.h" 
     3#include "common.h" 
     4 
     5 
    26#include <IL/il.h> 
    3 #include "glInterface.h" 
    47#include <assert.h> 
    58#include <iostream> 
     
    3033{ 
    3134        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()))) 
    3443        { 
    35                 cerr << "Image load error " << ilGetError() << ": " << filename << endl; 
     44                cerr << "Image load error " << ilGetError() << ": " << dummy << endl; 
    3645        } 
    3746        else 
     
    4150 
    4251                mFormat = FORMAT_RGBA; 
     52                mByteSize = mHeight * GetRowLength(); 
    4353                mImage = malloc(GetByteSize()); 
    4454 
    45                 cout << "successfully loaded texture " << filename << endl; 
     55                Debug << "successfully loaded texture " << filename << " w " << mWidth << " h " << mHeight << endl; 
     56 
    4657                ilCopyPixels(0, 0, 0, mWidth, mHeight, 1, IL_RGBA, IL_UNSIGNED_BYTE, mImage); 
    4758                assert(ilGetError() == IL_NO_ERROR); 
     
    6273        //glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); 
    6374        //glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND); 
     75         
    6476        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); 
    6580        //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 
    66         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR); 
     81 
    6782        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); 
    6883        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); 
    6984 
    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); 
    7386        //glTexImage2D(GL_TEXTURE_2D, 0, 3, mWidth, mHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, mImage); 
    7487} 
     
    129142 
    130143 
    131 int Texture::GetByteSize() const 
    132 { 
    133         return mHeight * GetRowLength(); 
    134 } 
    135  
    136  
    137144void Texture::Bind() const 
    138145{ 
  • GTP/trunk/App/Demos/Vis/CHC_revisited/Texture.h

    r2757 r2768  
    4444        int GetPixelSize() const; 
    4545         
    46         int GetByteSize() const; 
     46        inline int GetByteSize() const; 
    4747        /** Bind the texture. 
    4848        */ 
    4949        void Bind() const; 
     50 
     51 
    5052 
    5153protected: 
     
    6163        std::string mName; 
    6264 
     65        int mByteSize; 
    6366        void *mImage; 
    6467}; 
     68 
     69 
     70inline int Texture::GetByteSize() const 
     71{ 
     72        return mByteSize; 
     73} 
    6574 
    6675} 
  • GTP/trunk/App/Demos/Vis/CHC_revisited/chc_revisited.vcproj

    r2767 r2768  
    253253                        </File> 
    254254                        <File 
    255                                 RelativePath=".\Timers.cpp" 
    256                                 > 
    257                         </File> 
    258                         <File 
    259                                 RelativePath=".\Timers.h" 
    260                                 > 
    261                         </File> 
    262                         <File 
    263255                                RelativePath=".\Triangle3.cpp" 
    264256                                > 
  • GTP/trunk/App/Demos/Vis/CHC_revisited/chcdemo.cpp

    r2767 r2768  
    852852        static long renderTime = traverser->GetStats().mRenderTime; 
    853853 
    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; 
    857857 
    858858        if (renderTime) fps /= (float)renderTime; 
Note: See TracChangeset for help on using the changeset viewer.