Sign in to follow this  

Deleting Selected Object

This topic is 4343 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hello everyone: I would like to load the object in and delete it freely. e.g. Load the object by File->Load (which i have already done) and then the other things is to delete the selected object. could anyone help me or give me some hints on how to delete the object in memory. all the loaded objects are stored in "vector<C3dsLoader> vObjects".
C3dsLoader obj3dsLoader;
vector<C3dsLoader> vObjects;


//when loading object, this will load the objects geometry into vObjects.
ZeroMemory(szPath, 200);
GetWindowsDirectory(szPath, 200);

if(!GetFilename(szPath))
return 0 ;
else
{
vObjects.push_back( obj3dsLoader );
vObjects[vObjects.size()-1].Init_3ds(szPath);
Load = TRUE;
}
break;

//When I draw the objects out in render scene

	if(load)
	{ 
		for ( int i =0 ; i< vObjects.size(); i++ )
		{
			if (mode == GL_SELECT) 
			{
				glPushName(i);
				vObjects[i].Render_3ds();
				glPopName();
	
			}
			else
				if(mode == GL_RENDER)
				vObjects[i].Render_3ds();
		}
	}


Millions of thanks

Share this post


Link to post
Share on other sites
You can't release the memory for the original C3dsLoader object obj3dsLoader. Since the vector creates a copy of that object, you would just use the vector to erase that copy. I believe it's vObjects.erase(index) or vObjects.delete(index). The proper function call escapes me at the moment.

Good luck,
Chris

Share this post


Link to post
Share on other sites

This topic is 4343 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this