mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
Backends: OSX, Metal: Fix -Wshadow, -Wimplicit-float-conversion, and -Wsign-conversion warnings. (#3555)
This commit is contained in:
parent
9cca1b2e97
commit
b934b9bb86
@ -234,8 +234,8 @@ void ImGui_ImplMetal_DestroyDeviceObjects()
|
|||||||
int width, height;
|
int width, height;
|
||||||
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
|
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
|
||||||
MTLTextureDescriptor *textureDescriptor = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA8Unorm
|
MTLTextureDescriptor *textureDescriptor = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA8Unorm
|
||||||
width:width
|
width:(NSUInteger)width
|
||||||
height:height
|
height:(NSUInteger)height
|
||||||
mipmapped:NO];
|
mipmapped:NO];
|
||||||
textureDescriptor.usage = MTLTextureUsageShaderRead;
|
textureDescriptor.usage = MTLTextureUsageShaderRead;
|
||||||
#if TARGET_OS_OSX
|
#if TARGET_OS_OSX
|
||||||
@ -244,7 +244,7 @@ void ImGui_ImplMetal_DestroyDeviceObjects()
|
|||||||
textureDescriptor.storageMode = MTLStorageModeShared;
|
textureDescriptor.storageMode = MTLStorageModeShared;
|
||||||
#endif
|
#endif
|
||||||
id <MTLTexture> texture = [device newTextureWithDescriptor:textureDescriptor];
|
id <MTLTexture> texture = [device newTextureWithDescriptor:textureDescriptor];
|
||||||
[texture replaceRegion:MTLRegionMake2D(0, 0, width, height) mipmapLevel:0 withBytes:pixels bytesPerRow:width * 4];
|
[texture replaceRegion:MTLRegionMake2D(0, 0, (NSUInteger)width, (NSUInteger)height) mipmapLevel:0 withBytes:pixels bytesPerRow:(NSUInteger)width * 4];
|
||||||
self.fontTexture = texture;
|
self.fontTexture = texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -435,8 +435,8 @@ void ImGui_ImplMetal_DestroyDeviceObjects()
|
|||||||
float R = drawData->DisplayPos.x + drawData->DisplaySize.x;
|
float R = drawData->DisplayPos.x + drawData->DisplaySize.x;
|
||||||
float T = drawData->DisplayPos.y;
|
float T = drawData->DisplayPos.y;
|
||||||
float B = drawData->DisplayPos.y + drawData->DisplaySize.y;
|
float B = drawData->DisplayPos.y + drawData->DisplaySize.y;
|
||||||
float N = viewport.znear;
|
float N = (float)viewport.znear;
|
||||||
float F = viewport.zfar;
|
float F = (float)viewport.zfar;
|
||||||
const float ortho_projection[4][4] =
|
const float ortho_projection[4][4] =
|
||||||
{
|
{
|
||||||
{ 2.0f/(R-L), 0.0f, 0.0f, 0.0f },
|
{ 2.0f/(R-L), 0.0f, 0.0f, 0.0f },
|
||||||
@ -464,8 +464,8 @@ void ImGui_ImplMetal_DestroyDeviceObjects()
|
|||||||
|
|
||||||
id<MTLRenderPipelineState> renderPipelineState = [self renderPipelineStateForFrameAndDevice:commandBuffer.device];
|
id<MTLRenderPipelineState> renderPipelineState = [self renderPipelineStateForFrameAndDevice:commandBuffer.device];
|
||||||
|
|
||||||
size_t vertexBufferLength = drawData->TotalVtxCount * sizeof(ImDrawVert);
|
size_t vertexBufferLength = (size_t)drawData->TotalVtxCount * sizeof(ImDrawVert);
|
||||||
size_t indexBufferLength = drawData->TotalIdxCount * sizeof(ImDrawIdx);
|
size_t indexBufferLength = (size_t)drawData->TotalIdxCount * sizeof(ImDrawIdx);
|
||||||
MetalBuffer* vertexBuffer = [self dequeueReusableBufferOfLength:vertexBufferLength device:commandBuffer.device];
|
MetalBuffer* vertexBuffer = [self dequeueReusableBufferOfLength:vertexBufferLength device:commandBuffer.device];
|
||||||
MetalBuffer* indexBuffer = [self dequeueReusableBufferOfLength:indexBufferLength device:commandBuffer.device];
|
MetalBuffer* indexBuffer = [self dequeueReusableBufferOfLength:indexBufferLength device:commandBuffer.device];
|
||||||
|
|
||||||
@ -482,8 +482,8 @@ void ImGui_ImplMetal_DestroyDeviceObjects()
|
|||||||
{
|
{
|
||||||
const ImDrawList* cmd_list = drawData->CmdLists[n];
|
const ImDrawList* cmd_list = drawData->CmdLists[n];
|
||||||
|
|
||||||
memcpy((char *)vertexBuffer.buffer.contents + vertexBufferOffset, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
|
memcpy((char *)vertexBuffer.buffer.contents + vertexBufferOffset, cmd_list->VtxBuffer.Data, (size_t)cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
|
||||||
memcpy((char *)indexBuffer.buffer.contents + indexBufferOffset, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
|
memcpy((char *)indexBuffer.buffer.contents + indexBufferOffset, cmd_list->IdxBuffer.Data, (size_t)cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
|
||||||
|
|
||||||
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
|
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
|
||||||
{
|
{
|
||||||
@ -533,8 +533,8 @@ void ImGui_ImplMetal_DestroyDeviceObjects()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vertexBufferOffset += cmd_list->VtxBuffer.Size * sizeof(ImDrawVert);
|
vertexBufferOffset += (size_t)cmd_list->VtxBuffer.Size * sizeof(ImDrawVert);
|
||||||
indexBufferOffset += cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx);
|
indexBufferOffset += (size_t)cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
__weak id weakSelf = self;
|
__weak id weakSelf = self;
|
||||||
|
@ -171,7 +171,7 @@ void ImGui_ImplOSX_NewFrame(NSView* view)
|
|||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
if (view)
|
if (view)
|
||||||
{
|
{
|
||||||
const float dpi = [view.window backingScaleFactor];
|
const float dpi = (float)[view.window backingScaleFactor];
|
||||||
io.DisplaySize = ImVec2((float)view.bounds.size.width, (float)view.bounds.size.height);
|
io.DisplaySize = ImVec2((float)view.bounds.size.width, (float)view.bounds.size.height);
|
||||||
io.DisplayFramebufferScale = ImVec2(dpi, dpi);
|
io.DisplayFramebufferScale = ImVec2(dpi, dpi);
|
||||||
}
|
}
|
||||||
@ -180,7 +180,7 @@ void ImGui_ImplOSX_NewFrame(NSView* view)
|
|||||||
if (g_Time == 0.0)
|
if (g_Time == 0.0)
|
||||||
g_Time = CFAbsoluteTimeGetCurrent();
|
g_Time = CFAbsoluteTimeGetCurrent();
|
||||||
CFAbsoluteTime current_time = CFAbsoluteTimeGetCurrent();
|
CFAbsoluteTime current_time = CFAbsoluteTimeGetCurrent();
|
||||||
io.DeltaTime = current_time - g_Time;
|
io.DeltaTime = (float)(current_time - g_Time);
|
||||||
g_Time = current_time;
|
g_Time = current_time;
|
||||||
|
|
||||||
ImGui_ImplOSX_UpdateMouseCursorAndButtons();
|
ImGui_ImplOSX_UpdateMouseCursorAndButtons();
|
||||||
@ -231,7 +231,7 @@ bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view)
|
|||||||
NSPoint mousePoint = event.locationInWindow;
|
NSPoint mousePoint = event.locationInWindow;
|
||||||
mousePoint = [view convertPoint:mousePoint fromView:nil];
|
mousePoint = [view convertPoint:mousePoint fromView:nil];
|
||||||
mousePoint = NSMakePoint(mousePoint.x, view.bounds.size.height - mousePoint.y);
|
mousePoint = NSMakePoint(mousePoint.x, view.bounds.size.height - mousePoint.y);
|
||||||
io.MousePos = ImVec2(mousePoint.x, mousePoint.y);
|
io.MousePos = ImVec2((float)mousePoint.x, (float)mousePoint.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.type == NSEventTypeScrollWheel)
|
if (event.type == NSEventTypeScrollWheel)
|
||||||
@ -258,9 +258,9 @@ bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fabs(wheel_dx) > 0.0)
|
if (fabs(wheel_dx) > 0.0)
|
||||||
io.MouseWheelH += wheel_dx * 0.1f;
|
io.MouseWheelH += (float)wheel_dx * 0.1f;
|
||||||
if (fabs(wheel_dy) > 0.0)
|
if (fabs(wheel_dy) > 0.0)
|
||||||
io.MouseWheel += wheel_dy * 0.1f;
|
io.MouseWheel += (float)wheel_dy * 0.1f;
|
||||||
return io.WantCaptureMouse;
|
return io.WantCaptureMouse;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,8 +268,8 @@ bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view)
|
|||||||
if (event.type == NSEventTypeKeyDown)
|
if (event.type == NSEventTypeKeyDown)
|
||||||
{
|
{
|
||||||
NSString* str = [event characters];
|
NSString* str = [event characters];
|
||||||
int len = (int)[str length];
|
NSUInteger len = [str length];
|
||||||
for (int i = 0; i < len; i++)
|
for (NSUInteger i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
int c = [str characterAtIndex:i];
|
int c = [str characterAtIndex:i];
|
||||||
if (!io.KeyCtrl && !(c >= 0xF700 && c <= 0xFFFF) && c != 127)
|
if (!io.KeyCtrl && !(c >= 0xF700 && c <= 0xFFFF) && c != 127)
|
||||||
@ -288,8 +288,8 @@ bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view)
|
|||||||
if (event.type == NSEventTypeKeyUp)
|
if (event.type == NSEventTypeKeyUp)
|
||||||
{
|
{
|
||||||
NSString* str = [event characters];
|
NSString* str = [event characters];
|
||||||
int len = (int)[str length];
|
NSUInteger len = [str length];
|
||||||
for (int i = 0; i < len; i++)
|
for (NSUInteger i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
int c = [str characterAtIndex:i];
|
int c = [str characterAtIndex:i];
|
||||||
int key = mapCharacterToKey(c);
|
int key = mapCharacterToKey(c);
|
||||||
@ -301,7 +301,6 @@ bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view)
|
|||||||
|
|
||||||
if (event.type == NSEventTypeFlagsChanged)
|
if (event.type == NSEventTypeFlagsChanged)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
unsigned int flags = [event modifierFlags] & NSEventModifierFlagDeviceIndependentFlagsMask;
|
unsigned int flags = [event modifierFlags] & NSEventModifierFlagDeviceIndependentFlagsMask;
|
||||||
|
|
||||||
bool oldKeyCtrl = io.KeyCtrl;
|
bool oldKeyCtrl = io.KeyCtrl;
|
||||||
|
Loading…
Reference in New Issue
Block a user