11.3 Sample ‘alpha

Example of light and alpha (transparency).

MGL code:

call 'prepare2d'
subplot 2 2 0:title 'default':rotate 50 60:box
surf a
subplot 2 2 1:title 'light on':rotate 50 60:box
light on:surf a
subplot 2 2 3:title 'light on; alpha on':rotate 50 60:box
alpha on:surf a
subplot 2 2 2:title 'alpha on':rotate 50 60:box
light off:surf a

C++ code:

void smgl_alpha(mglGraph *gr)	// alpha and lighting
{
	mglData a;	mgls_prepare2d(&a);
	gr->SubPlot(2,2,0);	gr->Title("default");	gr->Rotate(50,60);
	gr->Box();	gr->Surf(a);
	gr->SubPlot(2,2,1);	gr->Title("light on");	gr->Rotate(50,60);
	gr->Box();	gr->Light(true);	gr->Surf(a);
	gr->SubPlot(2,2,3);	gr->Title("alpha on; light on");	gr->Rotate(50,60);
	gr->Box();	gr->Alpha(true);	gr->Surf(a);
	gr->SubPlot(2,2,2);	gr->Title("alpha on");	gr->Rotate(50,60);
	gr->Box();	gr->Light(false);	gr->Surf(a);
}
Sample alpha