sdd3d->BeginSprite();
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.");
d3d->SetTexture(0, NULL);
d3d->SetFVF(NULL);
sdd3d->EndSprite();
[SOLVED] Drawing a textured square - sprite issue
Why is it that in order for me to see the texture of a square I have defined using an FVF and vertices, I need to call Sprite->Begin and Sprite->End surrounding my SetTexture() call?
If I remove the BeginSprite and EndSprite calls nothing will display. I thought you only needed to make sprite calls when using Sprite->Draw(). I believe that this repetitive use of Begin/End Sprite in this function as well as in my RenderText function is causing all fonts to flicker. Does anyone know of a way around this or why I need these calls at all???
[Edited by - orphankill on October 13, 2007 1:30:16 PM]
What does BeginSprite() and EndSprite() do? They don't call beginScene() and EndScene() do they? If so, that's your problem - you can only call DrawPrimitive() from within a BeginScene()..EndScene() block.
No no, this whole function is already contained in a BeginScene and EndScene.
Here they are (sorry completely forgot):
Here they are (sorry completely forgot):
void BeginSprite() { d3dspr->Begin(D3DXSPRITE_ALPHABLEND); draw_started = TRUE; } void EndSprite() { d3dspr->End(); draw_started = FALSE; }
d3dspr->Begin(D3DXSPRITE_ALPHABLEND);
d3dspr->End();
Begin saves the current render state settings and sets new ones for sprite drawing based on the flags you pass.
End restores the settings saved in Begin.
That is why you could get unexpected results if you try to draw something inside a sprite's begin-end block, since the render states are changed during that phase.
The only workaround is to set the render state manually. They are explained in the docs. But that is just a waste of coding time. The sprite interface basically just draws lots of quads using a Draw*** function.
d3dspr->End();
Begin saves the current render state settings and sets new ones for sprite drawing based on the flags you pass.
End restores the settings saved in Begin.
That is why you could get unexpected results if you try to draw something inside a sprite's begin-end block, since the render states are changed during that phase.
The only workaround is to set the render state manually. They are explained in the docs. But that is just a waste of coding time. The sprite interface basically just draws lots of quads using a Draw*** function.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement