Jump to content
  • Advertisement
Sign in to follow this  
fjprieto

DirectX

This topic is 3163 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

I use DirectX with Borland CBuilder 6.0. If Graphics card has not Vertex Hardware Processing i have detected that my program is more quickly when i execute previosly another DirectX program wrote whith VC. Why? Thanks

Share this post


Link to post
Share on other sites
Advertisement
First, Borland C Builder isn't a supported compiler for the DirectX SDK - I'd recommend using Visual Studio 2008 unless you don't have any option for whatever reason.

If you mean that you run a DirectX app first, and then your app, and that causes your app to load faster, then that'll be because the DirectX DLLs will be loaded into memory by the first app, and the OS will keep them in memory for your app, thus avoiding the need to load them from disk.

If you mean that you get a better frame rate in your app after running another DirectX app, how do you detect frame rate? It's possible that the other app changed some timing method, making the timers more accurate. We'll probably need to see some code to help if this is the case (In particular what you use for timing).

Share this post


Link to post
Share on other sites
I get a better frame rate in my app after running another DirectX app. I really use the time measure with GetTickCount. I have detected that the frame rate is more slow with my app only, without measure. I think that i dont initialize correctly DirectX, beside th initialization function its the same that another DirectX app.


Thanks

Share this post


Link to post
Share on other sites
Quote:
Original post by fjprieto
I get a better frame rate in my app after running another DirectX app. I really use the time measure with GetTickCount. I have detected that the frame rate is more slow with my app only, without measure. I think that i dont initialize correctly DirectX, beside th initialization function its the same that another DirectX app.
How exactly are you using GetTickCount()? Remember that it's only accurate to about 15-25ms depending on your OS. You shouldn't ever measure the time taken for one frame if you can help it, instead count how many frames elapse in one second - that'll lower the error ratio.

What do you mean that you've detected that the frame rate is lower if you're not measuring it?

If you think the initialisation is wrong, we'll need to see your initialisation code.

Share this post


Link to post
Share on other sites
its not necesary the measure because the image its very big (4 million of vertex trinagles), so when i move the image i see the draw very slow when is not present another DirectX app. Really this is when the graphics card has not VERTEX_HARDWARE_PROCESSING. If the card has VERTEX_HARDWARE_PROCESSING i dont apreciate difference.


My code for DirectX initialitation is:

int D3D_Init(HWND hWnd)
{
D3DMATERIAL9 g_alphaMaterial;

lpD3D = Direct3DCreate9( D3D_SDK_VERSION );

D3DDISPLAYMODE d3ddm;

lpD3D->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &d3ddm );

D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory( &d3dpp, sizeof(d3dpp) );

d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = d3ddm.Format;
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;

lpD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp, &lpD3DDev );
//loadTexture();

/***** Code only for another app
D3DXMATRIX matProj;
D3DXMatrixPerspectiveFovLH( &matProj, D3DXToRadian( 45.0f ),
640.0f / 480.0f, 0.1f, 100.0f );
lpD3DDev->SetTransform( D3DTS_PROJECTION, &matProj );

lpD3DDev->CreateVertexBuffer( 24*sizeof(Vertex), D3DUSAGE_WRITEONLY,
Vertex::FVF_Flags, D3DPOOL_DEFAULT,
&g_pVertexBuffer, NULL );
void *pVertices = NULL;

g_pVertexBuffer->Lock( 0, sizeof(g_cubeVertices), (void**)&pVertices, 0 );
memcpy( pVertices, g_cubeVertices, sizeof(g_cubeVertices) );
g_pVertexBuffer->Unlock();
****/
lpD3DDev->SetRenderState( D3DRS_LIGHTING, TRUE );

// Set up our alpha material...
ZeroMemory( &g_alphaMaterial, sizeof(D3DMATERIAL9) );
g_alphaMaterial.Diffuse.r = 1.0f;
g_alphaMaterial.Diffuse.g = 1.0f;
g_alphaMaterial.Diffuse.b = 1.0f;
g_alphaMaterial.Diffuse.a = 0.5f;
lpD3DDev->SetMaterial( &g_alphaMaterial );

// Set light 0 to be a pure white directional light
D3DLIGHT9 light0;
ZeroMemory( &light0, sizeof(D3DLIGHT9) );
light0.Type = D3DLIGHT_DIRECTIONAL;
light0.Direction = D3DXVECTOR3( 0.0f, 0.0f, 1.0f );
light0.Diffuse.r = 1.0f;
light0.Diffuse.g = 1.0f;
light0.Diffuse.b = 1.0f;
light0.Diffuse.a = 1.0f;
lpD3DDev->SetLight( 0, &light0 );
lpD3DDev->LightEnable( 0, TRUE );
return(1);
}


Its a copy from another DirectX App.

Thanks

Share this post


Link to post
Share on other sites
Just to check - the code you've pasted runs faster when another, unrelated application has been previously running (And is not running at the same time)?

Also, you should always use hardware vertex processing when it's available - there's no need to do things slowly on the CPU when they can be done quickly on the GPU.

Share this post


Link to post
Share on other sites
first i execute a app wrote in VC calling D3DInit, its code in init is the code previously paste, with the sentences CretateVertex, etc.. active (no comment).

second i execute my app

third i shutdown the first app.


In this my app its faster than i execute my app only.



This is when the graphics card has not VERTEX_HARDWARE_PROCESSING.

in this, I force VERTEX_SOFTWARE_PROCESSING


I have another routine for D3D init, that verify the graphics card vertex mode.


I paste this code, because i think that my D3D init was bad, and paste from the VC App.

Now in test mode my app execute D3DInit app before DirectX initialitation with CreateProcess, and after run TerminateProcess




thanks


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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!