Ignore:
Timestamp:
10/09/08 18:36:03 (16 years ago)
Author:
mattausch
Message:

detected memory leaks mainly in shadowmapping!!
strange problems with deferred rendering, seems to be uninitialized sometimes (solved?)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r3018 r3019  
    11// chcdemo.cpp : Defines the entry point for the console application. 
    22// 
    3 #include "glInterface.h" 
     3 
     4#ifdef _CRT_SET 
     5        #define _CRTDBG_MAP_ALLOC 
     6        #include <stdlib.h> 
     7        #include <crtdbg.h> 
     8#endif 
     9 
     10#include "common.h" 
     11 
     12#ifdef _CRT_SET 
     13        // redefine new operator 
     14        #define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__) 
     15        #define new DEBUG_NEW 
     16#endif 
     17 
     18 
    419#include <math.h> 
    520#include <time.h> 
    6 #include "common.h" 
     21#include "glInterface.h" 
     22 
     23#include <Cg/cg.h> 
     24#include <Cg/cgGL.h> 
     25 
     26 
    727#include "RenderTraverser.h" 
    828#include "SceneEntity.h" 
     
    4060#include "EntityMerger.h" 
    4161 
    42 #include <Cg/cg.h> 
    43 #include <Cg/cgGL.h> 
    44  
    45  
    4662using namespace std; 
    4763using namespace CHCDemoEngine; 
     
    5975/// the renderable scene geometry 
    6076SceneEntityContainer sceneEntities; 
    61 SceneEntityContainer sceneEntities2; 
    6277 
    6378// traverses and renders the hierarchy 
     
    255270inline float KeyRotationAngle() { return keyRotation * elapsedTime * 1e-3f; } 
    256271inline float KeyShift() { return keyForwardMotion * elapsedTime * 1e-3f; } 
    257  
     272// initialise the frame buffer objects 
    258273void InitFBO(); 
    259274 
     
    309324int main(int argc, char* argv[]) 
    310325{ 
     326#ifdef _CRT_SET 
     327 
     328        //Now just call this function at the start of your program and if you're 
     329        //compiling in debug mode (F5), any leaks will be displayed in the Output 
     330        //window when the program shuts down. If you're not in debug mode this will 
     331        //be ignored. Use it as you will! 
     332        //note: from GDNet Direct [3.8.04 - 3.14.04] void detectMemoryLeaks() { 
     333 
     334        _CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF|_CRTDBG_ALLOC_MEM_DF); 
     335        _CrtSetReportMode(_CRT_ASSERT,_CRTDBG_MODE_FILE); 
     336        _CrtSetReportFile(_CRT_ASSERT,_CRTDBG_FILE_STDERR);  
     337#endif 
     338 
     339        cout << "=== reading environment file ===" << endl << endl; 
     340 
    311341        int returnCode = 0; 
    312342 
     
    317347        cout << "=== reading environment file ===" << endl << endl; 
    318348 
    319         string envFileName = "default.env"; 
     349        const string envFileName = "default.env"; 
    320350        if (!env.Read(envFileName)) 
    321351        { 
     
    347377                //env.GetStringParam(string("modelPath"), model_path); 
    348378                //env.GetIntParam(string("numSssaoSamples"), numSsaoSamples); 
    349  
    350379 
    351380                cout << "assumedVisibleFrames: " << assumedVisibleFrames << endl;  
     
    395424        SceneEntity::SetUseLODs(useLODs); 
    396425 
    397  
    398426        if (!useFullScreen) 
    399427        { 
     
    420448        InitGLstate(); 
    421449 
    422  
    423450        glEnable(GL_MULTISAMPLE_ARB); 
    424451        glHint(GL_MULTISAMPLE_FILTER_HINT_NV, GL_NICEST); 
     
    432459 
    433460        const string filename = string(model_path + "city.dem"); 
     461         
    434462 
    435463        if (loader->Load(filename, sceneEntities)) 
     
    441469                exit(0); 
    442470        } 
     471         
    443472 
    444473        const string bvh_filename = string(model_path + "city.bvh"); 
     
    452481                exit(0); 
    453482        } 
    454          
    455483 
    456484        // set far plane based on scene extent 
     
    468496         
    469497        Matrix4x4 transl = TranslationMatrix(cubeCenter); 
    470          
    471498 
    472499        SceneEntityContainer dummy; 
     
    474501        string skyDomeStr(model_path + "sky.dem"); 
    475502 
    476         if (loader->Load(skyDomeStr, dummy)) 
    477                 cout << "successfully loaded " << dummy.size() << " scene entities" << endl; 
     503        if (loader->Load(skyDomeStr, sceneEntities)) 
     504                cout << "successfully loaded " << sceneEntities.size() << " scene entities" << endl; 
    478505        else 
    479506        { 
     
    484511        } 
    485512 
    486         skyDome = dummy[0]; 
     513        skyDome = sceneEntities.back(); 
    487514 
    488515 
     
    506533        // clean up 
    507534        CleanUp(); 
    508  
     535         
    509536        return 0; 
    510537} 
     
    572599                cgGLLoadProgram(RenderState::sCgMrtFragmentProgram); 
    573600 
    574                 sEyePosParam = cgGetNamedParameter(RenderState::sCgMrtFragmentTexProgram, "eyePos"); 
     601                sEyePosParam = cgGetNamedParameter(RenderState::sCgMrtFragmentProgram, "eyePos"); 
    575602        } 
    576603        else 
     
    613640        glGenTextures(1, &fontTex); 
    614641        glBindTexture(GL_TEXTURE_2D, fontTex); 
     642 
    615643        if (!myfont.Create("data/fonts/verdana.glf", fontTex)) 
    616644                return false; 
     
    17471775        DEL_PTR(ssaoShader); 
    17481776 
     1777        DEL_PTR(light); 
     1778        DEL_PTR(visCamera); 
     1779 
     1780        DEL_PTR(preetham); 
     1781 
    17491782        if (sCgMrtVertexProgram) 
    17501783                cgDestroyProgram(sCgMrtVertexProgram); 
Note: See TracChangeset for help on using the changeset viewer.