3 ms·
Drawing triangles on a screen is a push-style operation, isn’t it?
by heavenlyblue 6y ago
Drawing triangles on a screen is a push-style operation, isn’t it?
- ajuc 6y agoYes, from the POV of lists of polygons. But from the point view of textures it is pull (you go through destination pixels and fill them with source pixels fetched through transformation).
- heavenlyblue 6y agoIn the same way you could apply the reverse transform to the polygon and get the coordinates of display pixels in texture coordinates and then do a push from there. They are equivalent, as I am trying to say. The only difference is semantics or whatever makes it easier to think about.
- ajuc 6y agoYou would have to skip variable number of pixels in source texture according to the transformation, then calculate the reverse transformation to know where to push. Notice how you not only change x * 4 into x/4, you also change x++ into x+=4 for (int x=0; x<width; x++) for (int y=0; y<height; y++) destination[x][y] = source[x*4][y*4]; vs for (int x=0; x<width; x+=4) for (int y=0; y<height; y+=4) destination[x/4][y/4] = source[x][y]; If it's as simple as scaling: x+=4 isn't much harder than x++. But for complex transformations calculation of how many pixels to skip in any particular row will be slow and complicated. Meanwhile when doing pull you don't need to do it. This is the reason every graphical API i know of does these tranformations iterating over destination pixels.