Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!

Prasoon Pankaj

Member Since 16 Sep 2010
Offline Last Active Jan 14 2012 04:04 AM

Posts I've Made

In Topic: Quick code to get a WPF Visual to DirectX Texture (performance wise)

24 April 2011 - 09:36 PM

I tried to load the data using CopyPixels(), but it throws D3DXERR_INVALIDDATA exception.

RenderTargetBitmap bmp = GetBitmap();// copy into a byte array
int stride = bmp.PixelWidth * 4; 
byte[] data = new byte[bmp.PixelHeight * stride]; 
bmp.CopyPixels(data, stride, 0); // create texture
using (MemoryStream ms = new MemoryStream(data))
    ms.Seek(0, SeekOrigin.Begin);
    if (dxDevice != null)
        // next line throws D3DXERR_INVALIDDATA exception
        texture = TextureLoader.FromStream(dxDevice, ms);

In Topic: Is VertexBuffer Lock/Unlock appropriate in this case?

22 April 2011 - 11:44 AM

It was giving me some hit. So, I changed the logic to use CustomVertex.Transformed[] and used the following logic in my render loop:

var blendedFillColor = /* color remains the same, just changing the alpha value */;

device.TextureState[0].ConstantColor = blendedFillColor;
device.TextureState[0].ColorOperation = TextureOperation.SelectArg1;
device.TextureState[0].AlphaOperation = TextureOperation.SelectArg1;
device.TextureState[0].ColorArgument1 = TextureArgument.Constant;
device.TextureState[0].AlphaArgument1 = TextureArgument.Constant;

device.SetStreamSource(0, this._vertexBuffer, 0);
device.VertexFormat = CustomVertex.Transformed.Format;
device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);

Anything you guys wanna suggest?

In Topic: Is VertexBuffer Lock/Unlock appropriate in this case?

17 April 2011 - 10:59 PM

Instead of changing the information per vertex, why not set an alpha value per object? There isnt a need to change it per vertex when it can be set in the shader.

Can you please share few links to the stuff you are talking about? Or may be a sample code to illustrate.

In Topic: [MDX] Not able to get stencil to work

17 September 2010 - 01:26 AM

So, I finally figured it out. It's all related to Sprites and its Begin() method.

Sprite.Begin() will modify the RenderState and disable stencil. We can prevent it by setting SpriteFlags.DoNotModifyRenderState flag, but then the alpha blending is not supported when sprites are drawn.

What I did now was simply call Sprite.Begin() without SpriteFlags.DoNotModifyRenderState flag set. And before the call to Sprite.Draw(), enabled stencil on the device.

In Topic: [MDX] Not able to get stencil to work

16 September 2010 - 08:57 PM

OK.. So I figured out how to get it done. Referred to this post - http://www.gamedev.net/community/forums/viewreply.asp?ID=1999276

But now the sprite is ignoring alpha values and rendering sprites opaque. Similar to the effect we get when alpha blending is set to false.