
separate (adagate.drawroom)

procedure drawLev4 is
begin

---------- begin piranha --------------------------------------------

	gluseprogram(pidfish11); --=================================

	--portal-exterior discard:
	glUniform1i(side11, glint(numport) );

	glUniform3f(ieye11, glfloat(xeye),glfloat(yeye),glfloat(zeye));

	glUniform3f(lprt11,glfloat(xtgt1),glfloat(ytgt1),glfloat(ztgt1)); 
	glUniform3f(rprt11,glfloat(xtgt2),glfloat(ytgt2),glfloat(ztgt2)); 

	gluniformmatrix4fv(imvp11, 1, gl_false, mvp(1,1)'address );
	gluniform1i(samp11,0);
	glUniform3f(icen11,glfloat(fishx),glfloat(fishy),glfloat(fishz));
	glUniform1f(irad11, glfloat(fishr) ); --swim circle radius
	glUniform1f(svel11, glfloat(fishs) ); --swim speed
	glUniform1f(wvel11, 1.0 ); --wiggle speed
	glUniform1f(wamp11, 1.0 ); --wiggle amplitude
	gluniform1i(arot11,1); -- 1=>CW,  -1=>CCW (28jan17)
	glbindtexture(gl_texture_2d, pfish_texid);

	glUniform1f(time11, glfloat(currentTime) ); 
	myfish.draw( pdfish, vertbuff,uvbuff,elembuff ); --piranha

	glUniform1f(time11, glfloat(currentTime+6.0) ); 
	myfish.draw( pdfish, vertbuff,uvbuff,elembuff ); --piranha

	glUniform1f(time11, glfloat(currentTime+12.0) ); 
	myfish.draw( pdfish, vertbuff,uvbuff,elembuff ); --piranha

	glUniform1f(time11, glfloat(currentTime+18.0) ); 
	myfish.draw( pdfish, vertbuff,uvbuff,elembuff ); --piranha

	glUniform1f(time11, glfloat(currentTime+24.0) ); 
	myfish.draw( pdfish, vertbuff,uvbuff,elembuff ); --piranha

	glUniform1f(time11, glfloat(currentTime+30.0) ); 
	myfish.draw( pdfish, vertbuff,uvbuff,elembuff ); --piranha

---------- end piranha ------------------------------------------------





	-- fancy fragshader draws dark green water in level 4
	glUseProgram( pidpool13 ); --=================================

	glUniform1i(side13, glint(numport) );
	--glUniform1i(dunifside, 0 ); --13apr18

	glUniform3f(ieye13, glfloat(xeye),glfloat(yeye),glfloat(zeye));

	glUniform3f(lprt13,glfloat(xtgt1),glfloat(ytgt1),glfloat(ztgt1)); 
	glUniform3f(rprt13,glfloat(xtgt2),glfloat(ytgt2),glfloat(ztgt2)); 


	gluniformmatrix4fv( imvp13, 1, gl_false, mvp(1,1)'address );
	gluniform1f(time13, glfloat(currentTime) );
	gluniform3f(icen13,glfloat(xpcen),glfloat(ypcen),glfloat(zpcen));
	gluniform3f(irad13,glfloat(xprad),glfloat(yprad),glfloat(zprad));
	gluniform1f(wlev13, glfloat(waterlevel) );
	rectsurf.draw(rso,vertbuff);



	-- fancy fragshader draws star ceiling
	glUseProgram( pidstar10 ); --============================
	gluniformmatrix4fv( imvp10, 1, gl_false, mvp(1,1)'address );
	gluniform1f(time10, glfloat(currentTime) );
	gluniform2f(ires10, glfloat(winwidth), glfloat(winheight) );

	-- window-discard:
	glUniform1i(side10, glint(numport) );

	glUniform3f(ieye10, glfloat(xeye),glfloat(yeye),glfloat(zeye));
	glUniform3f(lprt10,glfloat(xtgt1),glfloat(ytgt1),glfloat(ztgt1)); 
	glUniform3f(rprt10,glfloat(xtgt2),glfloat(ytgt2),glfloat(ztgt2)); 

	rectxobj.draw(rox,vertbuff,elembuff);



	--blueSpiralGalaxy
	glUseProgram( pidpic08 ); --===================================

	glUniform1i(side08, glint(numport) );

	glUniform3f(ieye08, glfloat(xeye),glfloat(yeye),glfloat(zeye));

	glUniform3f(lprt08,glfloat(xtgt1),glfloat(ytgt1),glfloat(ztgt1)); 
	glUniform3f(rprt08,glfloat(xtgt2),glfloat(ytgt2),glfloat(ztgt2)); 

	gluniformmatrix4fv( imvp08, 1, gl_false, mvp(1,1)'address );
	gluniform1f(time08, glfloat(currentTime) );
	gluniform2f(icen08, glfloat(x4picx), glfloat(x4picy) );
	gluniform2f(irad08, glfloat(x4picw/2.0), glfloat(x4pich/2.0) );
	gluniform2f(ires08, glfloat(winwidth), glfloat(winheight) );
	rectxobj.draw(pox,vertbuff,elembuff);


end drawLev4;

