Prepping to allow textures to have different render modes/types. Prepping for freetype support

This commit is contained in:
2023-05-21 23:35:39 -07:00
parent bb0eb2d7fa
commit 4a0c817a1c
17 changed files with 344 additions and 48 deletions

View File

@ -5,10 +5,46 @@
#pragma once
#include "display/Color.hpp"
#include "state/StateOwner.hpp"
namespace Dawn {
class ITexture {
enum TextureFormat {
TEXTURE_FORMAT_R = 1,
TEXTURE_FORMAT_RG = 2,
TEXTURE_FORMAT_RGB = 3,
TEXTURE_FORMAT_RGBA = 4
};
enum TextureWrapMode {
TEXTURE_WRAP_MODE_REPEAT = 0,
TEXTURE_WRAP_MODE_MIRRORED_REPEAT = 1,
TEXTURE_WRAP_MODE_CLAMP_TO_EDGE = 2,
TEXTURE_WRAP_MODE_CLAMP_TO_BORDER = 3
};
enum TextureFilterMode {
TEXTURE_FILTER_MODE_NEAREST = 0,
TEXTURE_FILTER_MODE_LINEAR = 1
};
class ITexture : public StateOwner {
protected:
bool_t texturePropertiesNeedUpdating = true;
public:
StateProperty<enum TextureWrapMode> wrapModeX;
StateProperty<enum TextureWrapMode> wrapModeY;
StateProperty<enum TextureFilterMode> filterModeMin;
StateProperty<enum TextureFilterMode> filterModeMag;
ITexture() :
wrapModeX(TEXTURE_WRAP_MODE_CLAMP_TO_EDGE),
wrapModeY(TEXTURE_WRAP_MODE_CLAMP_TO_EDGE),
filterModeMin(TEXTURE_FILTER_MODE_LINEAR),
filterModeMag(TEXTURE_FILTER_MODE_LINEAR)
{
}
/**
* Returns the width of the texture.
*
@ -28,8 +64,13 @@ namespace Dawn {
*
* @param width Width of the texture (in pixels).
* @param height Height of the texture (in pixels).
* @param format Data format of the texture to use.
*/
virtual void setSize(int32_t width, int32_t height) = 0;
virtual void setSize(
int32_t width,
int32_t height,
enum TextureFormat format
) = 0;
/**
* Fill a texture with a single color. This is stupidly costly.

View File

@ -99,6 +99,6 @@ void ExampleFont::init() {
pixels[j++] = this->getColor(n & 0x01);
}
this->realTexture.setSize(128, 64);
this->realTexture.setSize(128, 64, TEXTURE_FORMAT_RGBA);
this->realTexture.buffer(pixels);
}