After drawing text using CD3DFont class, images are not rendering

After drawing text using CD3DFont class, images are not rendering

Post by Pavel Celb » Mon, 07 Jul 2003 00:55:01


Hi,
  I'm using DirectX 8 for drawing some images and text.
And I have a problem, that after drawing text using
CD3DFont class (provided by DX8 SDK), the images coming
after do not draw. All images before drawing text draw
fine. I'm sure, that DrawPrimitive is executed for images
coming after text. I think, there should be some setting,
which may not come back after drawing text. What setting
should I set, in order to be sure, that images will draw?

This is my setting for drawing images:

// Samotne renderovani
_Device->BeginScene();
_Device->SetTexture(0, Texture);
_Device->SetRenderState( D3DRS_ALPHABLENDENABLE, true);
_Device->SetTextureStageState(0, D3DTSS_ALPHAOP,  
D3DTOP_BLENDDIFFUSEALPHA);

_Device->SetTextureStageState( 0, D3DTSS_ADDRESSU,
D3DTADDRESS_CLAMP );
_Device->SetTextureStageState( 0, D3DTSS_ADDRESSV,
D3DTADDRESS_CLAMP );
_Device->SetTextureStageState(0, D3DTSS_MAGFILTER,
D3DTEXF_LINEAR );
_Device->SetTextureStageState(0, D3DTSS_MINFILTER,
D3DTEXF_LINEAR );

switch ( Render->BlendMode() )
{
case BLMODE_ZERO:
_Device->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ZERO);
_Device->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ZERO);
case BLMODE_ONE:
_Device->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ONE);
_Device->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE);
case BLMODE_SOURCECOLOR:
_Device->SetRenderState( D3DRS_SRCBLEND,
D3DBLEND_SRCCOLOR);
_Device->SetRenderState( D3DRS_DESTBLEND,
D3DBLEND_INVSRCCOLOR);
case BLMODE_DESTCOLOR:
_Device->SetRenderState( D3DRS_SRCBLEND,
D3DBLEND_DESTCOLOR);
_Device->SetRenderState( D3DRS_DESTBLEND,
D3DBLEND_INVDESTCOLOR);
default:
_Device->SetRenderState( D3DRS_SRCBLEND,
D3DBLEND_SRCALPHA);
_Device->SetRenderState( D3DRS_DESTBLEND,
D3DBLEND_INVSRCALPHA);

Quote:}      

_Device->SetVertexShader(VertexFVF);
_Device->SetStreamSource(0, Buffer, sizeof(v[0]) );

_Device->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);

_Device->EndScene();

Thank you for help.

 
 
 

After drawing text using CD3DFont class, images are not rendering

Post by Cronus3 » Tue, 08 Jul 2003 10:55:39


I just skimmed over your code pretty quickly, and I'm not sure if this is
the problem but, don't you need "break" statements to exit out of each case
statement.  From MSDN:

"If a matching expression is found, control is not impeded by subsequent
case or default labels. The break statement is used to stop execution and
transfer control to the statement after the switch statement. Without a
break statement, every statement from the matched case label to the end of
the switch, including the default, is executed. "


Quote:> Hi,
>   I'm using DirectX 8 for drawing some images and text.
> And I have a problem, that after drawing text using
> CD3DFont class (provided by DX8 SDK), the images coming
> after do not draw. All images before drawing text draw
> fine. I'm sure, that DrawPrimitive is executed for images
> coming after text. I think, there should be some setting,
> which may not come back after drawing text. What setting
> should I set, in order to be sure, that images will draw?

> This is my setting for drawing images:

> // Samotne renderovani
> _Device->BeginScene();
> _Device->SetTexture(0, Texture);
> _Device->SetRenderState( D3DRS_ALPHABLENDENABLE, true);
> _Device->SetTextureStageState(0, D3DTSS_ALPHAOP,
> D3DTOP_BLENDDIFFUSEALPHA);

> _Device->SetTextureStageState( 0, D3DTSS_ADDRESSU,
> D3DTADDRESS_CLAMP );
> _Device->SetTextureStageState( 0, D3DTSS_ADDRESSV,
> D3DTADDRESS_CLAMP );
> _Device->SetTextureStageState(0, D3DTSS_MAGFILTER,
> D3DTEXF_LINEAR );
> _Device->SetTextureStageState(0, D3DTSS_MINFILTER,
> D3DTEXF_LINEAR );

> switch ( Render->BlendMode() )
> {
> case BLMODE_ZERO:
> _Device->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ZERO);
> _Device->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ZERO);
> case BLMODE_ONE:
> _Device->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ONE);
> _Device->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE);
> case BLMODE_SOURCECOLOR:
> _Device->SetRenderState( D3DRS_SRCBLEND,
> D3DBLEND_SRCCOLOR);
> _Device->SetRenderState( D3DRS_DESTBLEND,
> D3DBLEND_INVSRCCOLOR);
> case BLMODE_DESTCOLOR:
> _Device->SetRenderState( D3DRS_SRCBLEND,
> D3DBLEND_DESTCOLOR);
> _Device->SetRenderState( D3DRS_DESTBLEND,
> D3DBLEND_INVDESTCOLOR);
> default:
> _Device->SetRenderState( D3DRS_SRCBLEND,
> D3DBLEND_SRCALPHA);
> _Device->SetRenderState( D3DRS_DESTBLEND,
> D3DBLEND_INVSRCALPHA);
> }

> _Device->SetVertexShader(VertexFVF);
> _Device->SetStreamSource(0, Buffer, sizeof(v[0]) );

> _Device->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);

> _Device->EndScene();

> Thank you for help.


 
 
 

After drawing text using CD3DFont class, images are not rendering

Post by Pavel Celb » Tue, 08 Jul 2003 19:09:23


Hi,
  thank you, it's just silly mistake, which have nothing
to do with the problem I have, but it's silly mistake.

Pavel Celba

Quote:>-----Original Message-----

>I just skimmed over your code pretty quickly, and I'm
not sure if this is
>the problem but, don't you need "break" statements to

exit out of each case
Quote:>statement.  From MSDN:

>"If a matching expression is found, control is not

impeded by subsequent
Quote:>case or default labels. The break statement is used to
stop execution and
>transfer control to the statement after the switch

statement. Without a
>break statement, every statement from the matched case
label to the end of
>the switch, including the default, is executed. "



>> Hi,
>>   I'm using DirectX 8 for drawing some images and text.
>> And I have a problem, that after drawing text using
>> CD3DFont class (provided by DX8 SDK), the images coming
>> after do not draw. All images before drawing text draw
>> fine. I'm sure, that DrawPrimitive is executed for
images
>> coming after text. I think, there should be some
setting,
>> which may not come back after drawing text. What
setting
>> should I set, in order to be sure, that images will
draw?

>> This is my setting for drawing images:

>> // Samotne renderovani
>> _Device->BeginScene();
>> _Device->SetTexture(0, Texture);
>> _Device->SetRenderState( D3DRS_ALPHABLENDENABLE, true);
>> _Device->SetTextureStageState(0, D3DTSS_ALPHAOP,
>> D3DTOP_BLENDDIFFUSEALPHA);

>> _Device->SetTextureStageState( 0, D3DTSS_ADDRESSU,
>> D3DTADDRESS_CLAMP );
>> _Device->SetTextureStageState( 0, D3DTSS_ADDRESSV,
>> D3DTADDRESS_CLAMP );
>> _Device->SetTextureStageState(0, D3DTSS_MAGFILTER,
>> D3DTEXF_LINEAR );
>> _Device->SetTextureStageState(0, D3DTSS_MINFILTER,
>> D3DTEXF_LINEAR );

>> switch ( Render->BlendMode() )
>> {
>> case BLMODE_ZERO:
>> _Device->SetRenderState( D3DRS_SRCBLEND,
D3DBLEND_ZERO);
>> _Device->SetRenderState( D3DRS_DESTBLEND,
D3DBLEND_ZERO);
>> case BLMODE_ONE:
>> _Device->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ONE);
>> _Device->SetRenderState( D3DRS_DESTBLEND,
D3DBLEND_ONE);
>> case BLMODE_SOURCECOLOR:
>> _Device->SetRenderState( D3DRS_SRCBLEND,
>> D3DBLEND_SRCCOLOR);
>> _Device->SetRenderState( D3DRS_DESTBLEND,
>> D3DBLEND_INVSRCCOLOR);
>> case BLMODE_DESTCOLOR:
>> _Device->SetRenderState( D3DRS_SRCBLEND,
>> D3DBLEND_DESTCOLOR);
>> _Device->SetRenderState( D3DRS_DESTBLEND,
>> D3DBLEND_INVDESTCOLOR);
>> default:
>> _Device->SetRenderState( D3DRS_SRCBLEND,
>> D3DBLEND_SRCALPHA);
>> _Device->SetRenderState( D3DRS_DESTBLEND,
>> D3DBLEND_INVSRCALPHA);
>> }

>> _Device->SetVertexShader(VertexFVF);
>> _Device->SetStreamSource(0, Buffer, sizeof(v[0]) );

>> _Device->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);

>> _Device->EndScene();

>> Thank you for help.

>.

 
 
 

After drawing text using CD3DFont class, images are not rendering

Post by Stephan Ros » Tue, 08 Jul 2003 21:37:41


No break at the end of a case? That'd result in all cases to be
executed. Which clearly would cause a problem....

Stephan



>I just skimmed over your code pretty quickly, and I'm not sure if this is
>the problem but, don't you need "break" statements to exit out of each case
>statement.  From MSDN:

>"If a matching expression is found, control is not impeded by subsequent
>case or default labels. The break statement is used to stop execution and
>transfer control to the statement after the switch statement. Without a
>break statement, every statement from the matched case label to the end of
>the switch, including the default, is executed. "



>> Hi,
>>   I'm using DirectX 8 for drawing some images and text.
>> And I have a problem, that after drawing text using
>> CD3DFont class (provided by DX8 SDK), the images coming
>> after do not draw. All images before drawing text draw
>> fine. I'm sure, that DrawPrimitive is executed for images
>> coming after text. I think, there should be some setting,
>> which may not come back after drawing text. What setting
>> should I set, in order to be sure, that images will draw?

>> This is my setting for drawing images:

>> // Samotne renderovani
>> _Device->BeginScene();
>> _Device->SetTexture(0, Texture);
>> _Device->SetRenderState( D3DRS_ALPHABLENDENABLE, true);
>> _Device->SetTextureStageState(0, D3DTSS_ALPHAOP,
>> D3DTOP_BLENDDIFFUSEALPHA);

>> _Device->SetTextureStageState( 0, D3DTSS_ADDRESSU,
>> D3DTADDRESS_CLAMP );
>> _Device->SetTextureStageState( 0, D3DTSS_ADDRESSV,
>> D3DTADDRESS_CLAMP );
>> _Device->SetTextureStageState(0, D3DTSS_MAGFILTER,
>> D3DTEXF_LINEAR );
>> _Device->SetTextureStageState(0, D3DTSS_MINFILTER,
>> D3DTEXF_LINEAR );

>> switch ( Render->BlendMode() )
>> {
>> case BLMODE_ZERO:
>> _Device->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ZERO);
>> _Device->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ZERO);
>> case BLMODE_ONE:
>> _Device->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ONE);
>> _Device->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE);
>> case BLMODE_SOURCECOLOR:
>> _Device->SetRenderState( D3DRS_SRCBLEND,
>> D3DBLEND_SRCCOLOR);
>> _Device->SetRenderState( D3DRS_DESTBLEND,
>> D3DBLEND_INVSRCCOLOR);
>> case BLMODE_DESTCOLOR:
>> _Device->SetRenderState( D3DRS_SRCBLEND,
>> D3DBLEND_DESTCOLOR);
>> _Device->SetRenderState( D3DRS_DESTBLEND,
>> D3DBLEND_INVDESTCOLOR);
>> default:
>> _Device->SetRenderState( D3DRS_SRCBLEND,
>> D3DBLEND_SRCALPHA);
>> _Device->SetRenderState( D3DRS_DESTBLEND,
>> D3DBLEND_INVSRCALPHA);
>> }

>> _Device->SetVertexShader(VertexFVF);
>> _Device->SetStreamSource(0, Buffer, sizeof(v[0]) );

>> _Device->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);

>> _Device->EndScene();

>> Thank you for help.