Jump to content
  • Advertisement
Sign in to follow this  
orphankill

[SOLVED] Sprites with text

This topic is 3935 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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, (INT)strlen((char*)menu_options), &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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!