Fast pixel drawing
i wondered if there was a way i can draw pixels on a 640x480 form and reach framerates up to 100+ FPS?
i've been doing this with C++ and SDL and i reached the maximum framerate. is there an efficient way to plot pixels in c# with pointers on a form?
speed has most importance on this.
thanks in advance :)
Use a graphics api like DirectX or OpenGL?
there hadnt been any need to ask if it was that easy...
i want to port my software renderer to C# originaly written in SDL (c++). i don't need any SDL since it does not seem to be the right solution.
so if software pixel drawing is as fast as DirectX pixel drawing, i want to do it in software, otherwise how should i do it in directx? any samples?
if speed is the major concern why are you using software rendering in the first place let alone porting to c#? Thats just making a bad problem worse.
Keep a copy of the pixels in a flat array. Process, write, process, write. It doesn't get much faster than that.
i'm writing a _software_ renderer just to do it. it has no further use but to be proud of doing it in software :P
so Sebastiani, how do i handle this pixel writing stuff? i basically need a pointer or an array of 4-byted-colors to write my data to and a flip function. but how?
i tried it with directdraw, but couldnt really get a grip on that :(
If you want fast pixel drawing then do not use C#.
i know how to draw pixels on a bitmap with bitmapdata and lock, but thats not fast, it is very slow. what i'm looking for is some realtime 100-fps drawing on a form...
ok. it seems fairly fast when I use a picturebox with a bitmap and a pointer to the image.
if you have any idea how to get this even faster, post it here :)
Use a language that allows you lower-level access or use your language of choice the way in which it was designed to be used.
You are not supposed to do low level pixel manipulation with C# b/c it is abstracted into a much higher level object like an image. Anytime you try to do low-level pixel manipulation in C# it is going to be slow b/c it was not designed for that.
The whole point of C# is to hide the nitty gritty from you. Whether you agree with that or not is a moot point but if you do not like that you can switch to C++. Personally I find C# is very good for GUI but if you are trying to do something more complex like this you will run into many issues.
You could look into XNA in windowed mode for what you want. However I do not know much about XNA so I cannot give you any further advice about it. You may have better luck at some other forums regarding XNA. Gamedev has a lot of C# XNA devs so you might want to try over there.