Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, TipmyPip, Edgar_Herrera), 804 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Working with digits #476678
03/22/19 10:50
03/22/19 10:50
Joined: Sep 2009
Posts: 991
Budapest
Aku_Aku Offline OP
User
Aku_Aku  Offline OP
User

Joined: Sep 2009
Posts: 991
Budapest
On a PANEL i can create or modify digits with the pan_setdigits(...) function.
How can i delete such a digits?
If i delete (remove) a PANEL, will all its digits be deleted?

Re: Working with digits [Re: Aku_Aku] #476680
03/22/19 12:32
03/22/19 12:32
Joined: Oct 2008
Posts: 679
Germany
Ayumi Offline
User
Ayumi  Offline
User

Joined: Oct 2008
Posts: 679
Germany
You can not delete the digits, just delete the Panel and create new one.
All Panel-Elements are automatically removed.

Re: Working with digits [Re: Ayumi] #476684
03/22/19 18:03
03/22/19 18:03
Joined: Sep 2009
Posts: 991
Budapest
Aku_Aku Offline OP
User
Aku_Aku  Offline OP
User

Joined: Sep 2009
Posts: 991
Budapest
Thanks for the answer.
Does it mean, if a Panel is deleted, all the elements related with that will be removed?
digits, buttons and so on...?
Final question: all the allocated memory will be released?
For example, if a button has an image, the allocated memory of the image will be also released automatically?

Re: Working with digits [Re: Aku_Aku] #476685
03/22/19 22:44
03/22/19 22:44
Joined: Oct 2008
Posts: 679
Germany
Ayumi Offline
User
Ayumi  Offline
User

Joined: Oct 2008
Posts: 679
Germany
Quote:
Does it mean, if a Panel is deleted, all the elements related with that will be removed?


Sure

Quote:
Final question: all the allocated memory will be released?


I am not ...sure.

Quote:
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 Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
Originally Posted By: Ayumi
Quote:
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'.

Code:
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: 679
Germany
Ayumi Offline
User
Ayumi  Offline
User

Joined: Oct 2008
Posts: 679
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 Offline
Serious User
txesmi  Offline
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:

Code:
#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 wink

Re: Working with digits [Re: txesmi] #476694
03/23/19 13:36
03/23/19 13:36
Joined: Oct 2008
Posts: 679
Germany
Ayumi Offline
User
Ayumi  Offline
User

Joined: Oct 2008
Posts: 679
Germany
Quote:
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: 991
Budapest
Aku_Aku Offline OP
User
Aku_Aku  Offline OP
User

Joined: Sep 2009
Posts: 991
Budapest
Thanks guys for the answers. I hope i understood well all of them.
But one thing remained:
Quote:
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: 679
Germany
Ayumi Offline
User
Ayumi  Offline
User

Joined: Oct 2008
Posts: 679
Germany
@Aku_Aku

Code:
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.
Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1