Direct X is confusing me in several ways. Let me first introduce my code to you, problematic code I believe is bolded. I have a square that is made of 4 vertices. Like this.

Code:
    struct { float x, y, z; } temp [] = 
    {
        { -0.9f, -0.9f, 0.0f },
        { -0.9f, -0.7f, 0.0f },
        { -0.8f, -0.9f, 0.0f },
        { -0.8f, -0.7f, 0.0f }
    };
I got some code from a tutorial that sets up some stuff like this in an initialization routine.

Code:
    mpd3dDevice->SetRenderState( D3DRS_LIGHTING, FALSE );
    mpd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );

    D3DXMATRIX mProjection;
    XD3DXMatrixPerspectiveFovLH( &mProjection, 45.0f, 640.0f / 480.0f, 0.1f, 100.0f );
    mpd3dDevice->SetTransform( D3DTS_PROJECTION, &mProjection );
I have a routine that creates the vertex buffer.

Code:
int Direct3D::RetrievePool( void )
{
    if( FAILED( mpd3dDevice->CreateVertexBuffer
        ( sizeof vertices, D3DUSAGE_WRITEONLY, D3DFVF_XYZ, D3DPOOL_DEFAULT, &mpdvBuf, 0) ) )
    {
        return 0;
    }

    LPVOID pVertices = 0;

    if( FAILED( mpdvBuf->Lock( 0, 0, &pVertices, 0 ) ) )
    {
        return 0;
    }

    CopyMemory(pVertices, vertices, sizeof vertices);

    mpdvBuf->Unlock();

    return 1;
}
And then I render things like this

Code:
int Direct3D::RenderDxScene( void )
{
    HRESULT coop = mpd3dDevice->TestCooperativeLevel();

    switch(coop)
    {
        case D3DERR_DEVICELOST: 
            OutputDebugString( TEXT( "Device lost" ) );
            return 1;

        case D3DERR_DEVICENOTRESET:
            mpdvBuf->Release();
            if( FAILED( mpd3dDevice->Reset( &md3dpp ) ) )
            {
                OutputDebugString( TEXT( "Reset failed" ) );
                return 0;
            }
            RetrievePool();
            break;

        default:;
    }

    mpd3dDevice->Clear( 0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_COLORVALUE(0.2f, 0.2f, 0.2f, 1.0f), 1.0f, 0 );

    if( FAILED( mpd3dDevice->BeginScene() ) )
    {
        return 0;
    }

    D3DXMATRIX mWorld;
    XD3DXMatrixTranslation( &mWorld, 0.0f, 0.0f, 2.0f );

    mpd3dDevice->SetTransform( D3DTS_WORLD, &mWorld );
    mpd3dDevice->SetStreamSource( 0, mpdvBuf, 0, sizeof(float) * 3 );
    mpd3dDevice->SetFVF( D3DFVF_XYZ );
    mpd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 4 );

    if( FAILED( mpd3dDevice->EndScene() ) )
    {
        return 0;
    }

    mpd3dDevice->Present( 0, 0, 0, 0 );

    return 1;
}
So.

When I draw it as a triangle list, like there, it only ends up being a right triangle facing to the right.
When I draw it as a pointlist, it is 4 points in the shape of a square.
When I draw it as a triangle fan, it is a solid square but with a big fingery thing pointing to the center (see attachment)

Okay. So that's wierd. Now the alt+tab thing. The documentation is a little confusing. http://msdn.microsoft.com/library/de...st_devices.asp

What I tried doing, was just letting it not try to render the scene if it acknowledges the device is lost (D3DERR_DEVICELOST). But if I get a D3DERR_DEVICENOTRESET, I assume that I need to do stuff then, so I guess I need to release anything allocated in the D3DPOOL_DEFAULT so I call release, then I restore settings, and then I try to lock/unlock resources again in that retrievepool thing.

1) As it is, with that strategy, nothing will be drawn on the screen when I return to it.
2) If I do not call retrievepool again, then the app crashes (I suppose using the vertex buffer which has been released)

This confuses me. Hmm.