Sign in to follow this  
CadetUmfer

BeginScene/EndScene ...what am I forgetting?

Recommended Posts

CadetUmfer    234
I'm writing a DX9 engine, and I can't pin down this error. Basic program execution: Init d3d Create device Create sprite Create font The per-frame code looks like this
switch (IDirect3DDevice9_TestCooperativeLevel(device)) {
    case D3DERR_DEVICELOST:
        return;
    case D3DERR_DEVICENOTRESET:
        Reset();
        break;
}

IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL, COLOR_GREY, 0, 0);

if (SUCCEEDED(IDirect3DDevice9_BeginScene(device))) {
    ID3DXSprite_Begin(sprite, D3DXSPRITE_DONOTSAVESTATE | D3DXSPRITE_SORT_TEXTURE);
    /* ID3DXFont_Draw calls */
    ID3DXSprite_End(sprite);

    IDirect3DDevice9_EndScene(device);

    IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
}

I get this error at ID3DXSprite_Begin:
D3DX: Begin called from within a Begin/End pair
If I remove the draw code entirely I get this at IDirect3DDevice9_EndScene:
Direct3D9: (ERROR) :EndScene, not in scene. EndScene failed.
What am I forgetting? EDIT: Note this happens on the first frame. Here is the debug output leading up to the error:
Direct3D9: :====> ENTER: DLLMAIN(00ede6e0): Process Attach: 00000cf4, tid=00000bc0
Direct3D9: :====> EXIT: DLLMAIN(00ede6e0): Process Attach: 00000cf4
Direct3D9: (INFO) :Direct3D9 Debug Runtime selected.
Direct3D9: :Device doesn't support mip-maps
Direct3D9: (ERROR) :No hardware acceleration is available in the current mode
Direct3D9: :Device doesn't support mip-maps
Direct3D9: (ERROR) :No hardware acceleration is available in the current mode
Direct3D9: (ERROR) :No hardware acceleration is available in the current mode
Direct3D9: (ERROR) :No ddraw acceleration is available in the current mode
Direct3D9: (INFO) :======================= Reference HWVP Pure device selected
Direct3D9: (INFO) :HalDevice Driver style 9
Direct3D9: :DoneExclusiveMode
Direct3D9: (INFO) :======================= Reference HWVP Pure device selected
Direct3D9: (INFO) :HalDevice Driver style 9
Direct3D9: :DoneExclusiveMode
D3DX: Unicode support: 1
Direct3D9: :DoneExclusiveMode
Direct3D9: :DoneExclusiveMode
[Edited by - CadetUmfer on February 22, 2008 10:37:52 AM]

Share this post


Link to post
Share on other sites
Evil Steve    2017
Have you tried putting breakpoints on your begin and end calls to check they're being called how you expect?

Sounds to me like you're calling BeginScene from somewhere else, or you're return'ing from within that loop without calling EndScene somehow.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this