• Advertisement

Archived

This topic is now archived and is closed to further replies.

blinking triangle in D3DIM :(

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

hi! i just started my new game project , and for the start i just initialized ddraw & d3dim and tried to render a rectangle with texture on him to see if everything goes well, and for my supraise it (the rectange) started to blink with the background color , its so strange it never happened to me , u can see how it looks like: its just 32KB Download it (if u cant download it with getright or program liek that download it with your own browser , in IE: right click and "save target as...") umm... can u think on the problem? what am i doing wrong? "Everything you know is wrong" - Bono Edited by - xeno on 9/2/00 7:07:10 AM Edited by - xeno on 9/2/00 8:28:37 AM

Share this post


Link to post
Share on other sites
Advertisement
Forbidden
Host: [myip] myhostname
You do not have permission to access http://vsoft.20m.com/test.zip
Data files must be stored on the same site they are linked from.

Thank you for using 20m Free Web Space™


Share this post


Link to post
Share on other sites
ok , now try to download it again , please!

download it with your own browser:
with IE: right click - and then "save target as..."

thanks a lot!

Share this post


Link to post
Share on other sites
Usally blinks alot when you forgot that, done that several times =) Post your render loop

Share this post


Link to post
Share on other sites
this is my render function:

    
void Render(D3DTLVERTEX *vrtx,int num_of_vrtx)
{

lp_device->Clear(0,NULL,D3DCLEAR_TARGET,RGB_MAKE(128,128,128),0.0f,0);

lp_device->SetTexture(0,lp_tex);

if(lp_device->BeginScene())
{
lp_device->DrawPrimitive(D3DPT_TRIANGLESTRIP,D3DFVF_TLVERTEX,vrtx,num_of_vrtx,0);
lp_device->SetTexture(0,NULL);
lp_device->EndScene();
}
}




Share this post


Link to post
Share on other sites
sure it does , im doing flipping in the UpdateFrame() procedure

Share this post


Link to post
Share on other sites
when i replace this line:
if(lp_device->BeginScene())

with this:
if(SECCEEDED(lp_device->BeginScene()))

it almost not blinking , but still there is some blinking in some parts of the image , dunno why...

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
If you have z-buffering enabled, then you are not clearing the z-buffer...

instead of
    
lp_device->Clear(0,NULL,D3DCLEAR_TARGET,RGB_MAKE(128,128,128),0.0f,0);
[/source]

try
[source]
lp_device->Clear(0,NULL,D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, RGB_MAKE(128,128,128),1.0f,0);


That clears your render target AND the z-buffer, setting all z-buffer values to 1.0 (farthest from the viewer).

Share this post


Link to post
Share on other sites
I''m almost certain it has to do with how you''re updating the screen. It looks like you are only drawing it every other frame. Could you post your screen update code?

----------------------------------------
"Before criticizing someone, walk a mile in their shoes.
Then, when you do criticize them, you will be a mile away and have their shoes." -- Deep Thoughts

"If you have any trouble sounding condescending, find a Unix user to show you how it's done." - Scott Adams

Share this post


Link to post
Share on other sites
    
void Render(D3DTLVERTEX *vrtx,int num_of_vrtx)
{

lp_device->Clear(0,NULL,D3DCLEAR_TARGET,RGB_MAKE(128,128,128),0.0f,0);

lp_device->SetTexture(0,lp_tex);

if(SUCCEEDED(lp_device->BeginScene()))
{
lp_device->DrawPrimitive(D3DPT_TRIANGLESTRIP,D3DFVF_TLVERTEX,vrtx,num_of_vrtx,0);
lp_device->SetTexture(0,NULL);
lp_device->EndScene();
}


}

void UpdateFrame(void)
{
HRESULT hRet;

while(TRUE)
{
hRet = lp_primary->Flip(0,DDFLIP_WAIT);

if(hRet == DD_OK)
break;

if(hRet == DDERR_SURFACELOST)
{
hRet = RestoreAll();
if(hRet != DD_OK)
break;
}

if(hRet != DDERR_WASSTILLDRAWING)
break;
}

}

[/source]

[source]
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,
LPSTR lpCmdLine,int nCmdShow)
{
MSG msg;
HWND hWnd;
WNDCLASS wc;

wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wc.hCursor = LoadCursor(hInstance,IDC_ARROW);
wc.hIcon = NULL;
wc.hInstance = hInstance;
wc.lpfnWndProc = (WNDPROC) WndProc;
wc.lpszClassName = app_name;
wc.lpszMenuName = app_name;
wc.style = CS_VREDRAW | CS_HREDRAW;

RegisterClass(&wc);

hWnd = CreateWindowEx(NULL,app_name,app_title,WS_POPUP,
0,0,0,0,NULL,NULL,hInstance,NULL);

if(!hWnd)
return 0;

ShowWindow(hWnd,nCmdShow);
UpdateWindow(hWnd);
SetFocus(hWnd);

while(1)
{
if(PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
{
if(!GetMessage(&msg,NULL,0,0))
return msg.wParam;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else if(ready)
{

d3d_vrtx[0] = D3DTLVERTEX(D3DVECTOR(0,0,0),1.0,RGBA_MAKE(255,255,255,0),0,0,0);
d3d_vrtx[1] = D3DTLVERTEX(D3DVECTOR(256,0,0),1.0,RGBA_MAKE(255,255,255,0),0,1,0);
d3d_vrtx[2] = D3DTLVERTEX(D3DVECTOR(0,128,0),1.0,RGBA_MAKE(255,255,255,0),0,0,1);
d3d_vrtx[3] = D3DTLVERTEX(D3DVECTOR(256,128,0),1.0,RGBA_MAKE(255,255,255,0),0,1,1);

Render(d3d_vrtx,4);

UpdateFrame();

}
else
{
WaitMessage();
}
}
}



thats how im updating the screen

Edited by - xeno on September 2, 2000 11:54:01 AM

Share this post


Link to post
Share on other sites
nevermind guys , tornado helped me and its working great , thanks anyway
the problem was because i create my primary surface as the render target instead of the back buffer (ops )

Edited by - xeno on September 2, 2000 12:48:34 PM

Share this post


Link to post
Share on other sites

  • Advertisement