moved textures into their own classes, better tilemapping
This commit is contained in:
@@ -5,8 +5,8 @@
|
||||
#include "../datatypes.cpp"
|
||||
#include "../helpers.cpp"
|
||||
#include "../buffer.cpp"
|
||||
#include "../shaders/shaders.h"
|
||||
#include "../mappers/mappers.h"
|
||||
#include "../textures/textures.h"
|
||||
|
||||
namespace UwU {
|
||||
// rectangle
|
||||
@@ -25,13 +25,13 @@ namespace UwU {
|
||||
uint16_t y1;
|
||||
|
||||
// Draw a rectangle
|
||||
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) {
|
||||
if (x0 > buffer.width || y0 > buffer.height || x1 > buffer.width || y1 > buffer.height) {return;};
|
||||
for (uint16_t y = y0; y <= y1; y++) {
|
||||
for (uint16_t x = x0; x <= x1; x++) {
|
||||
Coord2 uv = mapper.map(x0, y0, x, y);
|
||||
buffer.drawPixel(x, y, shader.shade(uv.x, uv.y));
|
||||
buffer.drawPixel(x, y, texture.texel(uv.x, uv.y));
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user