View Full Version : Fast drawing
Minuous
July 1st, 2006, 22:49
'm the coder of the WinArcadia emulator, which is now feature-complete. I want to optimize it as it is extremely slow, it only achieves 1-2 FPS in most modes, this is with the CPU emulation turned off! The Amiga port of WinArcadia runs faster than this, even through WinUAE!
I'm using SetPixel()/ClipBlit() to do the drawing. Apparently it is much quicker to use SetBitmapBits(), but there doesn't seem to be any reasonable documentation about it.
If I may say so the entire Windoze display subsystem is a joke, it seems convoluted and poorly designed, things are much easier to do on an Amiga. The documentation over at MSDN is absolute crap and there doesn't seem to be any tutorials about it.
I don't want to use DirectX as I know for a fact that it is not necessary to gain adequate performance, there are other emulators of more complex machines which achieve good performance with GDI.
All I need to do is plot pixels one at a time to a bitmap, it only needs to be 8 colours (3 bitplanes), and refresh the window after each frame has been drawn. It already does this of course but much too slowly.
Aaarrrggh....
Doomulation
July 1st, 2006, 23:08
It's called Windows, btw and DirectX was created to make graphics rendering easy while fast.
ShizZy
July 2nd, 2006, 04:19
Try SDL? :P
Poobah
July 2nd, 2006, 09:13
Does GDI give you direct access to the screen's location in video memory? SetPixel() functions in just about any API are slow, because they usually do all sorts of checking and other things.
I do agree with you on the Windows display thing. Programming graphics stuff in DOS was easy, but in Windows we are pretty-much forced to learn a bloated API.
gladius
July 2nd, 2006, 09:16
http://www.gaffer.scene.org/tinyptc/. If you must do it yourself, the bitblt API is extremely well documented and pretty darn easy to use as well. The function you want to use is called BitBlt (or a variant thereof). Check out http://www.winprog.org/tutorial/bitmaps.html and then take a look at SetDIBits to get a device indepdent bitmap (which will give you byte r,g,b format easily).
If you want to stick to GDI, I advise you to use CreateDIBSection, to get a pointer to the bitmap pixel bits, which you can write to directly instead of a slow SetPixel or similar function, and just use BitBlt to blit it to the screen.
*edit* didn't read gladius' post, he basically said the same thing.
Minuous
July 2nd, 2006, 18:20
Thanks all, I had a look at http://www.gaffer.scene.org/tinyptc/ and based it on that code. It's dozens of times faster now :-)
@Doomulation: There was no need to use DirectX, why force the users to download and install yet more bloatware? Windoze is bloated enough :-)
Minuous
July 2nd, 2006, 18:24
Thanks all, I had a look at http://www.gaffer.scene.org/tinyptc/ and based it on that code. It's dozens of times faster now :-)
@Doomulation: There was no need to use DirectX, why force the users to download and install yet more bloatware? Windoze is bloated enough :-)
Doomulation
July 2nd, 2006, 18:24
Thanks all, I had a look at http://www.gaffer.scene.org/tinyptc/ and based it on that code. It's dozens of times faster now :-)
@Doomulation: There was no need to use DirectX, why force the users to download and install yet more bloatware? Windoze is bloated enough :-)
Windoze = Windows.
Anyway, although I haven't tryied GDI, try 3D using it. I'm sure you'll get a headache. Besides that, DirectX isn't bloated, but pretty useful. DirectInput for example. Catches keys and much more flexible than Windows standard input mechanism. DirectShow, which is now part of the Windows SDK, can be used for a lot of things using a filter system. Easily integrated into media players for easy playback.
I consider DirectX to be something good. And for a reason.
bcrew1375
July 2nd, 2006, 19:23
Windoze = Windows.
Um, I can't tell if you're being serious or not. It's a joke :P.
Doomulation
July 2nd, 2006, 19:29
Perhaps, but I should still point out that it is Windows. Wondoze and m$ and such "jokes" that I would simply reject now. Let's be serious.
Minuous
July 2nd, 2006, 22:23
Yes, Windows (happy now?) is a bit of a joke isn't it!! :-)
I never said I wanted to do 3D graphics, obviously I would use some kind of 3D subsystem for that rather than reinvent the wheel...
Doomulation
July 2nd, 2006, 22:59
No, but you did refer to DirectX to be bloated and DirectX is a collection of DirectInput, DirectDraw, Direct3D, DirectSound, DirectPlay and DirectShow.
Garstyciuks
July 3rd, 2006, 13:44
@Doomulation: There was no need to use DirectX, why force the users to download and install yet more bloatware? Windoze is bloated enough :-)DirectX is already installed with Windows or is usually installed when installing video card drivers for Windows.
Doomulation
July 3rd, 2006, 13:52
Not to mention it is usually included with every game you buy.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.