Gamestudio Links
Zorro Links
Newest Posts
Script filename
by AndrewAMD. 08/24/19 18:52
Any Old Timers Still Around?
by pyramide. 08/24/19 18:23
Oanda FIFO issue?
by AndrewAMD. 08/24/19 12:10
IG plugin initial release
by Dalla. 08/24/19 06:06
Tutorial for Vector Graphics
by Dooley. 08/23/19 22:32
Issue with dataParse function
by byakuren81. 08/23/19 21:57
Multiplayer subscription
by Truth. 08/23/19 20:08
candle pattern on weekly bars
by AndrewAMD. 08/23/19 13:20
AUM Magazine
Latest Screens
The Space Between
Pogostuck: Rage With Your Friends
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Who's Online Now
8 registered members (AndrewAMD, pyramide, 3run, MatPed, byakuren81, Realspawn, 2 invisible), 646 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Ysbail, trader4321, GorgonzolaBYTE, Southqvist, tawin
18272 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: 926
Budapest
Aku_Aku Offline OP
User
Aku_Aku  Offline OP
User

Joined: Sep 2009
Posts: 926
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: 658
Germany
Ayumi Offline
User
Ayumi  Offline
User

Joined: Oct 2008
Posts: 658
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: 926
Budapest
Aku_Aku Offline OP
User
Aku_Aku  Offline OP
User

Joined: Sep 2009
Posts: 926
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: 658
Germany
Ayumi Offline
User
Ayumi  Offline
User

Joined: Oct 2008
Posts: 658
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,237
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,237
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: 658
Germany
Ayumi Offline
User
Ayumi  Offline
User

Joined: Oct 2008
Posts: 658
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,237
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,237
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: 658
Germany
Ayumi Offline
User
Ayumi  Offline
User

Joined: Oct 2008
Posts: 658
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: 926
Budapest
Aku_Aku Offline OP
User
Aku_Aku  Offline OP
User

Joined: Sep 2009
Posts: 926
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: 658
Germany
Ayumi Offline
User
Ayumi  Offline
User

Joined: Oct 2008
Posts: 658
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