Page 1 of 1

switch case statement in cg shaders not working, possible?

Posted: Wed Nov 25, 2009 5:39 pm
by toglia
Quick question:
In the nvidia's cg tutorial http://http.developer.nvidia.com/CgTuto ... dix_d.html it lists the switch and case statement like reserved words, but I tried using it this way:

Code: Select all

	int x = 1;
	switch(x){
		case 0:
			colorIn0 = tex2D(texture0,uv0);
		break;
		case 1:
			colorIn0 = tex2D(texture1,uv0);
		break;
		case 2:
			colorIn0 = tex2D(texture2,uv0);
		break;
	}
And I'm getting:

Code: Select all

(17) : error C0000: syntax error, unexpected reserved word "switch" at token "switch"
(17) : error C0501: type name expected at token "switch"
(17) : error C1033: cast not allowed
(17) : error C0000: syntax error, unexpected '{', expecting ';' or ',' at token "{"
(17) : error C0501: type name expected at token "{"
(19) : error C1038: declaration of "colorIn0" conflicts with previous declaration at (13)
(19) : error C1038: declaration of "colorIn0" conflicts with previous declaration at (13)
(21) : error C0000: syntax error, unexpected reserved word "case" at token "case"
(21) : error C0501: type name expected at token "case"
(22) : error C1038: declaration of "colorIn0" conflicts with previous declaration at (13)
(22) : error C1038: declaration of "colorIn0" conflicts with previous declaration at (13)
(24) : error C0000: syntax error, unexpected reserved word "case" at token "case"
Any ideas?

Re: switch case statement in cg shaders not working, possible?

Posted: Thu Nov 26, 2009 11:00 am
by tuan kuranes
It's not supported in CG.
Might be in future version, that's why it's "reserver"