Results 1 to 24 of 24

Thread: Cpp to C# drawing speed test complete. Download available here.

  1. #1

    Thread Starter
    Frenzied Member aewarnick's Avatar
    Join Date
    Dec 2002
    Posts
    1,037

    Cpp to C# drawing speed test complete. Download available here.

    These files have no viruses or anything unusual.
    To compare the speed of Cpp to C# just unzip the exe's.
    Directions are included.

    2 things: You need the .net framework or winxp or higher.
    I made the cpp file with Borland. Let me know if it does not work.
    Last edited by aewarnick; Jul 18th, 2003 at 11:42 AM.

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Just use the code if its there.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3
    Hyperactive Member
    Join Date
    Sep 2001
    Posts
    396
    aewarnick : I managed to get it compile in VC7. But there is nothing, except "jlkjgas" word on the screen. Did you upload the correct source?
    Last edited by transcendental; Jul 20th, 2003 at 12:40 AM.

  4. #4

    Thread Starter
    Frenzied Member aewarnick's Avatar
    Join Date
    Dec 2002
    Posts
    1,037
    Remember how I mentioned placing any bitmap into the directory and naming it "pic.bmp"...

    Also, I have updated news and am VERY excited. I have gotten cs to be much much faster! I just skipped over using some of it's convieniences like drawing with drawImage instead of BitBlt and especially the automatic double buffering, that made the biggest difference.

    You will see that soon!
    Last edited by aewarnick; Jul 20th, 2003 at 09:43 AM.

  5. #5
    Hyperactive Member
    Join Date
    Sep 2001
    Posts
    396
    I have already done that before I made that post. It doesn't work. I even put the full path, it still doesn't work.
    But there is nothing, except "jlkjgas" word on the screen. Did you upload the correct source?

  6. #6
    Hyperactive Member
    Join Date
    Sep 2001
    Posts
    396
    The cs program works. Now I'm very sure you posted the wrong code.

    In main.cpp

    Code:
    void a::DrawImage(HBITMAP hBmp, int *posX, int *posY, int *sizeW, int *sizeH)
    {
    	
    }
    };
    .....
    
    
            case WM_PAINT:
            {
            if(draw)
            {
            PAINTSTRUCT lpPaintStruct;
            HDC hdc= ::BeginPaint(thisHwnd, &lpPaintStruct);
    
            A.DrawImage(thisHwnd, hdc, hImage,W,H, &lpPaintStruct.rcPaint, &drawRect);
    
            ::DeleteDC(hdc);
            ::EndPaint(thisHwnd, &lpPaintStruct);
            }
            }
    In a.cpp
    Code:
           
            case WM_PAINT:
            {
            PAINTSTRUCT lpPaintStruct;
            HDC hdc= ::BeginPaint(h, &lpPaintStruct);
            RECT rect;
            rect.left=0; rect.top=0; rect.right=500; rect.bottom=500;
            ::DrawText(hdc, "jlkjgas", -1, &lpPaintStruct.rcPaint, NULL/*DT_CENTER*/);
    
            ::DeleteDC(hdc);
            ::EndPaint(h, &lpPaintStruct);
            }

  7. #7

    Thread Starter
    Frenzied Member aewarnick's Avatar
    Join Date
    Dec 2002
    Posts
    1,037
    Don't bother posing it back unless you changed something to get it to work.

    This is where I am having the problem right now:
    if(formsWndProc)
    ::CallWindowProc(formsWndProc, hwnd, message, wParam, lParam);

    [C++ Error] main.cpp(125): E2342 Type mismatch in parameter 'lpPrevWndFunc' (wanted 'int (__stdcall *)()', got 'long (__stdcall *)(void *,unsigned int,unsigned int,long)')

    Did you have the same problem or did it just compile?

  8. #8

    Thread Starter
    Frenzied Member aewarnick's Avatar
    Join Date
    Dec 2002
    Posts
    1,037
    Got it working. Although only with Borland. You will have to compile the code for the C++ program.

    I included a cs regular buffed program and a cs optimized buffed program.
    Attached Files Attached Files

  9. #9
    Hyperactive Member
    Join Date
    Sep 2001
    Posts
    396
    Originally posted by aewarnick

    [C++ Error] main.cpp(125): E2342 Type mismatch in parameter 'lpPrevWndFunc' (wanted 'int (__stdcall *)()', got 'long (__stdcall *)(void *,unsigned int,unsigned int,long)')

    Did you have the same problem or did it just compile?
    I did not have this error. I had some other error which went away after I changed ext of a.cpp to a.h .

  10. #10

    Thread Starter
    Frenzied Member aewarnick's Avatar
    Join Date
    Dec 2002
    Posts
    1,037
    I think the error was some kind of Borland junk and that is why you didn't get the error. Dev does not get it either. I will try renaming the a.cpp file to a.h and see if Dev knows what prototypes are then.

  11. #11

    Thread Starter
    Frenzied Member aewarnick's Avatar
    Join Date
    Dec 2002
    Posts
    1,037
    I was going to post the new file compiled with Dev but the exe is 476kb!! Is there any way to slim that down to 27kb where Borland was?

  12. #12
    Hyperactive Member
    Join Date
    Sep 2001
    Posts
    396
    At least it is better than having to distribute the DLLs with the 27KB app.

    Email to me.
    Last edited by transcendental; Jul 21st, 2003 at 12:30 AM.

  13. #13

    Thread Starter
    Frenzied Member aewarnick's Avatar
    Join Date
    Dec 2002
    Posts
    1,037
    You are right about that, however, my program barely has anything in it. A C# app with a bunch of code only compiles to 80kb.

    I didn't use anything in the Borland dll's (that I know of). The same code I compiled with Borland I also just now compiled with Dev. One very very minor change to get Borland to compile the code but that would not use the dll's to do it.

    Maybe I don't understand what is going on in the Dev compiler. I just see my code and say wow, a big file for such little code!
    Last edited by aewarnick; Jul 21st, 2003 at 11:51 AM.

  14. #14
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    I will look it over when I'm home. I'm very suspicious of everything calling C# faster than C++...
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  15. #15

    Thread Starter
    Frenzied Member aewarnick's Avatar
    Join Date
    Dec 2002
    Posts
    1,037
    No need to be suspicious, I didn't say it was faster, I just said I made one of the C# programs faster than the other C# program by not using the SetStyle DoubleBuffer. I used my own double buffing technique. You will see that the C++ program is much much much much much much much faster! Not that much faster, but you get my point.

    Here is the 1st part of 3 downloads:
    Attached Files Attached Files

  16. #16

    Thread Starter
    Frenzied Member aewarnick's Avatar
    Join Date
    Dec 2002
    Posts
    1,037
    2:
    Attached Files Attached Files

  17. #17

    Thread Starter
    Frenzied Member aewarnick's Avatar
    Join Date
    Dec 2002
    Posts
    1,037
    3: Comes with the merge file to put it back together again.
    Attached Files Attached Files

  18. #18

    Thread Starter
    Frenzied Member aewarnick's Avatar
    Join Date
    Dec 2002
    Posts
    1,037

    Something really really weird just happened!!!

    This is weird in the full definition of the word!!!!!______-----++==
    I installed a program (Ulead Photo Express) on my computer, rebooted and when I ran the same programs I posted here the C++ program now runs as slow as the cs optimized program!!!

    Before I restarted the computer it was at least twice as fast!!! What happed? There is no memory leak and the file was untouched.

    I know Photo Express does not have a virus or anything like that.
    I did recently just install a hard drive on my computer though (D and it is not installed properly. It isn't mounted, I just attatched the wires.

    My one browser is acting strange too.

    Is there any explanation for this??
    Last edited by aewarnick; Jul 21st, 2003 at 01:20 PM.

  19. #19

    Thread Starter
    Frenzied Member aewarnick's Avatar
    Join Date
    Dec 2002
    Posts
    1,037

    It gets more weird!!!

    I am guessing it is the hard drive so I copy the c++ file and the picture to the c drive. Both files work correctly on both drives.

    This is the weird part. I delete the file and pic from c, still works right on d.
    I CLOSE THE C FOLDER, then it goes back to being slow!!!!

    In fact, every time I open the C folder the program on d works perfecly, but when I close the c folder it does not.

    I know this has nothing to do with my C++ program but why does it not effect the cs programs?

    Have you ever heard of anything like this before?

  20. #20

    Thread Starter
    Frenzied Member aewarnick's Avatar
    Join Date
    Dec 2002
    Posts
    1,037
    I rebooted and now everything is fine. I guess something didn't hook right for the Photo Express install the first time.

    You have to admit that was very very strange.

  21. #21
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Windows IS very strange.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  22. #22

    Thread Starter
    Frenzied Member aewarnick's Avatar
    Join Date
    Dec 2002
    Posts
    1,037
    I am glad I am not alone on that one.
    By the way I did not use any other source code in any of those programs except my own. So I know my programs did not cause that weird stuff to happen.

  23. #23
    Hyperactive Member
    Join Date
    Sep 2001
    Posts
    396
    I notice your C++ code contains my custom alphablend code. Why?

  24. #24

    Thread Starter
    Frenzied Member aewarnick's Avatar
    Join Date
    Dec 2002
    Posts
    1,037
    It's just waiting there for me to finally getting around to testing it out. I have not used it yet but it will be part of the a class.
    Do you want me to remove it?

    What I meant above was in the C# apps where the source was not included. I had forgotten all the AlphaBlend code of yours in the C++ source. Sorry transendental, I forgot it was there or else I would have mentioned it.
    Last edited by aewarnick; Jul 22nd, 2003 at 09:07 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width