Use named casts in openrct2-ui/drawing

This commit is contained in:
Tulio Leao 2020-03-28 15:59:50 -03:00
parent 57886ad0c7
commit abfd41c35f
13 changed files with 96 additions and 71 deletions

View file

@ -24,7 +24,7 @@ static std::vector<uint8_t> ReadToVector(std::istream& stream)
auto size = stream.tellg();
result.resize(size);
stream.seekg(0, std::ios_base::beg);
stream.read((char*)result.data(), size);
stream.read(reinterpret_cast<char*>(result.data()), size);
}
return result;
}
@ -34,7 +34,7 @@ static std::vector<uint8_t> ReadToVector(std::istream& stream)
static Image ReadBitmap(std::istream& istream, IMAGE_FORMAT format)
{
auto buffer = ReadToVector(istream);
auto sdlStream = SDL_RWFromConstMem(buffer.data(), (int)buffer.size());
auto sdlStream = SDL_RWFromConstMem(buffer.data(), static_cast<int>(buffer.size()));
auto bitmap = SDL_LoadBMP_RW(sdlStream, 1);
if (bitmap != nullptr)
{
@ -59,7 +59,7 @@ static Image ReadBitmap(std::istream& istream, IMAGE_FORMAT format)
std::fill(image.Pixels.begin(), image.Pixels.end(), 0xFF);
// Copy pixels over
auto src = (const uint8_t*)bitmap->pixels;
auto src = static_cast<const uint8_t*>(bitmap->pixels);
auto dst = image.Pixels.data();
if (numChannels == 4)
{

View file

@ -33,7 +33,7 @@ namespace OpenRCT2
std::unique_ptr<IDrawingEngine> Create(
DRAWING_ENGINE_TYPE type, const std::shared_ptr<IUiContext>& uiContext) override
{
switch ((int32_t)type)
switch (static_cast<int32_t>(type))
{
case DRAWING_ENGINE_SOFTWARE:
return CreateSoftwareDrawingEngine(uiContext);

View file

@ -57,7 +57,7 @@ public:
: X8DrawingEngine(uiContext)
, _uiContext(uiContext)
{
_window = (SDL_Window*)_uiContext->GetWindow();
_window = static_cast<SDL_Window*>(_uiContext->GetWindow());
}
~HardwareDisplayDrawingEngine() override
@ -221,7 +221,8 @@ private:
else
#endif
{
CopyBitsToTexture(_screenTexture, _bits, (int32_t)_width, (int32_t)_height, _paletteHWMapped);
CopyBitsToTexture(
_screenTexture, _bits, static_cast<int32_t>(_width), static_cast<int32_t>(_height), _paletteHWMapped);
}
if (smoothNN)
{
@ -279,11 +280,11 @@ private:
{
for (int32_t x = width; x > 0; x--)
{
const uint8_t lower = *(uint8_t*)(&palette[*src++]);
const uint8_t upper = *(uint8_t*)(&palette[*src++]);
const uint8_t lower = *reinterpret_cast<const uint8_t*>(&palette[*src++]);
const uint8_t upper = *reinterpret_cast<const uint8_t*>(&palette[*src++]);
*dst++ = (lower << 8) | upper;
}
dst = (uint16_t*)(((uint8_t*)dst) + padding);
dst = reinterpret_cast<uint16_t*>(reinterpret_cast<uint8_t*>(dst) + padding);
}
}
else if (pitch == width + padding)
@ -293,7 +294,7 @@ private:
{
for (int32_t x = width; x > 0; x--)
{
*dst++ = *(uint8_t*)(&palette[*src++]);
*dst++ = *reinterpret_cast<const uint8_t*>(&palette[*src++]);
}
dst += padding;
}
@ -352,13 +353,13 @@ private:
auto timeLeft = GetDirtyVisualTime(x, y);
if (timeLeft > 0)
{
uint8_t alpha = (uint8_t)(timeLeft * 5 / 2);
uint8_t alpha = static_cast<uint8_t>(timeLeft * 5 / 2);
SDL_Rect ddRect;
ddRect.x = (int32_t)(x * _dirtyGrid.BlockWidth * scaleX);
ddRect.y = (int32_t)(y * _dirtyGrid.BlockHeight * scaleY);
ddRect.w = (int32_t)(_dirtyGrid.BlockWidth * scaleX);
ddRect.h = (int32_t)(_dirtyGrid.BlockHeight * scaleY);
ddRect.x = static_cast<int32_t>(x * _dirtyGrid.BlockWidth * scaleX);
ddRect.y = static_cast<int32_t>(y * _dirtyGrid.BlockHeight * scaleY);
ddRect.w = static_cast<int32_t>(_dirtyGrid.BlockWidth * scaleX);
ddRect.h = static_cast<int32_t>(_dirtyGrid.BlockHeight * scaleY);
SDL_SetRenderDrawColor(_sdlRenderer, 255, 255, 255, alpha);
SDL_RenderFillRect(_sdlRenderer, &ddRect);
@ -369,7 +370,7 @@ private:
void ReadCentrePixel(uint32_t* pixel)
{
SDL_Rect centrePixelRegion = { (int32_t)(_width / 2), (int32_t)(_height / 2), 1, 1 };
SDL_Rect centrePixelRegion = { static_cast<int32_t>(_width / 2), static_cast<int32_t>(_height / 2), 1, 1 };
SDL_RenderReadPixels(_sdlRenderer, &centrePixelRegion, SDL_PIXELFORMAT_RGBA8888, pixel, sizeof(uint32_t));
}

View file

@ -37,7 +37,7 @@ public:
: X8DrawingEngine(uiContext)
, _uiContext(uiContext)
{
_window = (SDL_Window*)_uiContext->GetWindow();
_window = static_cast<SDL_Window*>(_uiContext->GetWindow());
}
~SoftwareDrawingEngine() override
@ -113,7 +113,7 @@ private:
}
// Copy pixels from the virtual screen buffer to the surface
std::copy_n(_bits, _surface->pitch * _surface->h, (uint8_t*)_surface->pixels);
std::copy_n(_bits, _surface->pitch * _surface->h, static_cast<uint8_t*>(_surface->pixels));
// Unlock the surface
if (SDL_MUSTLOCK(_surface))

View file

@ -39,9 +39,11 @@ ApplyPaletteShader::ApplyPaletteShader()
glBufferData(GL_ARRAY_BUFFER, sizeof(VertexData), VertexData, GL_STATIC_DRAW);
glBindVertexArray(_vao);
glVertexAttribPointer(vPosition, 2, GL_FLOAT, GL_FALSE, sizeof(VDStruct), (void*)offsetof(VDStruct, position));
glVertexAttribPointer(
vTextureCoordinate, 2, GL_FLOAT, GL_FALSE, sizeof(VDStruct), (void*)offsetof(VDStruct, texturecoordinate));
vPosition, 2, GL_FLOAT, GL_FALSE, sizeof(VDStruct), reinterpret_cast<void*>(offsetof(VDStruct, position)));
glVertexAttribPointer(
vTextureCoordinate, 2, GL_FLOAT, GL_FALSE, sizeof(VDStruct),
reinterpret_cast<void*>(offsetof(VDStruct, texturecoordinate)));
glEnableVertexAttribArray(vPosition);
glEnableVertexAttribArray(vTextureCoordinate);
@ -72,7 +74,7 @@ void ApplyPaletteShader::SetTexture(GLuint texture)
void ApplyPaletteShader::SetPalette(const vec4* glPalette)
{
glUniform4fv(uPalette, 256, (const GLfloat*)glPalette);
glUniform4fv(uPalette, 256, reinterpret_cast<const GLfloat*>(glPalette));
}
void ApplyPaletteShader::Draw()

View file

@ -39,9 +39,11 @@ ApplyTransparencyShader::ApplyTransparencyShader()
glBufferData(GL_ARRAY_BUFFER, sizeof(VertexData), VertexData, GL_STATIC_DRAW);
glBindVertexArray(_vao);
glVertexAttribPointer(vPosition, 2, GL_FLOAT, GL_FALSE, sizeof(VDStruct), (void*)offsetof(VDStruct, position));
glVertexAttribPointer(
vTextureCoordinate, 2, GL_FLOAT, GL_FALSE, sizeof(VDStruct), (void*)offsetof(VDStruct, texturecoordinate));
vPosition, 2, GL_FLOAT, GL_FALSE, sizeof(VDStruct), reinterpret_cast<void*>(offsetof(VDStruct, position)));
glVertexAttribPointer(
vTextureCoordinate, 2, GL_FLOAT, GL_FALSE, sizeof(VDStruct),
reinterpret_cast<void*>(offsetof(VDStruct, texturecoordinate)));
glEnableVertexAttribArray(vPosition);
glEnableVertexAttribArray(vTextureCoordinate);

View file

@ -39,16 +39,23 @@ DrawLineShader::DrawLineShader()
glBufferData(GL_ARRAY_BUFFER, sizeof(VertexData), VertexData, GL_STATIC_DRAW);
glBindVertexArray(_vao);
glVertexAttribPointer(vVertMat + 0, 2, GL_FLOAT, GL_FALSE, sizeof(VDStruct), (void*)offsetof(VDStruct, mat[0]));
glVertexAttribPointer(vVertMat + 1, 2, GL_FLOAT, GL_FALSE, sizeof(VDStruct), (void*)offsetof(VDStruct, mat[1]));
glVertexAttribPointer(vVertMat + 2, 2, GL_FLOAT, GL_FALSE, sizeof(VDStruct), (void*)offsetof(VDStruct, mat[2]));
glVertexAttribPointer(vVertMat + 3, 2, GL_FLOAT, GL_FALSE, sizeof(VDStruct), (void*)offsetof(VDStruct, mat[3]));
glVertexAttribPointer(
vVertMat + 0, 2, GL_FLOAT, GL_FALSE, sizeof(VDStruct), reinterpret_cast<void*>(offsetof(VDStruct, mat[0])));
glVertexAttribPointer(
vVertMat + 1, 2, GL_FLOAT, GL_FALSE, sizeof(VDStruct), reinterpret_cast<void*>(offsetof(VDStruct, mat[1])));
glVertexAttribPointer(
vVertMat + 2, 2, GL_FLOAT, GL_FALSE, sizeof(VDStruct), reinterpret_cast<void*>(offsetof(VDStruct, mat[2])));
glVertexAttribPointer(
vVertMat + 3, 2, GL_FLOAT, GL_FALSE, sizeof(VDStruct), reinterpret_cast<void*>(offsetof(VDStruct, mat[3])));
glBindBuffer(GL_ARRAY_BUFFER, _vboInstances);
glVertexAttribIPointer(vClip, 4, GL_INT, sizeof(DrawLineCommand), (void*)offsetof(DrawLineCommand, clip));
glVertexAttribIPointer(vBounds, 4, GL_INT, sizeof(DrawLineCommand), (void*)offsetof(DrawLineCommand, bounds));
glVertexAttribIPointer(vColour, 1, GL_UNSIGNED_INT, sizeof(DrawLineCommand), (void*)offsetof(DrawLineCommand, colour));
glVertexAttribIPointer(vDepth, 1, GL_INT, sizeof(DrawLineCommand), (void*)offsetof(DrawLineCommand, depth));
glVertexAttribIPointer(vClip, 4, GL_INT, sizeof(DrawLineCommand), reinterpret_cast<void*>(offsetof(DrawLineCommand, clip)));
glVertexAttribIPointer(
vBounds, 4, GL_INT, sizeof(DrawLineCommand), reinterpret_cast<void*>(offsetof(DrawLineCommand, bounds)));
glVertexAttribIPointer(
vColour, 1, GL_UNSIGNED_INT, sizeof(DrawLineCommand), reinterpret_cast<void*>(offsetof(DrawLineCommand, colour)));
glVertexAttribIPointer(
vDepth, 1, GL_INT, sizeof(DrawLineCommand), reinterpret_cast<void*>(offsetof(DrawLineCommand, depth)));
glEnableVertexAttribArray(vVertMat + 0);
glEnableVertexAttribArray(vVertMat + 1);
@ -98,7 +105,7 @@ void DrawLineShader::DrawInstances(const LineCommandBatch& instances)
glBindBuffer(GL_ARRAY_BUFFER, _vboInstances);
glBufferData(GL_ARRAY_BUFFER, sizeof(DrawLineCommand) * instances.size(), instances.data(), GL_STREAM_DRAW);
glDrawArraysInstanced(GL_LINES, 0, 2, (GLsizei)instances.size());
glDrawArraysInstanced(GL_LINES, 0, 2, static_cast<GLsizei>(instances.size()));
}
#endif /* DISABLE_OPENGL */

View file

@ -41,26 +41,39 @@ DrawRectShader::DrawRectShader()
glBindVertexArray(_vao);
glVertexAttribPointer(vVertMat + 0, 2, GL_FLOAT, GL_FALSE, sizeof(VDStruct), (void*)offsetof(VDStruct, mat[0]));
glVertexAttribPointer(vVertMat + 1, 2, GL_FLOAT, GL_FALSE, sizeof(VDStruct), (void*)offsetof(VDStruct, mat[1]));
glVertexAttribPointer(vVertMat + 2, 2, GL_FLOAT, GL_FALSE, sizeof(VDStruct), (void*)offsetof(VDStruct, mat[2]));
glVertexAttribPointer(vVertMat + 3, 2, GL_FLOAT, GL_FALSE, sizeof(VDStruct), (void*)offsetof(VDStruct, mat[3]));
glVertexAttribPointer(vVertVec, 2, GL_FLOAT, GL_FALSE, sizeof(VDStruct), (void*)offsetof(VDStruct, vec));
glVertexAttribPointer(
vVertMat + 0, 2, GL_FLOAT, GL_FALSE, sizeof(VDStruct), reinterpret_cast<void*>(offsetof(VDStruct, mat[0])));
glVertexAttribPointer(
vVertMat + 1, 2, GL_FLOAT, GL_FALSE, sizeof(VDStruct), reinterpret_cast<void*>(offsetof(VDStruct, mat[1])));
glVertexAttribPointer(
vVertMat + 2, 2, GL_FLOAT, GL_FALSE, sizeof(VDStruct), reinterpret_cast<void*>(offsetof(VDStruct, mat[2])));
glVertexAttribPointer(
vVertMat + 3, 2, GL_FLOAT, GL_FALSE, sizeof(VDStruct), reinterpret_cast<void*>(offsetof(VDStruct, mat[3])));
glVertexAttribPointer(vVertVec, 2, GL_FLOAT, GL_FALSE, sizeof(VDStruct), reinterpret_cast<void*>(offsetof(VDStruct, vec)));
glBindBuffer(GL_ARRAY_BUFFER, _vboInstances);
glVertexAttribIPointer(vClip, 4, GL_INT, sizeof(DrawRectCommand), (void*)offsetof(DrawRectCommand, clip));
glVertexAttribIPointer(vClip, 4, GL_INT, sizeof(DrawRectCommand), reinterpret_cast<void*>(offsetof(DrawRectCommand, clip)));
glVertexAttribIPointer(
vTexColourAtlas, 1, GL_INT, sizeof(DrawRectCommand), (void*)offsetof(DrawRectCommand, texColourAtlas));
vTexColourAtlas, 1, GL_INT, sizeof(DrawRectCommand),
reinterpret_cast<void*>(offsetof(DrawRectCommand, texColourAtlas)));
glVertexAttribPointer(
vTexColourBounds, 4, GL_FLOAT, GL_FALSE, sizeof(DrawRectCommand), (void*)offsetof(DrawRectCommand, texColourBounds));
glVertexAttribIPointer(vTexMaskAtlas, 1, GL_INT, sizeof(DrawRectCommand), (void*)offsetof(DrawRectCommand, texMaskAtlas));
vTexColourBounds, 4, GL_FLOAT, GL_FALSE, sizeof(DrawRectCommand),
reinterpret_cast<void*>(offsetof(DrawRectCommand, texColourBounds)));
glVertexAttribIPointer(
vTexMaskAtlas, 1, GL_INT, sizeof(DrawRectCommand), reinterpret_cast<void*>(offsetof(DrawRectCommand, texMaskAtlas)));
glVertexAttribPointer(
vTexMaskBounds, 4, GL_FLOAT, GL_FALSE, sizeof(DrawRectCommand), (void*)offsetof(DrawRectCommand, texMaskBounds));
glVertexAttribIPointer(vPalettes, 3, GL_INT, sizeof(DrawRectCommand), (void*)offsetof(DrawRectCommand, palettes));
glVertexAttribIPointer(vFlags, 1, GL_INT, sizeof(DrawRectCommand), (void*)offsetof(DrawRectCommand, flags));
glVertexAttribIPointer(vColour, 1, GL_UNSIGNED_INT, sizeof(DrawRectCommand), (void*)offsetof(DrawRectCommand, colour));
glVertexAttribIPointer(vBounds, 4, GL_INT, sizeof(DrawRectCommand), (void*)offsetof(DrawRectCommand, bounds));
glVertexAttribIPointer(vDepth, 1, GL_INT, sizeof(DrawRectCommand), (void*)offsetof(DrawRectCommand, depth));
vTexMaskBounds, 4, GL_FLOAT, GL_FALSE, sizeof(DrawRectCommand),
reinterpret_cast<void*>(offsetof(DrawRectCommand, texMaskBounds)));
glVertexAttribIPointer(
vPalettes, 3, GL_INT, sizeof(DrawRectCommand), reinterpret_cast<void*>(offsetof(DrawRectCommand, palettes)));
glVertexAttribIPointer(
vFlags, 1, GL_INT, sizeof(DrawRectCommand), reinterpret_cast<void*>(offsetof(DrawRectCommand, flags)));
glVertexAttribIPointer(
vColour, 1, GL_UNSIGNED_INT, sizeof(DrawRectCommand), reinterpret_cast<void*>(offsetof(DrawRectCommand, colour)));
glVertexAttribIPointer(
vBounds, 4, GL_INT, sizeof(DrawRectCommand), reinterpret_cast<void*>(offsetof(DrawRectCommand, bounds)));
glVertexAttribIPointer(
vDepth, 1, GL_INT, sizeof(DrawRectCommand), reinterpret_cast<void*>(offsetof(DrawRectCommand, depth)));
glEnableVertexAttribArray(vVertMat + 0);
glEnableVertexAttribArray(vVertMat + 1);
@ -152,7 +165,7 @@ void DrawRectShader::SetInstances(const RectCommandBatch& instances)
glBindBuffer(GL_ARRAY_BUFFER, _vboInstances);
glBufferData(GL_ARRAY_BUFFER, sizeof(DrawRectCommand) * instances.size(), instances.data(), GL_STREAM_DRAW);
_instanceCount = (GLsizei)instances.size();
_instanceCount = static_cast<GLsizei>(instances.size());
}
void DrawRectShader::DrawInstances()

View file

@ -153,7 +153,7 @@ public:
uint32_t finalPixelOffset = width + pixelOffset;
uint32_t xPixelOffset = pixelOffset;
xPixelOffset += ((uint8_t)(patternX - patternStartXOffset)) % patternXSpace;
xPixelOffset += (static_cast<uint8_t>(patternX - patternStartXOffset)) % patternXSpace;
uint8_t patternPixel = pattern[patternYPos * 2 + 1];
for (; xPixelOffset < finalPixelOffset; xPixelOffset += patternXSpace)
@ -204,7 +204,7 @@ public:
, _drawingContext(new OpenGLDrawingContext(this))
, _rainDrawer(_drawingContext)
{
_window = (SDL_Window*)_uiContext->GetWindow();
_window = static_cast<SDL_Window*>(_uiContext->GetWindow());
_bitsDPI.DrawingEngine = this;
# ifdef __ENABLE_LIGHTFX__
lightfx_set_available(false);
@ -839,8 +839,8 @@ void OpenGLDrawingContext::DrawSpriteSolid(uint32_t image, int32_t x, int32_t y,
int32_t drawOffsetX = g1Element->x_offset;
int32_t drawOffsetY = g1Element->y_offset;
int32_t drawWidth = (uint16_t)g1Element->width;
int32_t drawHeight = (uint16_t)g1Element->height;
int32_t drawWidth = static_cast<uint16_t>(g1Element->width);
int32_t drawHeight = static_cast<uint16_t>(g1Element->height);
int32_t left = x + drawOffsetX;
int32_t top = y + drawOffsetY;
@ -887,8 +887,8 @@ void OpenGLDrawingContext::DrawGlyph(uint32_t image, int32_t x, int32_t y, uint8
int32_t drawOffsetX = g1Element->x_offset;
int32_t drawOffsetY = g1Element->y_offset;
int32_t drawWidth = (uint16_t)g1Element->width;
int32_t drawHeight = (uint16_t)g1Element->height;
int32_t drawWidth = static_cast<uint16_t>(g1Element->width);
int32_t drawHeight = static_cast<uint16_t>(g1Element->height);
int32_t left = x + drawOffsetX;
int32_t top = y + drawOffsetY;
@ -1003,14 +1003,14 @@ void OpenGLDrawingContext::SetDPI(rct_drawpixelinfo* dpi)
{
rct_drawpixelinfo* screenDPI = _engine->GetDPI();
# ifndef NDEBUG
size_t bitsSize = (size_t)screenDPI->height * (size_t)(screenDPI->width + screenDPI->pitch);
size_t bitsSize = static_cast<size_t>(screenDPI->height) * static_cast<size_t>(screenDPI->width + screenDPI->pitch);
# endif
size_t bitsOffset = (size_t)(dpi->bits - screenDPI->bits);
size_t bitsOffset = static_cast<size_t>(dpi->bits - screenDPI->bits);
assert(bitsOffset < bitsSize);
_clipLeft = (int32_t)(bitsOffset % (screenDPI->width + screenDPI->pitch));
_clipTop = (int32_t)(bitsOffset / (screenDPI->width + screenDPI->pitch));
_clipLeft = static_cast<int32_t>(bitsOffset % (screenDPI->width + screenDPI->pitch));
_clipTop = static_cast<int32_t>(bitsOffset / (screenDPI->width + screenDPI->pitch));
_clipRight = _clipLeft + (dpi->width / dpi->zoom_level);
_clipBottom = _clipTop + (dpi->height / dpi->zoom_level);
_offsetX = _clipLeft - dpi->x;

View file

@ -72,7 +72,7 @@ OpenGLFramebuffer::~OpenGLFramebuffer()
void OpenGLFramebuffer::Bind() const
{
glBindFramebuffer(GL_FRAMEBUFFER, _id);
glViewport(0, 0, (GLsizei)_width, (GLsizei)_height);
glViewport(0, 0, static_cast<GLsizei>(_width), static_cast<GLsizei>(_height));
}
void OpenGLFramebuffer::BindDraw() const

View file

@ -29,7 +29,7 @@ OpenGLShader::OpenGLShader(const char* name, GLenum type)
auto sourceCodeStr = sourceCode.c_str();
_id = glCreateShader(type);
glShaderSource(_id, 1, (const GLchar**)&sourceCodeStr, nullptr);
glShaderSource(_id, 1, static_cast<const GLchar**>(&sourceCodeStr), nullptr);
glCompileShader(_id);
GLint status;
@ -84,7 +84,7 @@ std::string OpenGLShader::ReadSourceCode(const std::string& path)
}
auto fileData = std::string((size_t)fileLength + 1, '\0');
fs.Read((void*)fileData.data(), fileLength);
fs.Read(static_cast<void*>(fileData.data()), fileLength);
return fileData;
}

View file

@ -86,7 +86,7 @@ BasicTextureInfo TextureCache::GetOrLoadImageTexture(uint32_t image)
// Load new texture.
unique_lock lock(_mutex);
index = (uint32_t)_textureCache.size();
index = static_cast<uint32_t>(_textureCache.size());
AtlasTextureInfo info = LoadImageTexture(image);
@ -105,7 +105,7 @@ BasicTextureInfo TextureCache::GetOrLoadGlyphTexture(uint32_t image, uint8_t* pa
{
shared_lock lock(_mutex);
std::copy_n(palette, sizeof(glyphId.Palette), (uint8_t*)&glyphId.Palette);
std::copy_n(palette, sizeof(glyphId.Palette), reinterpret_cast<uint8_t*>(&glyphId.Palette));
auto kvp = _glyphTextureMap.find(glyphId);
if (kvp != _glyphTextureMap.end())
@ -271,7 +271,7 @@ AtlasTextureInfo TextureCache::AllocateImage(int32_t imageWidth, int32_t imageHe
}
// If there is no such atlas, then create a new one
if ((int32_t)_atlases.size() >= _atlasesTextureIndicesLimit)
if (static_cast<int32_t>(_atlases.size()) >= _atlasesTextureIndicesLimit)
{
throw std::runtime_error("more texture atlases required, but device limit reached!");
}

View file

@ -105,7 +105,7 @@ public:
_freeSlots.resize(_cols * _rows);
for (size_t i = 0; i < _freeSlots.size(); i++)
{
_freeSlots[i] = (GLuint)i;
_freeSlots[i] = static_cast<GLuint>(i);
}
}
@ -146,7 +146,7 @@ public:
[[nodiscard]] int32_t GetFreeSlots() const
{
return (int32_t)_freeSlots.size();
return static_cast<int32_t>(_freeSlots.size());
}
static int32_t CalculateImageSizeOrder(int32_t actualWidth, int32_t actualHeight)
@ -158,7 +158,7 @@ public:
actualSize = TEXTURE_CACHE_SMALLEST_SLOT;
}
return (int32_t)ceil(log2f((float)actualSize));
return static_cast<int32_t>(ceil(log2f(static_cast<float>(actualSize))));
}
private:
@ -178,10 +178,10 @@ private:
[[nodiscard]] vec4 NormalizeCoordinates(const ivec4& coords) const
{
return vec4{
coords.x / (float)_atlasWidth,
coords.y / (float)_atlasHeight,
coords.z / (float)_atlasWidth,
coords.w / (float)_atlasHeight,
coords.x / static_cast<float>(_atlasWidth),
coords.y / static_cast<float>(_atlasHeight),
coords.z / static_cast<float>(_atlasWidth),
coords.w / static_cast<float>(_atlasHeight),
};
}
};