Gdi+ Dev C++
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.
A task-oriented review of an animation library and the application which uses it. The GDI, as a military army, navy, and air force, was officially formed on October 12, 1995, by the final act of the United Nations Global Defense Initiative, in response to the rise of the Brotherhood of Nod and its efforts to gain power in unstable, third-world nations. Before the First Tiberium War began, the GDI followed its mandate under the orders of the United Nations Security Council.
So, as long as you know what you're doing, Windows GDI isn't actually that slow :icon_lol:
Assign a MIDI controller and start tweaking!Finally, let's not forget the easiest-to-use compressor you'll find anywhere. It can 'phatten' up your sound as quickly as you can turn up the 'Amount' knob! Features.
Attached executable:
GDI Animation.zip
Preview Image:
edit: Running in Debug may reduce speed by a lot, set it as Release.
3,534 ViewsHere'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.
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.
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.
Gdi Device
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;
}
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.
Have fun! THANKS AGAIN FOR POSTING THE FAST ANIMATION SNIPPET!
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 :-)
Dev C++ Download For Windows 7
Purpose
The Microsoft Windows graphics device interface (GDI) enables applications to use graphics and formatted text on both the video display and the printer. Windows-based applications do not access the graphics hardware directly. Instead, GDI interacts with device drivers on behalf of applications.
Where applicable
GDI can be used in all Windows-based applications.
Developer audience
This API is designed for use by C/C++ programmers. Familiarity with the Windows message-driven architecture is required.
Gdi+ Tutorial
Run-time requirements
Dev C++ 5.11
For information on which operating systems are required to use a particular function, see the Requirements section of the documentation for the function.