Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 801 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Question about mat_effect #457424
01/18/16 02:35
01/18/16 02:35
Joined: Dec 2003
Posts: 1,097
Maryland, USA
Steempipe Offline OP
Serious User
Steempipe  Offline OP
Serious User

Joined: Dec 2003
Posts: 1,097
Maryland, USA
Hi,

If I use this code, I get the anticipated results, a texture tiled 2x:

Code:
function mtlEffect_init()

{

      
   float rotation_matrix[16] =
		{ 1.0, 0.0, 0.0, 0.0,
		  0.0, 1.0,	0.0, 0.0,
		  0.0, 0.0, 1.0, 0.0,
		  0.0, 0.0, 0.0, 1.0 };
		  
	
	float temp_matrix[16] =
		{ 1.0, 0.0, 0.0, 0.0,
		  0.0, 1.0,	0.0, 0.0,
		  0.0, 0.0, 1.0, 0.0,
		  0.0, 0.0, 0.0, 1.0 };	  
		  
			
	// scale the texture
	rotation_matrix[0] = 2;
	rotation_matrix[5] = 2;
	
	mat_set(temp_matrix, rotation_matrix);
	
	mat_effect1 = temp_matrix; 
	 
}





But if I use this code I don't. Am I misinterpreting the usage from the manual?

Code:
function mtlEffect_init()

{

      
   float rotation_matrix[16] =
		{ 1.0, 0.0, 0.0, 0.0,
		  0.0, 1.0,	0.0, 0.0,
		  0.0, 0.0, 1.0, 0.0,
		  0.0, 0.0, 0.0, 1.0 };
		  
	
	float temp_matrix[16];	  
		  
			
	// scale the texture
	rotation_matrix[0] = 2;
	rotation_matrix[5] = 2;
	
	mat_set(temp_matrix, rotation_matrix);
	
	mat_effect1 = temp_matrix; 
	 
}





And even if I do this I get the results like the second image:

Code:
function mtlEffect_init()

{

      
   float rotation_matrix[16];
		  
	mat_identity(rotation_matrix);
			
	// scale the texture
	rotation_matrix[0] = 2;
	rotation_matrix[5] = 2;
	
	mat_effect1 = rotation_matrix; 
	 
}



I'm wondering why, but its not clear in the manual.

Thanks for any clarification.

Re: Question about mat_effect [Re: Steempipe] #457434
01/18/16 11:10
01/18/16 11:10
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
An effect matrix, just as any other variable or object, can only work as long as it is not deleted or overwritten. Your matrices are fine inside your functions, but just garbage outside. When you want a variable to survive the return of the function, you must declare it global or static.

Re: Question about mat_effect [Re: jcl] #457482
01/19/16 12:30
01/19/16 12:30
Joined: Dec 2003
Posts: 1,097
Maryland, USA
Steempipe Offline OP
Serious User
Steempipe  Offline OP
Serious User

Joined: Dec 2003
Posts: 1,097
Maryland, USA
Thanks for the lesson. It works great.


Moderated by  old_bill, Tobias 

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