Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (TipmyPip), 18,466 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Crash with pixel_to_vec #263596
04/30/09 18:22
04/30/09 18:22
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline OP
Expert
Matt_Aufderheide  Offline OP
Expert
M

Joined: Oct 2003
Posts: 4,131
can anyone tell me why this function crashes? I'm sure its something to with the line "if (temp_vec[0]==255)" ..in old c-script you used to be able to assign the pixel to temp and read it like temp.red ..this doesnt work in lite C apparently.

Code:
var treemask_array[256][256];

BMAP* treemask = "treemask.tga"; 

function init_treemask()
{	
	var format;
	var pixel;		
	var county=0;
	var countx=256;
	
	var temp_vec[3];

	format=bmap_lock(treemask,0);

	while(countx>0)
	{			
		while(county<256)
		{		
			pixel = pixel_for_bmap(treemask,countx,county);
			pixel_to_vec(temp_vec,NULL,888,pixel);
			
			//only write to array if red is 255
			if (temp_vec[0]==255) 
			{
				treemask_array[countx][county]=255;				
			}
			
			else {treemask_array[countx][county]=0;}
			
			county+=1;
		}	
		
		if (county>=256)
		
		{
			county=0;
		}
		
		countx-=1;
	}

	bmap_unlock(treemask);	
}



Sphere Engine--the premier A6 graphics plugin.
Re: Crash with pixel_to_vec [Re: Matt_Aufderheide] #263598
04/30/09 18:31
04/30/09 18:31
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline OP
Expert
Matt_Aufderheide  Offline OP
Expert
M

Joined: Oct 2003
Posts: 4,131
never mind, i was overrunning the array.. duh.

Re: Crash with pixel_to_vec [Re: Matt_Aufderheide] #263674
05/01/09 10:54
05/01/09 10:54
Joined: Feb 2006
Posts: 385
Oldenburg,Germany
Ralph Offline
Senior Member
Ralph  Offline
Senior Member

Joined: Feb 2006
Posts: 385
Oldenburg,Germany
From the manual:
pixel_to_vec(COLOR* color,var alpha,var format,var pixel);

You have to use a Vector or Color at the first parameter not a array.
This should solved your problem.
EDIT : shocked I dont see your secound post ... I need glasses! argh!

Last edited by Ralph; 05/01/09 10:56.

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

Gamestudio download | 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