Jump to content

  • Log In with Google      Sign In   
  • Create Account


axefrog

Member Since 08 Apr 2011
Offline Last Active Aug 25 2014 02:33 AM

Posts I've Made

In Topic: SharpDX / Direct2D - Plotting pixels directly onto a bitmap or back buffer?

29 July 2014 - 06:56 PM

I found a good way to do this, if it helps anyone. Seems to be relatively fast as well. I keep a raw byte array in memory and copy its contents to a bitmap which is then blitted to the render target when ready.

 

In the constructor:

_memory = new byte[Width * Height * 4];
_backBufferBmp = new Bitmap(_renderTarget, new Size2(Width, Height), new BitmapProperties(_renderTarget.PixelFormat));

Here's how I draw raw pixels:

public void DrawPoint(int x, int y)
{
	var i = (int)(Width * 4 * y + x * 4);
	_memory[i] = _fgColor.B;
	_memory[i+1] = _fgColor.G;
	_memory[i+2] = _fgColor.R;
	_memory[i+3] = _fgColor.A;
}

And finally, when the memory contents are ready to be displayed:

_backBufferBmp.CopyFromMemory(_memory, Width * 4);
_renderTarget.DrawBitmap(_backBufferBmp, 1f, BitmapInterpolationMode.Linear);

Works like a charm.


In Topic: C# UI libraries? Either written in managed code, or with managed wrappers

27 July 2014 - 04:15 AM

Thanks I'll check them out!


In Topic: Are some people not cut out for programming?

11 March 2014 - 08:44 AM

So I decided to write a c++ parser, lots of string manipulation, plenty of substr's and find_first_of \n \t \f et al.

How long have you been coding for? I've been at it for over 15 years and I am still improving to this day. Generally speaking, and based only on my limited observations, it takes 5 years to become reasonably competent and 10 years to get past your desire (and failed attempts) to overarchitect things and reinvent wheels, and start to feel really competent. And even at 15 years you'll feel a lot more competent than you did at ten years of experience. Best advice is to not lose heart, keep coding, do the best you can and accept that you'll have to go through all of the failures, mistakes, different types of development processes, and so forth, in order to truly understand what you're doing and what the implications of any of your decisions will truly mean. Learn by doing and improve with each attempt.


In Topic: Beginner: not performing CPU-wise calculations on objects outside of camera s...

11 March 2014 - 05:45 AM

Cool, thanks for your replies, they were both very helpful!


In Topic: Cull mode inverted for some reason?

10 March 2014 - 03:33 AM

It’s not. First you define which direction defines a front face (clockwise or counter clockwise) and then you decide whether you want to cull front faces or back faces. I personally use clockwise, but whether one is used more than the other or by whom one is used is rather arbitrary—there is no reason to pick one over the other except that that is how your toolchain works.


L. Spiro

Ah, thanks, that's helpful. I wonder if it's a bug in SharpDX for configuring the Rasterizer.Default() method to have the winding order mismatched with the cull mode.


PARTNERS