Skip to main content
gamedev.net
🔒 Locked

Rendering Problem

Started by Shaw Mishrak 1 reply 200+ views
Original Post
Shaw Mishrak
Shaw Mishrak
I can setup Direct3D with no errors and render a triangle, but when I call Clear, Drawprimitive, then Flip, after rendering one object previously, it reverts to a black screen. Calling Flip before clear AND after EndScene sometimes works, but not always. I set up my surfaces like such: ZeroMemory(&ddsd, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); ddsd.dwFlags = DDSD_CAPS / DDSD_BACKBUFFERCOUNT; ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE / DDSCAPS_FLIP / DDSCAPS_COMPLEX / DDSCAPS_3DDEVICE; ddsd.dwBackBufferCount = 1; hr = g_pDD->CreateSurface(&ddsd, &g_pDDSPrimary, NULL); if(FAILED(hr)) { REGISTER_FAILURE("Create Primary Surface"); return FALSE; } //ZeroMemory(&ddscaps, sizeof(ddscaps)); //ddscaps.dwCaps = DDSCAPS_BACKBUFFER/* / DDSCAPS_3DDEVICE / DDSCAPS_COMPLEX*/; DDSCAPS2 ddscaps = { DDSCAPS_BACKBUFFER, 0, 0, 0 }; hr = g_pDDSPrimary->GetAttachedSurface(&ddscaps, &g_pDDSBack); if(FAILED(hr)) { REGISTER_FAILURE("GetAttachedSurface"); return FALSE; } and when I call CreateDevice, I use g_pDDSBack like such: hr = g_pD3D->CreateDevice(IID_IDirect3DHALDevice, g_pDDSBack, &g_pd3dDevice); and Ive tried even making sure of this by calling SetRenderTarget with g_pDDSBack. With animation, my render function will actually display a frame of the triangle rotating evry 40 of so frames. Anyone have any idea on whats going wrong? Shaw Mishrak
Shaw Mishrak
Shaw Mishrak
I saw your post, and that works for the first time rendering, but everytime after that, it gets iffy. THe first frame I draw will work fine. But, if I set up a loop to render another frame of animation on idle time during WinMain, it ownt always draw the triangle. I get about a 10% success rate of drawing the triangle. The second frame will almost always work if I call Flip before AND after the Clear, DrawPrimitive commands. I dont know if maybe its just going to fast, but the loop is set up exactly like the triangle sample.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.