void ModelDrawer::Render(IView *v, const Vector3& teamColor)
{
	if (!glewInitialized) 
		SetupGL();

	if (!model->root)
		return;

	int S3ORendering=0;
	MdlObject *root = model->root;

	if (v->IsSelecting ())
		glDisable(GL_TEXTURE_2D);
	else if (v->GetRenderMode () == M3D_TEX)
		S3ORendering = SetupTextureMapping (v, teamColor);

	Matrix ident;
	ident.identity();
	RenderObject(root, v, model->mapping);

	if (S3ORendering > 0) {
		if (S3ORendering == 2)
			CleanupS3OAdvDrawing ();
		else if (S3ORendering == 1)
			CleanupS3OBasicDrawing ();
		glDisable (GL_TEXTURE_2D);
	}

	if (!v->IsSelecting ())
		RenderSelection (v);

	// draw radius
	if (v->GetConfig (CFG_DRAWRADIUS) != 0.0f)
	{
		glPushMatrix();
		glTranslatef(model->mid.x, model->mid.y, model->mid.z);
		glScalef(model->radius,model->radius,model->radius);
		glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
		glColor3ub(255,255,255);
		glDisable(GL_LIGHTING);
		glDisable(GL_CULL_FACE);
		glDisable(GL_TEXTURE_2D);
		glCallList(sphereList);
		glPopMatrix();
	}

	// draw height
	if (v->GetConfig (CFG_DRAWHEIGHT) != 0.0f)
	{
		glLineWidth (5.0f);

		glColor3ub (255,255,0);
		glBegin (GL_LINES);
		glVertex3i(0,0,0);
		glVertex3f(0.0f,model->height,0.0f);
		glEnd();

		glLineWidth (1.0f);
	}
}
示例#2
0
void CLightingEditor::OnRender()
{
	if ( !IsEditorActive() )
		return;

	const EDITOR_DBG_MODES dbg = GetDebugMode();
	if ( dbg != EDITOR_DBG_OFF && g_ShaderEditorSystem->IsReady() )
	{
		const char *pszDebugList[] = {
			"dbg_editor_ppe_lighting",
			"dbg_editor_ppe_depth",
			"dbg_editor_ppe_normals",
		};
		Assert( dbg >= 1 && dbg <= 3 );
		const char *pszDebugName = pszDebugList[ dbg - 1 ];

		int iDbgIndex = shaderEdit->GetPPEIndex( pszDebugName );
		if ( iDbgIndex != -1 )
			shaderEdit->DrawPPEOnDemand( iDbgIndex );
	}

	RenderSprites();

	RenderSelection();

	RenderHelpers();
}
示例#3
0
void CMenuState::OnClick(int button, int action, double x, double y) {
	GLubyte res[4];
	GLint viewport[4];

	// render selection 
	RenderSelection();

	glGetIntegerv(GL_VIEWPORT, viewport);
	glReadPixels(x, viewport[3] - y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &res); 

	if (action == GLFW_PRESS)
	{
        SoundsHandler::SoundOptions options;
        options._isRelativeToListener = true;
		switch (res[0]) {
			case 0: printf("None clicked\n"); 
				typing = false;
				break;
			case 1: printf("Textbox clicked\n"); 
				if (username == default_name) {
                    ClientGame::instance()->PlaySound("Button_Click", options);
                    username.clear();
				}
				typing = true;
				break;
			case 2: printf("Button clicked\n");
                ClientGame::instance()->PlaySound("Button_Click", options);
                StartGame();
				break;
			default: printf("%d clicked%s\n", res[0]);
                ClientGame::instance()->PlaySound("Button_Click", options);
                typing = false;
		}
	}
}
示例#4
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CEditorSystem::PostRender()
{
	if( !IsActive() )
		return;

	RenderSelection();
	RenderHelpers();
}
示例#5
0
/// Renders text ^^
void TextFont::RenderText(Text & text, GraphicsState & graphicsState)
{
	// Set starting variables.
	NewText(text);

	/// One color for all text?
	this->SetColor(text.color);
	
	/// Save old shader!
	Shader * oldShader = ActiveShader();
	// Load shader, set default uniform values, etc.
	if (!PrepareForRender())
		return;

	/// Sort the carets in order to render selected text properly.
	int min, max;
	if (text.caretPosition < text.previousCaretPosition)
	{
		min = text.caretPosition;
		max = text.previousCaretPosition;
	}
	else 
	{
		max = text.caretPosition;
		min = text.previousCaretPosition;
	}

	bool shouldRenderCaret = Timer::GetCurrentTimeMs() % 1000 > 500;
	if (text.Length() == 0 && shouldRenderCaret)
		RenderChar('|');
	for (i = 0; i < text.Length(); ++i)
	{
		if (text.caretPosition == i && shouldRenderCaret)
		{
			RenderChar('|');
		}
		currentCharIndex = i;
		currentChar = text.c_str()[i];
		if (currentChar == 0)
			break;
		nextChar = text.c_str()[i + 1];

		if (EvaluateSpecialChar())
			continue;

		StartChar();				// Move in.
		RenderChar(currentChar);	// Render
		/// If we are between the 2 active carets, render the region the char covers over with a white quad ?
		if (text.previousCaretPosition != -1 && i >= min && i < max)
		{
			RenderSelection(currentChar);			
		}
		EndChar();					// Move out.
		lastChar = currentChar;
	}
	// Caret at the end?
	if (text.caretPosition >= text.Length() && shouldRenderCaret)
	{
		RenderChar('|');
	}
	
	OnEndRender(graphicsState);
	/// Revert to old shader!
	ShadeMan.SetActiveShader(oldShader);
}