strange antialiasing depending on window size

Started by
6 comments, last by Raloth 20 years, 2 months ago
Something is antialiasing my terrain around the edges. It isn't consistent though. If I make my window larger/smaller it shifts around. The presentation parameters have the backbuffer width and height set to that of the resolution. I plan on using swap chains to get multiple views but still haven't gotten them working quite right, so they are disabled right now. I set the projection matrix like so:
	D3DXMATRIX projection;
	float ratio = (float)width/(float)height;
	RECT rect;
	GetClientRect(hWnd,&rect);
	float x = (float)rect.right/(float)width;
	float y = (float)rect.bottom/(float)height;
	D3DXMatrixPerspectiveLH(&projection,x*ratio,y,1.0f,1024.0f);
	d3ddevice->SetTransform(D3DTS_PROJECTION,&projection);  
width and height are the resolution of the screen. The way I do this keeps it so that an object always stays the same size, no matter what size I make the window. Unfortunately something is causing this to happen: sometimes it is very noticeable: http://www20.brinkster.com/raloth/strongalias.bmp sometimes not so noticeable: http://www20.brinkster.com/raloth/weakalias.bmp sometimes it's not there at all: http://www20.brinkster.com/raloth/noalias.bmp The images have been blown up so the effect is clearer. Can anyone help me out? (sorry for not giving a direct link to those, they don't allow remote linking) [edit] Antialiasing is set to application preference in the driver settings, and I have not turned it on through my program. [edited by - Raloth on January 25, 2004 12:53:01 PM]
____________________________________________________________AAAAA: American Association Against Adobe AcrobatYou know you hate PDFs...
Advertisement
If you resize a windowed D3D device without resizing the back buffer, the window automatically resizes it, resulting in an antialiased image. So either recreate the device when the window is resized, or don''t let the window be resized.
I will see what happens when I get the swap chains working, that way I can just destroy/recreate them to resize instead of recreating the device...
____________________________________________________________AAAAA: American Association Against Adobe AcrobatYou know you hate PDFs...
I added in the swap chains but it is still not working. I am following the article found at http://www.mvps.org/directx/articles/rendering_to_multiple_windows.htm. It says:

DirectX will automatically deal with changes in the child view by using a stretch blit to present the swap chain if the dimensions have client area is not the same size as the swap chain's frame buffer. However, this may not be desirable, as it will cause aliasing if the client area is increased in size.

To prevent this, you can write a handler for the WM_SIZE message of the child window. The handler should release the existing swap chain, and create a new swap chain using the code from Step 2.


I do that, but it still does the antialiasing.

[edited by - Raloth on January 25, 2004 2:27:16 PM]
____________________________________________________________AAAAA: American Association Against Adobe AcrobatYou know you hate PDFs...
Are you setting the device/swapchain backbuffer dimensions to the window size, or the window''s clientrect size? You want the clientrect.

Also, if you are doing 2D you''ll want to make sure you plot to the pixel''s center, not it''s edge. ie: if you use an RHW coord, use 0.5, not 0, and use 640.5, not 640.
I just tell the presentation parameters the window handle and let it figure out the client rect itself.

[edit] The device has its dimensions set to the resolution of the desktop, the swapchain has its dimensions set to the client area of the window.

[edited by - Raloth on January 25, 2004 2:44:25 PM]
____________________________________________________________AAAAA: American Association Against Adobe AcrobatYou know you hate PDFs...
If I had to guess, I''d say that your back buffer is smaller than the window''s client rect (which is what everyone else has said).

As a test, when the aliasing occurs call GetBackBuffer/GetDesc and compare the width and height to the dimensions of the rect returned from GetClientRect of your window.

Thanks...for some reason it wasn''t recalculating the client rect when I made the swap chain again. I did it manually and it works fine now . Stupid stubornness of mine...
____________________________________________________________AAAAA: American Association Against Adobe AcrobatYou know you hate PDFs...

This topic is closed to new replies.

Advertisement