diff options
| -rw-r--r-- | include/swgfx.h | 14 | ||||
| -rw-r--r-- | src/swgfx.c | 2 |
2 files changed, 10 insertions, 6 deletions
diff --git a/include/swgfx.h b/include/swgfx.h index 4a98116..d1f56df 100644 --- a/include/swgfx.h +++ b/include/swgfx.h | |||
| @@ -2,10 +2,16 @@ | |||
| 2 | Software rendering library. | 2 | Software rendering library. |
| 3 | 3 | ||
| 4 | Coordinate systems: | 4 | Coordinate systems: |
| 5 | - Pixel coordinates (i,j) refer to the center of the pixel. | 5 | - The coordinate systems for image addressing and texture sampling are the same |
| 6 | Thus, real-valued coordinates (x,y) with no fractional part point at the pixel center. | 6 | except in scale. |
| 7 | - Viewport origin is the top-left corner of the screen. | 7 | Origin is in the top-left corner of the image. |
| 8 | The viewport axes extend down and to the right. | 8 | Axes extend down and to the right. |
| 9 | - Image addressing: | ||
| 10 | (i,j) integer coordinates refer to the center of the pixel. | ||
| 11 | - Texture addressing: | ||
| 12 | (u,v) range in [0,1]. | ||
| 13 | (0,0) is the center of the top-left pixel. | ||
| 14 | (1,1) is the center of the bottom-right pixel. | ||
| 9 | 15 | ||
| 10 | Multi-threading: | 16 | Multi-threading: |
| 11 | - Internal resources (swgfx context) are externally synchronized. | 17 | - Internal resources (swgfx context) are externally synchronized. |
diff --git a/src/swgfx.c b/src/swgfx.c index 3bec663..7ade051 100644 --- a/src/swgfx.c +++ b/src/swgfx.c | |||
| @@ -272,8 +272,6 @@ void SetDepth(swgfx* gfx, const sgVec2i p, R depth) { | |||
| 272 | sgPixel Sample(const sgTexture_t* texture, sgVec2 uv) { | 272 | sgPixel Sample(const sgTexture_t* texture, sgVec2 uv) { |
| 273 | assert(texture); | 273 | assert(texture); |
| 274 | assert(texture->pixels); | 274 | assert(texture->pixels); |
| 275 | // TODO: (1/2, 1/2) is the center of the pixel. Do we need to do something | ||
| 276 | // about it here? | ||
| 277 | #define INDEX(X,Y) texture->pixels[(Y) * texture->width + (X)] | 275 | #define INDEX(X,Y) texture->pixels[(Y) * texture->width + (X)] |
| 278 | // Doing a nearest sample for now. TODO: Other sampling strategies. | 276 | // Doing a nearest sample for now. TODO: Other sampling strategies. |
| 279 | const int x = (int)(uv.x * (R)texture->width); | 277 | const int x = (int)(uv.x * (R)texture->width); |
