Skip to content
Snippets Groups Projects
llglsandbox.cpp 28.5 KiB
Newer Older
James Cook's avatar
James Cook committed

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

	LLGLSUIDefault gls_ui;

	{
		LLGLSNoTexture gls_ui_no_texture;

		S32 last_line_width = -1;
		// gGL.begin(LLVertexBuffer::LINES); // Always happens in (line_width != last_line_width)
		
		for (S32 i = 0; i < mDebugBeacons.count(); i++)
James Cook's avatar
James Cook committed
		{
			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)
			{
				if (i > 0)
				{
					gGL.end();
					gGL.flush();
				}
James Cook's avatar
James Cook committed
				glLineWidth( (F32)line_width );
				last_line_width = line_width;
				gGL.begin(LLVertexBuffer::LINES);
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);
		
		S32 last_line_width = -1;
		// gGL.begin(LLVertexBuffer::LINES); // Always happens in (line_width != last_line_width)
		
		for (S32 i = 0; i < mDebugBeacons.count(); i++)
James Cook's avatar
James Cook committed
		{
			const LLDebugBeacon &debug_beacon = mDebugBeacons[i];

			S32 line_width = debug_beacon.mLineWidth;
			if (line_width != last_line_width)
			{
				if (i > 0)
				{
					gGL.end();
					gGL.flush();
				}
James Cook's avatar
James Cook committed
				glLineWidth( (F32)line_width );
				last_line_width = line_width;
				gGL.begin(LLVertexBuffer::LINES);
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
		glLineWidth(1.f);

		for (S32 i = 0; i < mDebugBeacons.count(); i++)
James Cook's avatar
James Cook committed
		{
			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));
James Cook's avatar
James Cook committed
			hud_textp->setColor(color);
			hud_textp->setPositionAgent(debug_beacon.mPositionAgent);
			debug_beacon.mHUDObject = hud_textp;
		}
	}
}