20 #include "../context.h"
21 #include "../gpu/pipeline.h"
24 #include "../gpu/bgl.h"
25 #include "../exception.h"
26 #include "../gpu/swapper.h"
27 #include "../utils/bmp_file.h"
34 "single byte",
"triple byte",
"quad byte",
35 "single floating point",
"triple floating point",
"quad floating point",
36 "binary mask",
"quaternary mask",
"hexadecimal mask"
58 TextureHandler::prepare(gpu);
66 #ifdef BEATMUP_OPENGLVERSION_GLES20
68 glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, textureWidth,
getHeight(), 0, GL_ALPHA, GL_UNSIGNED_BYTE,
nullptr);
71 glTexStorage2D(GL_TEXTURE_2D, 1, GL_R8, textureWidth,
getHeight());
74 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
75 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
79 #ifdef BEATMUP_OPENGLVERSION_GLES20
81 glTexImage2D(GL_TEXTURE_2D,
101 return TextureFormat::Rx8;
129 return (
int)(*((
float*)
p) * 255);
176 desc +=
" stored on CPU+GPU";
179 desc +=
" stored on CPU";
182 desc +=
" stored on GPU";
237 DebugAssertion::check(!
bitmap.
isDirty(),
"Reading a dirty bitmap");
ReadLock(AbstractBitmap &bitmap)
A very basic class for any image.
virtual const TextureFormat getTextureFormat() const
Returns the texture format specifying how the shader must interpret the data.
static const unsigned char BITS_PER_PIXEL[NUM_PIXEL_FORMATS]
number of bits per pixel for each pixel format
const unsigned char getNumberOfChannels() const
Returns number of bytes per pixel stored in each bitmap.
Context & ctx
context managing this bitmap
Context & getContext() const
virtual const PixelFormat getPixelFormat() const =0
Pixel format of the bitmap.
bool isDirty() const
Returns true if the bitmap does not contain any valid content.
static const char * PIXEL_FORMAT_NAMES[NUM_PIXEL_FORMATS]
pixel format names
bool isInteger() const
Returns true if the bitmap contains integer values, false otherwise.
int getPixelInt(int x, int y, int cha=0) const
Retrieves integer value of given channel at given pixel.
std::string toString() const
Retruns a string describing the bitmap.
virtual void prepare(GraphicPipeline &gpu)
Prepares (eventually uploads) texture data on GPU.
const unsigned char getBitsPerPixel() const
Returns number of bits per pixel stored in each bitmap.
bool isMask() const
Returns true if the bitmap is a mask, false otherwise.
bool isFloat() const
Returns true if the bitmap contains floating point values, false otherwise.
virtual const pixbyte * getData(int x, int y) const =0
Returns a pointer to given pixel.
AbstractBitmap(const AbstractBitmap &that)=delete
disabling copying constructor
bool isUpToDate(ProcessingTarget) const
void saveBmp(const char *filename)
Saves the bitmap to a BMP file.
virtual void lockPixelData()=0
Locks access to the CPU memory buffer containing pixel data.
virtual const msize getMemorySize() const =0
Bitmap size in bytes.
virtual void unlockPixelData()=0
Unlocks access to the CPU memory buffer containing pixel data.
static const unsigned char CHANNELS_PER_PIXEL[NUM_PIXEL_FORMATS]
number of channels for each pixel format
void zero()
Sets all the pixels to zero.
bool upToDate[2]
bitmap up-to-date state on CPU and GPU
static void save(const void *pixels, int32_t width, int32_t height, uint8_t bpp, const char *filename)
Stores an image into a BMP file.
Basic class: task and memory management, any kind of static data.
GL::RecycleBin * getGpuRecycleBin() const
static void check(const std::string &info)
bool hasValidHandle() const
Returns true if the texture handle points to a valid texture.
virtual const int getHeight() const =0
Height of the texture in pixels.
TextureFormat
Texture format, specifies how the texture should be interpreted on the shader side.
virtual const int getWidth() const =0
Width of the texture in pixels.
Internal low-level GPU control API.
void unlockPixelData()
Unlocks access to the CPU memory buffer containing pixel data.
static void pullPixels(AbstractBitmap &bitmap)
Copies bitmap from GPU memory to RAM.
const GLuint BITMAP_INTERNALFORMATS[]
const GLuint BITMAP_PIXELTYPES[]
Mapping of bitmap pixel formats to GL pixel types.
const GLuint BITMAP_PIXELFORMATS[]
Mapping of bitmap pixel formats to GL pixel formats.
@ SingleByte
single channel of 8 bits per pixel (like grayscale), unsigned integer values
@ SingleFloat
single channel of 32 bits per pixel (like grayscale), single precision floating point values
@ QuaternaryMask
2 bits per pixel
@ QuadFloat
4 channels of 32 bits per pixel, single precision floating point values,
@ TripleFloat
3 channels of 32 bits per pixel, single precision floating point values
@ QuadByte
4 channels of 8 bits per pixel (like RGBA), unsigned integer values
@ TripleByte
3 channels of 8 bits per pixel (like RGB), unsigned integer values
@ BinaryMask
1 bit per pixel
@ HexMask
4 bits per pixel
std::string to_string(Beatmup::NNets::ActivationFunction function)
jlong jint jint jint jint pixelFormat
jobject jlong jint jint y
JNIEnv jlong jstring filename
Beatmup::InternalBitmap * bitmap
Beatmup::IntPoint p((int) x,(int) y)