Skip to content
Snippets Groups Projects
llglsandbox.cpp 28.4 KiB
Newer Older
	gGL.vertex3f(center.mV[VX] - width ,center.mV[VY] - width,center.mV[VZ] + width);
	gGL.vertex3f(center.mV[VX] - width ,center.mV[VY] - width,center.mV[VZ] - width);
	gGL.vertex3f(center.mV[VX] + width ,center.mV[VY] - width,center.mV[VZ] + width);
	gGL.vertex3f(center.mV[VX] + width ,center.mV[VY] - width,center.mV[VZ] - width);
James Cook's avatar
James Cook committed
}


void LLViewerObjectList::renderObjectBeacons()
{
James Cook's avatar
James Cook committed
	S32 i;
	//const LLFontGL *font = gResMgr->getRes(LLFONT_SANSSERIF);

	LLGLSUIDefault gls_ui;

	S32 last_line_width = -1;
	
	{
		LLGLSNoTexture gls_ui_no_texture;
James Cook's avatar
James Cook committed
		for (i = 0; i < mDebugBeacons.count(); i++)
		{
			const LLDebugBeacon &debug_beacon = mDebugBeacons[i];
			LLColor4 color = debug_beacon.mColor;
			color.mV[3] *= 0.25f;
			S32 line_width = debug_beacon.mLineWidth;
			if (line_width != last_line_width)
			{
James Cook's avatar
James Cook committed
				glLineWidth( (F32)line_width );
				last_line_width = line_width;
James Cook's avatar
James Cook committed
			}

			const LLVector3 &thisline = debug_beacon.mPositionAgent;
			gGL.color4fv(color.mV);
			gGL.vertex3f(thisline.mV[VX],thisline.mV[VY],thisline.mV[VZ] - 50.f);
			gGL.vertex3f(thisline.mV[VX],thisline.mV[VY],thisline.mV[VZ] + 50.f);
			gGL.vertex3f(thisline.mV[VX] - 2.f,thisline.mV[VY],thisline.mV[VZ]);
			gGL.vertex3f(thisline.mV[VX] + 2.f,thisline.mV[VY],thisline.mV[VZ]);
			gGL.vertex3f(thisline.mV[VX],thisline.mV[VY] - 2.f,thisline.mV[VZ]);
			gGL.vertex3f(thisline.mV[VX],thisline.mV[VY] + 2.f,thisline.mV[VZ]);
James Cook's avatar
James Cook committed

			draw_line_cube(0.10f, thisline);
		}
James Cook's avatar
James Cook committed
	}

	{
		LLGLSNoTexture gls_ui_no_texture;
		LLGLDepthTest gls_depth(GL_TRUE);
		
James Cook's avatar
James Cook committed
		last_line_width = -1;
		for (i = 0; i < mDebugBeacons.count(); i++)
		{
			const LLDebugBeacon &debug_beacon = mDebugBeacons[i];

			S32 line_width = debug_beacon.mLineWidth;
			if (line_width != last_line_width)
			{
James Cook's avatar
James Cook committed
				glLineWidth( (F32)line_width );
				last_line_width = line_width;
James Cook's avatar
James Cook committed
			}

			const LLVector3 &thisline = debug_beacon.mPositionAgent;
			gGL.color4fv(debug_beacon.mColor.mV);
			gGL.vertex3f(thisline.mV[VX],thisline.mV[VY],thisline.mV[VZ] - 0.5f);
			gGL.vertex3f(thisline.mV[VX],thisline.mV[VY],thisline.mV[VZ] + 0.5f);
			gGL.vertex3f(thisline.mV[VX] - 0.5f,thisline.mV[VY],thisline.mV[VZ]);
			gGL.vertex3f(thisline.mV[VX] + 0.5f,thisline.mV[VY],thisline.mV[VZ]);
			gGL.vertex3f(thisline.mV[VX],thisline.mV[VY] - 0.5f,thisline.mV[VZ]);
			gGL.vertex3f(thisline.mV[VX],thisline.mV[VY] + 0.5f,thisline.mV[VZ]);
James Cook's avatar
James Cook committed

			draw_line_cube(0.10f, thisline);
		}
James Cook's avatar
James Cook committed
	
James Cook's avatar
James Cook committed
		glLineWidth(1.f);

		for (i = 0; i < mDebugBeacons.count(); i++)
		{
			LLDebugBeacon &debug_beacon = mDebugBeacons[i];
			if (debug_beacon.mString == "")
			{
				continue;
			}
			LLHUDText *hud_textp = (LLHUDText *)LLHUDObject::addHUDObject(LLHUDObject::LL_HUD_TEXT);

			hud_textp->setZCompare(FALSE);
			LLColor4 color;
			color = debug_beacon.mTextColor;
			color.mV[3] *= 1.f;

			hud_textp->setString(utf8str_to_wstring(debug_beacon.mString.c_str()));
			hud_textp->setColor(color);
			hud_textp->setPositionAgent(debug_beacon.mPositionAgent);
			debug_beacon.mHUDObject = hud_textp;
		}
	}
}


void pre_show_depth_buffer()
{
	glClear(GL_STENCIL_BUFFER_BIT);
	glEnable(GL_STENCIL_TEST);
	glStencilFunc(GL_ALWAYS,0,0);
	glStencilOp(GL_INCR,GL_INCR,GL_INCR);
}

void post_show_depth_buffer()
{
	int xsize =500, ysize =500;
	U8 *buf = new U8[xsize*ysize];

	glReadPixels(0,0,xsize,ysize,GL_STENCIL_INDEX,GL_UNSIGNED_BYTE, buf);

	int total = 0;
	int i;
	for (i=0;i<xsize*ysize;i++) 
	{
		total += buf[i];
		buf[i] <<= 3;
	}

	float DC = (float)total/(float)(ysize*xsize);
	int DCline = llfloor((xsize-20) * DC / 10.0f);
	int stride = xsize / 10;

	int y = 2;

	for (i=0;i<DCline;i++)
	{
		if (i % stride == 0) i+=2;
		if (i > xsize) y=6;
		buf[ysize*(y+0)+i]=255;
		buf[ysize*(y+1)+i]=255;
		buf[ysize*(y+2)+i]=255;
	}
	glDrawPixels(xsize,ysize,GL_RED,GL_UNSIGNED_BYTE,buf);

James Cook's avatar
James Cook committed
}