![]() |
| | #1 |
| Registered User Join Date: Apr 2008
Posts: 58
| So...I'm using the graphic device's "Clear" method before I begin a scene, however I still get some strange results when it draws to the screen. I would post the code snippets here...but there is too much. In the application class, I call the BeginScene, and EndScene functions, and also clear and present the scenes.... In the Game1 class, I populate a "draw" method with a vertexbuffer class, and draw some basic primitives... The problem is that I cannot get the device to properly dispose of the previous primitive data. If you press the assigned controls to move the primitives, you will see that the "box" continues drawing its previous positions underneath the current position...even when you close the .exe and reopen it. The controls are as follows: - Up: Move up - Down: Move down - Left: Move left - Right: Move right - Shift-Up: Zoom in - Shift-Down: Zoom out Any ideas on what I need to do in order to prevent it from drawing this way? Last edited by arcaine01; 10-04-2009 at 10:44 PM. Reason: Including the d/l link |
| arcaine01 is offline | |
| | #2 |
| Rampaging 35 Stone Welsh Join Date: Apr 2007
Posts: 2,926
| Show us what you are doing to clear the scene, the parameters you're using etc. It should be something similar to - Code: Device->Clear(0 , 0 , D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER , 0X00000000 , 1.0f , 0);
__________________ He is free, you say. Ah! That is his misfortune… These men… [have] the most terrible, the most imperious of masters, that is, need. … They must therefore find someone to hire them, or die of hunger. Is that to be free? - Simon Linguet Last edited by abachler; 10-04-2009 at 11:34 PM. |
| abachler is offline | |
| | #3 |
| Registered User Join Date: Apr 2008
Posts: 58
| Code: Application::StartDraw(void)
{
GraphicDevice::GetService()->Device()->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, Colors::Red, 1.0f, 0);
GraphicDevice::GetService()->BeginScene();
}
|
| arcaine01 is offline | |
| | #4 |
| Rampaging 35 Stone Welsh Join Date: Apr 2007
Posts: 2,926
| red text is my addition. I don't know for what purpose you are abstracting it that far out, but the BeginScene() has to take place through the Device object. I am assuming your GetService()->Device() call returns a pointer to the device object.
__________________ He is free, you say. Ah! That is his misfortune… These men… [have] the most terrible, the most imperious of masters, that is, need. … They must therefore find someone to hire them, or die of hunger. Is that to be free? - Simon Linguet Last edited by abachler; 10-05-2009 at 10:27 AM. |
| abachler is offline | |
| | #5 |
| Super Moderator Join Date: Aug 2001
Posts: 7,472
| pDevice->Clear(0,D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL,0,1.0f,0); I'm a little confused when you say it doesn't clear the vertex buffer b/c Clear() is not supposed to touch vertex buffers. Make sure your viewport is set to the correct one. If you set the viewport at some point you must set it back to the default. Before setting a viewport ensure you get the current one so you can set it back when you are done.
__________________ If you aim at everything you will hit something but you won't know what it is. |
| Bubba is offline | |
| | #6 |
| Registered User Join Date: Apr 2008
Posts: 58
| You're right Bubba, I'm sorry for my poor choice of words. I meant to say its not clearing the window...not the vertex buffer :P I also found that if I construct the method like so: Code: HRESULT a = pDevice->Clear(0, 0, D3DCLEAR_TARGET, 0, 1.0f, 0); However, the following code, when drawing the vertices OR the textures, will return -2005530516: Code: HRESULT a = pDevice->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0, 1.0f, 0); It appears that for some reason, whenever I combine the flags, the method fails. Does anyone know of any possible reason for this? |
| arcaine01 is offline | |
| | #7 |
| Super Moderator Join Date: Aug 2001
Posts: 7,472
| Make sure you have a zbuffer specified in your D3DPRESENT_PARAMETERS. Auto depth stencil should be set to true and one of the following formats should be used. Some older cards did not use 1 bit stencil correctly so you may have to query the device. Under Direct3D 10 you do not have to query for device caps since it is required that all video card manuf. are 100% compatible. D3DFMT_D24S8 D3DFMT_D16 D3DFMT_D15S1
__________________ If you aim at everything you will hit something but you won't know what it is. |
| Bubba is offline | |
| | #8 |
| Registered User Join Date: Apr 2008
Posts: 58
| Bubba, you are a life saver :P Thank you again for your help. All I did was change the format for the auto depth stencil to one of the formats you suggested, and it worked perfectly. |
| arcaine01 is offline | |
| | #9 |
| Super Moderator Join Date: Aug 2001
Posts: 7,472
| Glad you got it working. Remember if Direct3D is not drawing it is usually something to do with present parameters, render states, or incorrect transforms.
__________________ If you aim at everything you will hit something but you won't know what it is. |
| Bubba is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Problems with my DirectX program | fighter92 | Game Programming | 1 | 01-23-2007 06:28 PM |
| Isometric Tile Engine using DirectX | Wraithan | Game Programming | 3 | 07-17-2006 12:16 PM |
| DirectSound header issues | dxfoo | C++ Programming | 0 | 03-19-2006 07:16 PM |
| DirectX - Starting Guide? | Zeusbwr | Game Programming | 13 | 11-25-2004 12:49 AM |
| DirectX: VertexBuffer with Length 0? | Epo | Game Programming | 6 | 12-28-2003 06:39 PM |