Problems with rendering... RRS feed

  • Question

  • Hey, I'm pretty sure that these are both simple fixes....

    But I've been having two problems with rendering things with direct x 9. I've worked around both of them for a while but I don't really like doing that, although I've been unable to come up with a reason/solution for either and my research on google and these forums hasn't yet provided a solution, so I figured I'd actually try asking for help...

    I'm writing a 2D/3D engine, and I've found that when I'm using 2D rendering, nothing shows up on screen until I render a font to the screen. I'm not doing anything excessive with my fonts - I'm just using the LPD3DXFONT class with the DrawTextA function to render my text. So as far as I know, that shouldn't be changing anything important.

    Regardless, until I've rendered a font to the screen, none of my 2D sprites will show up on screen. I'm using the following render states:

    m_pDevice->SetRenderState(D3DRS_LIGHTING, false);
    m_pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, true);
    m_pDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
    m_pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);


    EDIT: okay, apparently half of my message disappeared. So let's try this again...

    In case it's relevant, here's what I'm using to set my projection matrix:

    D3DXMatrixOrthoOffCenterLH(&m_mtxProjection, 0, 1, 1, 0, -100, 100);

    Other than that, there really isn't any difference between my meshes and my sprites (other than the fact that one's a textured quad and one's a full fledged mesh).

    The other problem I've been having is that in release mode, nothing shows up on screen even though everything works fine in debug mode. I'm not quite sure why this is happening. So any insights as in to why that happens would be much appreciated :)

    Wednesday, February 14, 2007 9:23 AM

All replies

  • wombat,

      You mentioned that none of your sprites show up until  you call DrawTextA.  I would assume you are calling the D3DXSprite::Begin , and the subsuquent D3DXSprite::Draw for each sprite.  The device state will not change (drawing) until you either call D3DXSprite::End or D3DXSprite::Flush.  If you want the other sprites rendered sooner can you flush them when you want them drawn to screen?  Note for performance reasons you should batch these calls, hence the behavior of the functions to draw on explicit flush or end (after all added).  I am wondering if the DrawTextA is "flushing" the buffer to the screen. 

      On the debug vs release breaking.  Do you get compilation errors on release?  Possible the additional dependences are not set in the project properties as they are in debug.  Check these settings as this is sometimes the issue when codes works in debug but not in release mode. Thanks.


    Thursday, February 15, 2007 6:35 AM
  • Hi, thanks for your response. I forgot to mention that the sprites that I'm using are not made using the IDirect3DSprite, I'm using my own textured-quad class. Would this still be a problem, do you think? Also related, I don't have to call the print function every frame, if I call it once before any rendering is done, the sprites will still work for the duration of the program.

    I'll look into the dependencies next chance I get, thanks for that heads up. If that's not it I'll post about it shortly.

    Thursday, February 15, 2007 7:01 AM