Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

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.

PARTNERS