2 registered members (AndrewAMD, NeoDumont),
761
guests, and 1
spider. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Working with digits
[Re: Aku_Aku]
#476685
03/22/19 22:44
03/22/19 22:44
|
Joined: Oct 2008
Posts: 681 Germany
Ayumi
User
|
User
Joined: Oct 2008
Posts: 681
Germany
|
Does it mean, if a Panel is deleted, all the elements related with that will be removed? Sure Final question: all the allocated memory will be released? I am not ...sure. For example, if a button has an image, the allocated memory of the image will be also released automatically? No,..this depend on your Pointer. Panel.bmap = bmap_create(...); -> This Image will be removed if the panel is deleted ---- BMAP* bmp = bmap_create(...); Panel.bmap = bmp; -> This Image will not be removed if the panel is deleted (if global )
Last edited by Ayumi; 03/23/19 10:48.
|
|
|
Re: Working with digits
[Re: Ayumi]
#476690
03/23/19 11:10
03/23/19 11:10
|
Joined: Jun 2007
Posts: 1,337 Hiporope and its pain
txesmi
Serious User
|
Serious User
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
|
For example, if a button has an image, the allocated memory of the image will be also released automatically? No,..this depend on your Pointer. Panel.bmap = bmap_create(...); -> This Image will be removed if the panel is deleted ---- BMAP* bmp = bmap_create(...); Panel.bmap = bmp; -> This Image will not be removed if the panel is deleted (because BMAP Pointer is global) I would bet that is wrong. I think the engine removes nothing but the globally declared stuff. You must remove everything you create by any of the '..._create' functions and, of course, all you allocate with 'sys_malloc'.
BMAP *gbBmp = "myImage.tga"; // This image is allocated and released by the engine automatically as far as ir is declared globally.
PANEL *gbPan = {
bmap = bgBmp; // This image will be removed as far as it is allocated in the program start by the engine, as happens with the PANEL struct.
window(200,0,40,20,"compass.pcx",compass_pos.x,compass_pos.y); // 'compass.pcx' will also be released when the panel is removed.
};
function myFnc() {
gbPan.bmap = bmap_create("myImage.tga"); // This image is not automatically released by the engine, does not matter where you save its reference. You must remove it when you are done.
}
|
|
|
Re: Working with digits
[Re: txesmi]
#476692
03/23/19 11:54
03/23/19 11:54
|
Joined: Oct 2008
Posts: 681 Germany
Ayumi
User
|
User
Joined: Oct 2008
Posts: 681
Germany
|
The manual said: bmap_createblack(var width, var height, var format): BMAP* Creates a bmap at runtime. bmap_create loads the content from an image file or from a cutout of an image , bmap_createblack creates a black bmap with given dimensions that can later be filled with a color. Objects created this way are automatically deleted on closing the engine, or by calling the ptr_remove function.
(and i already tryed this few month before) If you delete the Panel by ptr_remove, the BMAP (crated by bmap_create(); also will be removed by engine)
Last edited by Ayumi; 03/23/19 11:56.
|
|
|
Re: Working with digits
[Re: Ayumi]
#476693
03/23/19 13:15
03/23/19 13:15
|
Joined: Jun 2007
Posts: 1,337 Hiporope and its pain
txesmi
Serious User
|
Serious User
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
|
Ok. It is true. The engine frees all its structs at closing time. But 'ptr_remove' does not remove the bitmaps pointed by its elements. Take a look at this:
#include <acknex.h>
void main () {
wait(3);
PANEL *_pan = pan_create("flags=SHOW", 1);
_pan->bmap = bmap_createblack(128, 128, 24);
bmap_fill(_pan->bmap, COLOR_RED, 100);
while(!key_esc)
wait(1);
//bmap_remove(_pan->bmap);
ptr_remove(_pan);
while(key_esc){
DEBUG_BMAP(_pan->bmap, 1, 1);
wait(1);
}
sys_exit(NULL);
}
If you don't delete the bitmap before 'ptr_remove', it remains in the graphics card, so it is not deleted. Forgive the tricky thing of accesing hypothetically released memory
|
|
|
Re: Working with digits
[Re: txesmi]
#476694
03/23/19 13:36
03/23/19 13:36
|
Joined: Oct 2008
Posts: 681 Germany
Ayumi
User
|
User
Joined: Oct 2008
Posts: 681
Germany
|
If you don't delete the bitmap before 'ptr_remove', it remains in the graphics card, so it is not deleted. Forgive the tricky thing of accesing hypothetically released memory hehe yes,i know, because it s local created. Try panel.bmap = ent_create()...
|
|
|
Re: Working with digits
[Re: Ayumi]
#476695
03/23/19 14:38
03/23/19 14:38
|
Joined: Sep 2009
Posts: 993 Budapest
Aku_Aku
OP
User
|
OP
User
Joined: Sep 2009
Posts: 993
Budapest
|
Thanks guys for the answers. I hope i understood well all of them. But one thing remained: hehe yes,i know, because it s local created. Try panel.bmap = ent_create()... What is it?
|
|
|
Re: Working with digits
[Re: Aku_Aku]
#476696
03/23/19 15:05
03/23/19 15:05
|
Joined: Oct 2008
Posts: 681 Germany
Ayumi
User
|
User
Joined: Oct 2008
Posts: 681
Germany
|
@Aku_Aku
PANEL* Pan =
{
flags |= SHOW;
}
void Func()
{
Pan.bmap = ent_create("this.tga",...);
wait(1);
ptr_remove(Pan); -> delete bmap + panel by engine
}
Last edited by Ayumi; 03/23/19 15:05.
|
|
|
|