![]() |
| | #1 |
| Registered User Join Date: Aug 2001
Posts: 79
| Speeding up vga graphics and allegro tutorial The problems is that sometimes the picture flickers (after all it's quite a lot of pixels to plot, and NO, I do not use BIOS interrupts to plot them). Is ther any (easy) way to speed up the drawing? I use djgpp btw. Also, does anyone know of a good tutorial for the allegro game library? |
| Hannwaas is offline | |
| | #2 |
| Blank Join Date: Aug 2001
Posts: 1,034
| You should know that allegro as functions to load bitmaps and blit them. Just drawing the pixels bit by bit with like putpixel is very slow. http://www.grandgent.com/gfoot/ |
| Nick is offline | |
| | #3 |
| Skunkmeister Join Date: Aug 2001
Posts: 2,572
| Alternatively you could use memcpy() to copy the array to screen memory. Check out the vga tutorials here
__________________ Free the weed!! Class B to class C is not good enough!! And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi |
| Stoned_Coder is offline | |
| | #4 |
| Registered User Join Date: Aug 2001
Posts: 79
| Thanks for the help. About allegro tutorials, I downloaded one called Allegro Vivace but I haven't had time to look much on it yet. Anyone know if it's good or should I try another one? |
| Hannwaas is offline | |
| | #5 |
| Super Moderator Join Date: Aug 2001
Posts: 7,812
| The best way to do fast bit blts is either use a fast library and call those functions specific to bit blts or use assembly to code your own. I've tried using the various memory functions in C to do this, but I've found that trying to blt 1 line of pixels from a bitmap to the screen or to a buffer using the memory functions is actually slower than just plotting the pixels via a pointer. Memcpy also requires that the area to be blitted extend from the left side of the screen to the right side. If you have a small bitmap, this can be a waste of time. Also for a speed increase do not store your bitmaps in a two dimensional array. It is far slower to access a two dimensional array than a one dimensional or linear array. To access a one dimensional array using two values: Offset=y*Width+x y = the vertical component x = the horizontal component Width= the Width of the buffer, image, sprite, etc. Offset=the number which would refer to the value at x,y As well for very quick calculations use bit shifts instead of multiplications. Offset=(y<<6)+(y<<8)+x This will give you the offset in memory from segment A000h to plot a pixel at x,y in mode 13h - 320x200x256. I've tried turning optimizations on for those who are compiler reliant, but using bit shifts still seems to be faster than just using compiler optimizations. As for flickering, it should not do that. Check out www.brackeen.com and www.programmersheaven.com for information on creating a double-buffer for your program. |
| Bubba is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Game Programming FAQ | TechWins | Game Programming | 5 | 09-29-2004 02:00 AM |
| Question about allegro and other graphics libraries.... | o0obruceleeo0o | Game Programming | 2 | 06-11-2003 11:02 PM |
| Special Allegro Information | TechWins | Game Programming | 12 | 08-20-2002 11:35 PM |
| Allegro graphics trouble | Brian | C++ Programming | 0 | 02-25-2002 02:36 PM |
| allegro graphics library for linux | oldcoyote | Linux Programming | 3 | 10-03-2001 10:24 AM |