Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


to delete a mesh


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 karsnen   Members   -  Reputation: 110

Like
0Likes
Like

Posted 27 April 2011 - 12:27 AM

ppl,

I am loading a simple mesh file on the terrain. On collision I have to delete or destroy it.

Could someone pls help me out with this issue?

Sincerely karsnen.

Sponsor:

#2 karsnen   Members   -  Reputation: 110

Like
0Likes
Like

Posted 27 April 2011 - 12:27 AM

I forgot to mention that, my SDK is

DirectX 10

#3 programci_84   Members   -  Reputation: 335

Like
0Likes
Like

Posted 27 April 2011 - 11:14 PM

Hi,

Write a macro like that:
#define   _RELEASE_COM_(x)	if( (x) != NULL) { (x)->Release(); (x) = NULL; }

And use it on collide:
if (MyMeshCollides) 
	_RELEASE_COM_(pMyMesh);

And in rendering function, check whether it's NULL or not:
if (pMyMesh != NULL)
	RenderMyMesh();

hth.
-R
There's no "hard", and "the impossible" takes just a little time.

#4 rip-off   Moderators   -  Reputation: 8515

Like
1Likes
Like

Posted 28 April 2011 - 02:12 AM

@programci_84: You can and should use an inline function instead of a macro. In modern C++, the preprocessor is for conditional compilation, most other uses are discouraged to the point of effective deprecation.

Note that your macro evaluates it's argument multiple times, which could be problematic. Also it uses a reserved name, all names beginning with an underscore followed by an uppercase letter are reserved for the compiler, as are ones beginning with two underscores and identifiers beginning with a single underscore in the global namespace.

Something like this would be better:
inline void SafeRelease(IUnknown *& pointer)
{
    if(pointer)
    {
        pointer->Release();
        pointer = 0;
    }
}


#5 programci_84   Members   -  Reputation: 335

Like
0Likes
Like

Posted 28 April 2011 - 03:47 AM

Thanks for correcting me, rip-off.
There's no "hard", and "the impossible" takes just a little time.

#6 karsnen   Members   -  Reputation: 110

Like
0Likes
Like

Posted 28 April 2011 - 04:21 PM

@programci_84 & @ rip-off


Thank you. I will work it out and come back to you again. Actually I am having trouble in lighting. It seems that I have initialized two instances.


Source:
http://codepad.org/6siGDAy0

I hope you guys can understand it. If you guys could help. It would be really great.

Thank you.

Karsnen.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS