It is currently Thu Jul 20, 2017 7:33 pm

All times are UTC - 5 hours




 Page 1 of 1 [ 9 posts ] 
Author Message
 Post subject: Ghost VMK 3A->3E - Texture Manager
PostPosted: Thu May 29, 2008 6:35 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1102
Location: Ontario Canada
VMK 3A gives an introduction to the Texture Manager class which will be added to the game engine.

In VMK 3B I create the Texture Manager class which I'll be using to handle all my textures from now on. The Texture Manager allows you to load textures into "groups" for easy management of resources.

I upgrade the Texture class and add a new Vertex2i class to the game engine so that I can compile the Texture Manager in VMK 3C.

I update the Scene class so that I can start using the Texture Manager to handle all the loaded textures in VMK 3D/E. The game engine is cleaned up a little to. I move around all the static member variables from different classes.


Offline
 Profile  
 
 Post subject: Missing Code!
PostPosted: Fri Feb 12, 2010 8:13 am 

Joined: Sat Aug 16, 2008 7:58 am
Posts: 447
I am working in the the Texture Manager inside the LoadTexture() function. In the video, for the errorhandler where we are checking for textures already loaded into memory, you didn't scroll over far enough.

here is the code from video..
// Search To See If This File Has Already Been Loaded Into Memory
   for ( int iG = 0; iG < GROUP_LAST; iG++ )
   {
      for ( int i = 0; i < (int)m_vpTexture[iG].size(); i++ )
      {
         if ( strFile.compare( m_vpTexture[iG].at(i)->m_szFilename ) == 0 )
         {
            // The Texture Found In This Group Already
            if ( (Group)iG == group )
            {
               texID.uiID = i+1;
            }
            else
            {
               // Problem
               s_pErrorHandler->SetError( EC_GameError,
                                          "%s\nTexture found in Group_%d,
                                          but attempting to save in Group_%d.",
                                          ... );
               s_pErrorHandler->ShowErrorMessage();
               s_pErrorHandler->SetError( EC_NoError, "No Error." );
            }

            return texID;
         }
      }
   }


Where the elipse is these are the parameters that i can not see. By the looks of it im assuming that the first parameter is strFile.c_str(), but for the next two that is used to display which group, i have no idea.

Im not sure if you are using the iG index variable or using the actual group enum variable.

When you get a chance, can you post the two variables please. Thank You!


Offline
 Profile  
 
 Post subject:
PostPosted: Fri Feb 12, 2010 8:41 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1102
Location: Ontario Canada
Here is the code for the line that was clipped in the video:

s_pErrorHandler->setError(EC_GameError,"%s\nTexture found in Group_%d, but attempting to save in Group_%d.", strFile.c_str(), iG, group );


Offline
 Profile  
 
 Post subject: Thank You
PostPosted: Fri Feb 12, 2010 11:15 am 

Joined: Sat Aug 16, 2008 7:58 am
Posts: 447
My assumptions were right about the strFile.c_str(), and the first one being iG, but the last one where you used group (Would of been stumped on it for a very long time). This helps very much, now that I can progress throught he series


Offline
 Profile  
 
 Post subject: I think I may have found a Bug in VMK3D-E
PostPosted: Fri Feb 12, 2010 7:45 pm 

Joined: Sat Aug 16, 2008 7:58 am
Posts: 447
Where we implemented the TextureManager and move on to the Scene Update, after fixing all the errors throughout the scene class, I think I may have found a bug. I followed you through every step and when you had successfully compiled and ran the code, I was still getting 1 Error.

It has to do with the Scene::ClearAll() function. We modified this to now take a parameter Group group, which we corrected in the Scene class,
but there is one call to this function in the GameOGL class. This function is called in GameOGL's Destructor. I don't know if you missed this or corrected it and it just wasn't in the vidoe.

Here is the old code
// -------------------------------------------------------------------------------- //
// Name: ~GameOGL()
// Desc: Default Destructor
// ------------------------------------------------------------------------------- //
GameOGL::~GameOGL()
{
   if ( m_pScene )
   {
      m_pScene->ClearAll( group );
      SAFE_DELETE( m_pScene );
   }

   DestroyWnd();

} // ~GameOGL


And I did this to get it to work properly, (I think this is correct)
// ------------------------------------------------------------------------------- //
// Name: ~GameOGL()
// Desc: Default Destructor
// ------------------------------------------------------------------------------- //
GameOGL::~GameOGL()
{
   if ( m_pScene )
   {   
      Group group;
      m_pScene->ClearAll( group );
      SAFE_DELETE( m_pScene );
   }

   DestroyWnd();

} // ~GameOGL


I hope this helps! :)


Offline
 Profile  
 
 Post subject: Hmm It did compile and build successfully
PostPosted: Fri Feb 12, 2010 7:59 pm 

Joined: Sat Aug 16, 2008 7:58 am
Posts: 447
The program did run, but when I went to exit the program via the "Quit" button. There was an error stating that this variable was being used without being initialized Group group.


Offline
 Profile  
 
 Post subject: Would This Work ?
PostPosted: Fri Feb 12, 2010 10:50 pm 

Joined: Sat Aug 16, 2008 7:58 am
Posts: 447
After thinking about it for a little while, i was thinking that since we are no longer using 2 passes to delete all the textures in the scene's destructor, where the texture manager is now handling this, that we don't need to call the scenes ClearAll() function in the GameOGL Desctructor. This is already being called in the Scene's destructor. For now, I just rememoved this call so, my program will execute properly and I just hope that I don't have any memory leaks. I will continue to use the code in this way until I get your feedback about this issue.


Offline
 Profile  
 
 Post subject:
PostPosted: Sat Feb 13, 2010 12:21 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1102
Location: Ontario Canada
The destructor should look like this:

GameOGL::~GameOGL() {

   SAFE_DELETE(m_pScene);

   destroyWnd();
   
} //~GameOGL


Offline
 Profile  
 
 Post subject:
PostPosted: Sat Feb 13, 2010 1:14 am 

Joined: Sat Aug 16, 2008 7:58 am
Posts: 447
Thank You Marek. I don't know why, but maybe the Scene->ClearAll() function call was from an older video that I might have missed from removing it, It never gave me an error til now. Im about to finish up with the fonts for the texture manager. Moving along fairly quick :)


Offline
 Profile  
 
Display posts from previous:  Sort by  
 Page 1 of 1 [ 9 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  

cron