![]() |
| | #1 |
| Registered User Join Date: Jan 2008
Posts: 153
| 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 |
| Devils Child is offline | |
| | #2 |
| Confused Join Date: Sep 2001 Location: Sweden
Posts: 3,122
| Use a graphics api like DirectX or OpenGL?
__________________ MagosX.com Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime. |
| Magos is offline | |
| | #3 |
| Registered User Join Date: Jan 2008
Posts: 153
| 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? |
| Devils Child is offline | |
| | #4 |
| Rampaging 35 Stone Welsh Join Date: Apr 2007
Posts: 2,924
| 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.
__________________ He is free, you say. Ah! That is his misfortune… These men… [have] the most terrible, the most imperious of masters, that is, need. … They must therefore find someone to hire them, or die of hunger. Is that to be free? - Simon Linguet |
| abachler is offline | |
| | #5 |
| Guest Join Date: Aug 2001
Posts: 4,923
| Keep a copy of the pixels in a flat array. Process, write, process, write. It doesn't get much faster than that. |
| Sebastiani is offline | |
| | #6 |
| Registered User Join Date: Jan 2008
Posts: 153
| 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? |
| Devils Child is offline | |
| | #7 |
| Registered User Join Date: Jan 2008
Posts: 153
| i tried it with directdraw, but couldnt really get a grip on that |
| Devils Child is offline | |
| | #8 |
| Registered User Join Date: Jun 2008 Location: RING 0
Posts: 462
| |
| valaris is offline | |
| | #9 |
| Super Moderator Join Date: Aug 2001
Posts: 7,470
| If you want fast pixel drawing then do not use C#.
__________________ If you aim at everything you will hit something but you won't know what it is. |
| Bubba is offline | |
| | #10 |
| Registered User Join Date: Jan 2008
Posts: 153
| 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... |
| Devils Child is offline | |
| | #11 |
| Registered User Join Date: Jan 2008
Posts: 153
| 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 ![]() thanks. |
| Devils Child is offline | |
| | #12 |
| Super Moderator Join Date: Aug 2001
Posts: 7,470
| 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. EDIT: 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.
__________________ If you aim at everything you will hit something but you won't know what it is. Last edited by Bubba; 08-29-2009 at 12:31 PM. |
| Bubba is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How can I make this code more elegant? | ejohns85 | C++ Programming | 3 | 04-02-2009 08:55 AM |
| Slow drawing code | tjpanda | Windows Programming | 5 | 05-09-2008 05:09 PM |
| Why only 32x32? (OpenGL) [Please help] | Queatrix | Game Programming | 2 | 01-23-2006 02:39 PM |
| DX pixel drawing | VOX | Game Programming | 3 | 07-04-2005 03:59 PM |
| Drawing a single pixel | SMB3Master | C++ Programming | 14 | 05-26-2003 06:17 AM |