[Solved] Beginner's questions about GUI and Aspect2D

Return to C++ coding using Panda3D

[Solved] Beginner's questions about GUI and Aspect2D

Postby plaristote » Sat May 12, 2012 2:18 pm

Greetings !

I'm all new to this game engine (and even new to every 3d thingy, for that matter), and I'm working on an easy game to get introduced. :D

Up until now I've been doing pretty good on my own, but now I'm working with PGButton and I'm wondering a few things.

Like, initially, everything that you put under the aspect2d node will get rendered in a position relative to the camera.
What if I don't want that ? And especially, what if I want the node to be initially placed relatively to the camera, but to stay where it is if the camera moves ?

And second question is about PGButton.
I have no problem creating buttons, but I do have some issues getting rid of them.
If I store a pointer to PGButton, when I try to delete it, the whole thing crash (claming that a virtual pure method has been called...).

Right now I get rid of the menu by removing the NodePath. But I don't think the PGButton is cleaned afterwards, is it ?
And if not, I need to delete it myself... what's the procedure to do that ? I noticed that I can't start using "delete" on the button pointer as soon as I used setup or set_frame.

I can only delete the PGButton before I create attach its node to aspect2d.
If I try deleting it right after that, I got this :
Code: Select all
Assertion failed: _ref_count == 0 || _ref_count == local_ref_count at line 129 of built/include/referenceCount.I
game: built/include/mutexPosixImpl.I:129: void ReMutexPosixImpl::acquire(): Assertion `result == 0' failed


And if I try to do it later, I got this whole "virtual pure method called" thingy.

I thank thee for helpin !
Good day !
Last edited by plaristote on Mon May 14, 2012 11:10 am, edited 1 time in total.
Potato.
plaristote
 
Posts: 75
Joined: Sat May 12, 2012 2:02 pm

Postby rdb » Mon May 14, 2012 4:11 am

If you're using Panda's reference counting system, you're not allowed to delete objects yourself. Just let them go out of scope. Be sure to wrap reference counted object in a PT() instead of an ordinary pointer.
rdb
 
Posts: 8637
Joined: Mon Dec 04, 2006 5:58 am
Location: Netherlands

Postby plaristote » Mon May 14, 2012 11:10 am

Thank you !
It's neat to finally know what PT is actually for ! I added it and indeed there are no leaks at all in my game.

I also found several way to work around the static/not static UI problem. So I'm going to mark this thread as solved.
Potato.
plaristote
 
Posts: 75
Joined: Sat May 12, 2012 2:02 pm


Return to C++ coding using Panda3D

Who is online

Users browsing this forum: No registered users and 0 guests