V3 function request - version 2
Displaying 21-25 of 25 total.
prev 1 2
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
Beni

What is pixel-pushing? Isn't that just drawing with a computer paint program? And isn't a pixel array just an image? I don't get it.

Posted on 2005-02-12 20:14:32

RageCage

drawing with a computer paint program? no. is a pixel array an image? yes.

The reason for this would be you could generate your own images very fast in code in comparison to verge's setPixel();

Posted on 2005-02-13 01:12:17

Beni

I'm still a bit confused. What do you mean by generate? I load my images from a file, and use blit() to put them on the screen. What would I use setPixel() for?

Posted on 2005-02-13 02:46:28

mcgrue

Rage, you didn't answer his first question. I think there's a conceptual gap between the two of you (talking about seperate things).

Posted on 2005-02-13 04:48:11

Omni

SetPixel() allows you per-pixel access to any image loaded in Verge.

Say, you load your image for a health bar, but then realize there needs to be a red dot at position 0, 10 on it. SetPixel allows you to alter the image from within the code, instead of from outside, in a paint program.

Right now that's the only per-pixel function Verge has. Which means, if you want to create your own pictures, such as a Mode7 background (like those 3D backgrounds in Mario Kart), you've got to do it entirely with SetPixel.

But there's a problem. That means you have to call SetPixel over every pixel on the screen. If you have a 640x480 resolution, that's...a darn lot of pixels. Unfortunately, Verge's SetPixel is pretty slow because of function overhead. Well, technically, it's also slow because VergeC is just interpreted code, and isn't pure C code. Ika's SetPixel() and Pygame (a version of SDL for Python) has a SetAt() function that are all pretty much slow.

What Rage is talking about, is that instead of having to mess with every single call to SetPixel, you can instead assign values to an image array.

The idea is pretty nifty. Assigning a value is faster than a function call, so you could do something like:


int myimagearray[640][480]; //contains the data for a 640x480 image

//...Do some image drawing in the array
while(something)
{
myimagearray[x][y] = somecolor; //Theoretically, this is much faster than a ton of SetPixel() calls
}

//And then display the image, kind of like this.
int myimage = GetImageFromArray('myimagearray'); //Or something similar
Blit(x, y, myimage);


The idea is, a 'GetImageFromArray' would be a function that creates an image from an array much faster than you could do it with SetPixel. (Ever tried making a RotScale or your own Blit or Flipping function with SetPixel? The builtin functions are, in general, much faster).

So, RageCage says a method similar to this would be ideal for rapid image generation.

Does this make sense? ...I probably ended up repeating a lot of unneccesary stuff.



On a vaguely related side-note: As I recall, you could actually use the DMA functions on the 'screen' pointer in Verge2 (Verge3 doesn't allow it), but for some reason it was just about as slow as SetPixel anyway. I didn't, and still don't, quite understand why DMA assignment in VergeC was just as slow as SetPixel. I figured DMA would avoid a lot of overhead.

Posted on 2005-02-13 12:17:24 (last edited on 2005-02-13 12:20:40)


Displaying 21-25 of 25 total.
prev 1 2
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.