moved textures into their own classes, better tilemapping
This commit is contained in:
@@ -6,8 +6,8 @@
|
||||
#include "../datatypes.cpp"
|
||||
#include "../helpers.cpp"
|
||||
#include "../buffer.cpp"
|
||||
#include "../shaders/shaders.h"
|
||||
#include "../mappers/mappers.h"
|
||||
#include "../textures/textures.h"
|
||||
|
||||
namespace UwU {
|
||||
// trapezoid (horizontally constrained)
|
||||
@@ -31,8 +31,8 @@ namespace UwU {
|
||||
|
||||
// Draw a horizontally bounded trapezoid
|
||||
// y1 >= y0
|
||||
template <class MapperT, class ShaderT>
|
||||
void draw (Buffer buffer, MapperBase<MapperT>& mapper, ShaderBase<ShaderT>& shader) {
|
||||
template <class MapperT, class TextureT>
|
||||
void draw (Buffer buffer, MapperBase<MapperT>& mapper, TextureBase<TextureT>& texture) {
|
||||
uint16_t height = 1 + y1 - y0;
|
||||
int16_t LeftBound[height];
|
||||
int16_t RightBound[height];
|
||||
@@ -45,7 +45,7 @@ namespace UwU {
|
||||
for (uint16_t i = 0; i < height; i++) {
|
||||
for (uint16_t x = LeftBound[i]; x <= RightBound[i]; x++) {
|
||||
Coord2 uv = mapper.map(x0, y0, x, i + y0);
|
||||
buffer.drawPixel(x, i + y0, shader.shade(uv.x, uv.y));
|
||||
buffer.drawPixel(x, i + y0, texture.texel(uv.x, uv.y));
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user