Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi Guys,

 

I'm trying to use the StretchRectangle of DirectX3D in window mode, and it throws and exception.

 

Any ideas?

 

Here is the relevant code parts:

 

d3dpp.Windowed = true;

m_localDevice = new Microsoft.DirectX.Direct3D.Device(0, Microsoft.DirectX.Direct3D.DeviceType.Hardware, m_owner, CreateFlags.SoftwareVertexProcessing, d3dpp);

 

---------------------------

m_deviceSurface = m_localDevice.GetBackBuffer(0, 0, BackBufferType.Mono);

Bitmap bmpLayout = new Bitmap("layout.png");

 

// make sure we have the background viewed

m_srfcLayout = new Surface(m_localDevice, bmpLayout, Pool.Default);

 

----------------------------------------------------

 

m_localDevice.BeginScene();

 

//viewBmp(ref m_srfcLayout, 0, 0);

m_localDevice.Clear(ClearFlags.Target, Color.Blue, 0, 0);

//m_localDevice.StretchRectangle(m_srfcLayout, new Rectangle(1, 1, 100, 100), m_deviceSurface, new Rectangle(m_owner.Left + 100, m_owner.Top + 20, 100, 100), TextureFilter.None);

m_localDevice.StretchRectangle(m_srfcLayout, new Rectangle(1, 1, 100, 100), m_deviceSurface, new Rectangle(100, 20, 100, 100), TextureFilter.None);

 

m_localDevice.EndScene();

m_localDevice.Present();

Posted
What part throws an exception? And I recommend using a Texture and the Sprite class, rather than surfaces, for one thing it's easier to use the textures over surfaces and textures can be alphablended.
.Net allows software to be written for any version of Windows and not break like Unmanaged applications unless using Unmanaged procedures like APIs. If your program uses large amounts of memory but releases it when something else needs it, then what's the problem?
Posted

Hi,

 

First - thanks for your answer.

 

The exception thrown is general: "Error in the application".

It is thrown in the .StretchRectangle line.

 

But i found the error, i tried blitting from diffrent PixelFormat surfaces.

The best thing is to use .CreateOffPlainSurface method and use the same PixelFormat.

 

A few more questions:

1. How do i convert the Images i use from diffrent pixel-formats?

2. You suggested using Sprite class - which is better than surfaces, i agree. The problem is that i need to create a picture off screen and then show the full thing on screen, Sprite class draws directly on the device. Is there another way i can use it?

 

Thanks - LDV

Posted

The SurfaceLoader class may be able to convert image's pixelformats, the TextureLoader does anyway.

 

The Sprite class draws to the device using screen coordinates which saves the trouble in trying to calculate billboards(The sprite class can render billboards too). If you're combining different pictures, can't you do that on the BackBuffer instead of an offscreen surface? The Texture class also has a function(GetSurfaceLevel) which allows you to edit the underlying surface directly if you want to, I've never needed to use it so I don't know how it works though.

.Net allows software to be written for any version of Windows and not break like Unmanaged applications unless using Unmanaged procedures like APIs. If your program uses large amounts of memory but releases it when something else needs it, then what's the problem?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...