
separate (adagate.drawroom)

procedure drawLev2 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 ------------------------------------------------








	glUseProgram( pidpool14 ); --=================================

	glUniform1i(side14, glint(numport) );

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

	glUniform3f(lprt14,glfloat(xtgt1),glfloat(ytgt1),glfloat(ztgt1)); 
	glUniform3f(rprt14,glfloat(xtgt2),glfloat(ytgt2),glfloat(ztgt2)); 

	-- define cubemapped textures to reflect:
	glenable(gl_texture_cube_map_seamless);
	glbindtexture(gl_texture_cube_map, cubemap_texid);
	-- note:  this is essentially a "cheat".  I really want
	--        to use the actual environment!
	gluniform1i(envm14, 0); -- "envMap" in .fs
	gluniformmatrix4fv( imvp14, 1, gl_false, mvp(1,1)'address );
	gluniform1f(time14, glfloat(currentTime) );

	gluniform3f(icen14,glfloat(xpcen),glfloat(ypcen),glfloat(zpcen));
	gluniform3f(irad14,glfloat(xprad),glfloat(yprad),glfloat(zprad));
	gluniform1f(wlev14,glfloat(waterlevel) );

	reflsurf.draw(rfo,vertbuff);





	--WaterWorld
	glUseProgram( pidpic04 ); --===================================

	glUniform1i(side04, glint(numport) );

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


	glUniform3f(lprt04,glfloat(xtgt1),glfloat(ytgt1),glfloat(ztgt1)); 
	glUniform3f(rprt04,glfloat(xtgt2),glfloat(ytgt2),glfloat(ztgt2)); 


	gluniformmatrix4fv( imvp04, 1, gl_false, mvp(1,1)'address );
	gluniform1f(time04, glfloat(currentTime) );
	gluniform2f(icen04, glfloat(x2picx), glfloat(x2picy) );
	gluniform2f(irad04, glfloat(x2picwb/2.0), glfloat(x2pichb/2.0) );
	gluniform2f(ires04, glfloat(winwidth), glfloat(winheight) );
	rectxobj.draw(pox,vertbuff,elembuff);



	--MountainScape
	glUseProgram( pidpic05 ); --====================================

	glUniform1i(side05, glint(numport) ); 

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

	glUniform3f(lprt05,glfloat(xtgt1),glfloat(ytgt1),glfloat(ztgt1)); 
	glUniform3f(rprt05,glfloat(xtgt2),glfloat(ytgt2),glfloat(ztgt2)); 


	gluniformmatrix4fv( imvp05, 1, gl_false, mvp(1,1)'address );
	gluniform1f(time05, glfloat(currentTime) );
	gluniform2f(icen05, glfloat(x2picx), glfloat(x2picy) );
	gluniform2f(irad05, glfloat(x2picws/2.0), glfloat(x2pichs/2.0) );
	gluniform2f(ires05, glfloat(winwidth), glfloat(winheight) );
	rectxobj.draw(pox2,vertbuff,elembuff);



	-- fancy fragshader draws star ceiling
	glUseProgram( pidstar09 ); --==================================
	gluniformmatrix4fv( imvp09, 1, gl_false, mvp(1,1)'address );
	gluniform1f(time09, glfloat(currentTime) );
	gluniform2f(ires09, glfloat(winwidth), glfloat(winheight) );

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

	glUniform3f(ieye09, glfloat(xeye),glfloat(yeye),glfloat(zeye));
	glUniform3f(lprt09,glfloat(xtgt1),glfloat(ytgt1),glfloat(ztgt1)); 
	glUniform3f(rprt09,glfloat(xtgt2),glfloat(ytgt2),glfloat(ztgt2)); 


	rectxobj.draw(rox,vertbuff,elembuff);



end drawLev2;

