These compilers can create both 32bit and 64bit executables and generally ship with much more Microsoft related headers and libraries. When you place these compilers in Dev-CppMinGW64, Dev-C can automatically configure them on first launch or via Tools Compiler Options Find Compilers. I can initialize GDI+ in visual C 2003 with MFC. But i can not initialize it in VC 2005, i refer to MSDN library i found this: If you want to initialize GDI+ for your application (by calling GdiplusStartup in your InitInstance function), you will need to suppress the GDI+ background thread. You can do this by setting the SuppressBackgroundThread member of the GdiplusStartupInput structure.
Quite a while ago, I made '>this snippet. This code is basically the same, except that it adds animation.
This method of blitting is very fast assuming you don't use a surface that's too large. On a 500 x 500 surface, I managed 350fps using only 0-1% of the cpu. This snippet may appear much slower because of the amount of CPU it's applying to each pixel, but the blitting itself is very fast. Also, don't forget that an average game will only redraw parts of the window that need redrawing, this redraws the whole surface every time.
So, as long as you know what you're doing, Windows GDI isn't actually that slow :icon_lol:
Attached executable: GDI Animation.zip Dev C++ DownloadPreview Image:
edit: Running in Debug may reduce speed by a lot, set it as Release.
3,534 Views
Here's a speed test :) mine stays at about 480fps with only 2-3% CPU.
William Hemsworth1,339
Another really nice effect using this method :icon_smile:
Got it working with objects and bitmaps, I think with some optimizations I could use this to make some neat games :)
optimumgaint
Sorry, I should have tested it with multiple compilers, replace that line with:
and it should work.
mrnutty761
Pretty cool. Looks something someone will see if they were high of drugs. Auto shops near tune up 2017.
Pretty cool. Looks something someone will see if they were high of drugs.
Haha, what have you been smoking? I'd go crazy if anything turned out that intense.
Thanks alot for the feedback :icon_razz: Dave Sinkula2,398
Issues when building with mingw:
main.cpp:12: error: ISO C++ prohibits anonymous structs
main.cpp: In function `void onFrame(pixel*)': main.cpp:60: error: expected primary-expression before 'unsigned' main.cpp:60: error: expected `;' before 'unsigned' main.cpp: In function `void MakeSurface(HWND__*)': main.cpp:134: warning: passing NULL used for non-pointer converting 2 of `void* CreateThread(_SECURITY_ATTRIBUTES*, DWORD, DWORD (*)(void*), void*, DWORD, DWORD*)' main.cpp:134: warning: passing NULL used for non-pointer converting 5 of `void* CreateThread(_SECURITY_ATTRIBUTES*, DWORD, DWORD (*)(void*), void*, DWORD, DWORD*)' main.cpp: In function `int WinMain(HINSTANCE__*, HINSTANCE__*, CHAR*, int)': main.cpp:237: warning: passing NULL used for non-pointer converting 4 of `BOOL GetMessageA(tagMSG*, HWND__*, UINT, UINT)'
This includes the cast you've already corrected. So it's mostly just that anonymous struct you may want to look at.
[edit]Also, the necessary library to link with:
-LD:ProgramsCodeBlocksMinGWlib -lgdi32
Where the path to the library will be whatever your install might be.
Edited by Dave Sinkula: n/a
This includes the cast you've already corrected. So it's mostly just that anonymous struct you may want to look at.
Does giving the anonymous structure a name fix that?
Never thought there would be so many compiler issues, and I didn't realize that anonymous structs weren't allowed.
Thanks :)
Dave Sinkula2,398
Does giving the anonymous structure a name fix that?
Yup. I just named it
s , for example.
Hi, thanks for the cool code. I got it working in a Win32 app (project type choice) in VC++ Express 2010 by making the includes:
#include 'stdafx.h' #include 'GDIWin32.h' #include <windows.h> #include <iostream> #include <cmath>
and putting the L in front of the quoted text, as in:
// Init wc wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.cbSize = sizeof( WNDCLASSEX ); wc.hbrBackground = CreateSolidBrush( 0 ); wc.hCursor = LoadCursor( NULL, IDC_ARROW ); wc.hIcon = LoadIcon( NULL, IDI_APPLICATION ); wc.hIconSm = LoadIcon( NULL, IDI_APPLICATION ); wc.hInstance = hInstance; wc.lpfnWndProc = WndProc; wc.lpszClassName = L'animation_class'; wc.lpszMenuName = NULL; wc.style = 0; ![]()
// Register wc
if ( !RegisterClassEx(&wc) ) { MessageBox( NULL, L'Failed to register window class.', L'Error', MB_OK ); return 0; }
D750 auto af fine tune. Very cool, thanks very much. Any thoughts on how this could be implemented in a Windows Forms Application? (Sorry if this is a really stupid question, just starting in VC++.) Thanks again, Bill
Bill Dreschel
Finally got around to putting this animation code into a Visual C++ 2010 Express Windows form application. To use it, start a new form build, add a PictureBox, name it 'src' and make it some even dimension like 400,400. Add a button, name it 'btnStart', text to 'Start', add a timer to the form, set it to 20ms and disabled.
Add the attached code. Gdi+ Example
Have fun! THANKS AGAIN FOR POSTING THE FAST ANIMATION SNIPPET!
Dev C++ Online
Edited by mike_2000_17: Fixed formatting
Hi,
And this is a C Sharp version from Bill Dreschel's code. The picture box I used named 'pictureBox1'. It looks pretty good. I post this here because I found this article while I was searching for a CSharp solution about something like this. And I think it may help someone like me :-)
Edited by thetukiet: adb
Hi
I want to make an MFC app which displays controls on the left and a bitmap with some graphics on the right. My problem is now, how do I have to draw the graphic elements (gdiplus rectangle , line, circle) so that they are always on the same position in relation to the windows controls? I draw the controls in Visual Studio 2019 with the resource editor, the graphic elements are drawn by code. (DPI is set to HIGH in the mfc project settings). I have drawn two red rectangles, one with the size of the dialog and an inner one which is the size of a group box. For the size of the dialog rectangle I use GetClientRect. It works on all font sizes (DPI scalings) correct. For the inner rectangle inside the group box I tried to recalculate the coords with GetDeviceCaps, but that does not work. If I change scaling in windows the inner rectangle is completely off. So I tried to figure out the correct coords for the inner rectangle by trial and error. Below are the coords which draw the correct rectangles in relation the the group box. But how can I calculate them, I get some weird values? In the x axis I would get a factor of 1.3328 and on the y axis a factor of 1.62 with 150% scaling???? http://public.stattegg.info/_old/dpiproblem.jpg // coords at 100% Dialog rectangle coord = 0/0 - 1445/832 group box rectangle coord = 624/9 - 1247/581 // coords at 125% Dialog rectangle coord = 0/0 - 1685/1088 group box rectangle coord = 728/11 - 1456/761 // coords at 150% Dialog rectangle coord = 0/0 - 1926/1344 group box rectangle coord = 831/13 - 1664/941 How can I calculate the right coordinates for this elements ? thanks regards Erich Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |