Sign in to follow this  
orphankill

[SOLVED] Sprites with text

Recommended Posts

orphankill    122
The problem is, I am trying to draw text onto a square that I am drawing using d3d->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); For some reason, DrawPrimitive refuses to show my textured square unless I enclose it with Sprite->Begin(flags) and Sprite->End(). If I comment out the DrawPrimitive statement, there is no text there. If I enclose my DrawText() function with the Sprite->Begin and End statements then the text displays. For some reason, if I start this whole function off with Sprite->Begin and end it with Sprite->End my text won't show up but my textured square will. So how do I get my text to show up on top of the square?
int SD_MENU::Render()
{
	d2d->Begin();
	d3d->SetTransform(D3DTS_VIEW, &cam->GetView());
	d3d->SetTransform(D3DTS_PROJECTION, &cam->GetProjection());
	d3d->SetFVF(MENUFVF);
	d3d->SetStreamSource(0, menu_buffer, 0, sizeof(MENUVERTEX));
	d3d->SetTexture(0, menu_texture);
	if (FAILED(d3d->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2)))
{
		ERR("SD_MENU::Render: Failed to render a menu.");
return 0;
}
	d3d->SetTexture(0, NULL);
	d3d->SetFVF(NULL);

	RECT options_rect = { 55, -150, 425, 550 };
		font->DrawTextA(d2d->GetSprite(), (char*)menu_options[i], (INT)strlen((char*)menu_options[i]), &options_rect, DT_LEFT | DT_VCENTER | DT_NOCLIP, D3DCOLOR_RGBA(255, 255, 255, 255));
		options_rect.top = options_rect.top + 60;
	}
	d2d->End();

	return 1;
}



[Edited by - orphankill on October 9, 2007 10:44:42 AM]

Share this post


Link to post
Share on other sites
orphankill    122
Sorry for wasting your time, solved it myself (as I usually do if I play with it long enough). I had to make 2 calls to sprite->begin and to sprite->end, back to back surrounding the text and texture. Don't know why but it works.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this