117 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			117 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| // Copyright (c) 2023 Dominic Masters
 | |
| // 
 | |
| // This software is released under the MIT License.
 | |
| // https://opensource.org/licenses/MIT
 | |
| 
 | |
| #pragma once
 | |
| #include "display/Color.hpp"
 | |
| 
 | |
| namespace Dawn {
 | |
|   enum class TextureFormat {
 | |
|     R = 1,
 | |
|     RG = 2,
 | |
|     RGB = 3,
 | |
|     RGBA = 4
 | |
|   };
 | |
| 
 | |
|   enum class TextureWrapMode {
 | |
|     REPEAT = 0,
 | |
|     MIRRORED_REPEAT = 1,
 | |
|     CLAMP_TO_EDGE = 2,
 | |
|     CLAMP_TO_BORDER = 3
 | |
|   };
 | |
| 
 | |
|   enum class TextureFilterMode {
 | |
|     NEAREST = 0,
 | |
|     LINEAR = 1
 | |
|   };
 | |
| 
 | |
|   enum class TextureDataFormat {
 | |
|     UNSIGNED_BYTE = 0,
 | |
|     FLOAT = 1
 | |
|   };
 | |
| 
 | |
|   class ITexture {
 | |
|     public:
 | |
|       enum TextureWrapMode wrapModeX = TextureWrapMode::REPEAT;
 | |
|       enum TextureWrapMode wrapModeY = TextureWrapMode::REPEAT;
 | |
|       enum TextureFilterMode filterModeMin = TextureFilterMode::NEAREST;
 | |
|       enum TextureFilterMode filterModeMag = TextureFilterMode::NEAREST;
 | |
|       enum TextureFilterMode mipMapFilterModeMin = TextureFilterMode::NEAREST;
 | |
|       enum TextureFilterMode mipMapFilterModeMag = TextureFilterMode::NEAREST;
 | |
| 
 | |
|       /**
 | |
|        * Returns the width of the texture.
 | |
|        * 
 | |
|        * @return Width of the texture.
 | |
|        */
 | |
|       virtual int32_t getWidth() = 0;
 | |
| 
 | |
|       /**
 | |
|        * Returns the height of the texture.
 | |
|        * 
 | |
|        * @return Height of the texture.
 | |
|        */
 | |
|       virtual int32_t getHeight() = 0;
 | |
| 
 | |
|       /**
 | |
|        * Initializes a texture.
 | |
|        * 
 | |
|        * @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.
 | |
|        * @param dataFormat Data format of the texture to use.
 | |
|        */
 | |
|       virtual void setSize(
 | |
|         const int32_t width,
 | |
|         const int32_t height,
 | |
|         const enum TextureFormat format,
 | |
|         const enum TextureDataFormat dataFormat
 | |
|       ) = 0;
 | |
| 
 | |
|       /**
 | |
|        * Returns true only when the texture has been loaded, sized and put on
 | |
|        * the gpu for rendering.
 | |
|        * 
 | |
|        * @return True if ready, otherwise false.
 | |
|        */
 | |
|       // virtual bool_t isReady() = 0;
 | |
| 
 | |
|       /**
 | |
|        * Buffer pixel data onto the GPU. Pixel buffering is rather costly so
 | |
|        * avoid doing this too often.
 | |
|        * 
 | |
|        * @param pixels Array of pixels you're trying to buffer.
 | |
|        */
 | |
|       virtual void buffer(const struct ColorU8 pixels[]) = 0;
 | |
| 
 | |
|       /**
 | |
|        * Buffer pixel data onto the GPU. Pixel buffering is rather costly so
 | |
|        * avoid doing this too often.
 | |
|        * 
 | |
|        * @param pixels Array of pixels you're trying to buffer.
 | |
|        */
 | |
|       virtual void buffer(const struct Color pixels[]) = 0;
 | |
| 
 | |
|       /**
 | |
|        * Buffer pixel data onto the GPU. Pixel buffering is rather costly so
 | |
|        * avoid doing this too often.
 | |
|        * 
 | |
|        * @param pixels Array of pixels you're trying to buffer.
 | |
|        */
 | |
|       virtual void buffer(const uint8_t pixels[]) = 0;
 | |
| 
 | |
|       /**
 | |
|        * Binds the texture to the given slot (for use by the shaders).
 | |
|        * 
 | |
|        * @param slot Slot to bind to.
 | |
|        */
 | |
|       virtual void bind(const uint8_t slot) = 0;
 | |
| 
 | |
|       /**
 | |
|        * Disposes of the texture.
 | |
|        */
 | |
|       virtual ~ITexture() {
 | |
|       }
 | |
|   };
 | |
| } |