mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-10-31 05:01:05 +01:00 
			
		
		
		
	Examples: Cast to ImTextureID instead of void* when assigning to TexId. Applied to all examples. (#2015)
This commit is contained in:
		| @@ -213,7 +213,8 @@ void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data) | |||||||
|                 ctx->RSSetScissorRects(1, &r); |                 ctx->RSSetScissorRects(1, &r); | ||||||
|  |  | ||||||
|                 // Bind texture, Draw |                 // Bind texture, Draw | ||||||
|                 ctx->PSSetShaderResources(0, 1, (ID3D10ShaderResourceView**)&pcmd->TextureId); |                 ID3D10ShaderResourceView* texture_srv = (ID3D10ShaderResourceView*)pcmd->TextureId; | ||||||
|  |                 ctx->PSSetShaderResources(0, 1, &texture_srv); | ||||||
|                 ctx->DrawIndexed(pcmd->ElemCount, idx_offset, vtx_offset); |                 ctx->DrawIndexed(pcmd->ElemCount, idx_offset, vtx_offset); | ||||||
|             } |             } | ||||||
|             idx_offset += pcmd->ElemCount; |             idx_offset += pcmd->ElemCount; | ||||||
| @@ -279,7 +280,7 @@ static void ImGui_ImplDX10_CreateFontsTexture() | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     // Store our identifier |     // Store our identifier | ||||||
|     io.Fonts->TexID = (void *)g_pFontTextureView; |     io.Fonts->TexID = (ImTextureID)g_pFontTextureView; | ||||||
|  |  | ||||||
|     // Create texture sampler |     // Create texture sampler | ||||||
|     { |     { | ||||||
|   | |||||||
| @@ -218,7 +218,8 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data) | |||||||
|                 ctx->RSSetScissorRects(1, &r); |                 ctx->RSSetScissorRects(1, &r); | ||||||
|  |  | ||||||
|                 // Bind texture, Draw |                 // Bind texture, Draw | ||||||
|                 ctx->PSSetShaderResources(0, 1, (ID3D11ShaderResourceView**)&pcmd->TextureId); |                 ID3D11ShaderResourceView* texture_srv = (ID3D11ShaderResourceView*)pcmd->TextureId; | ||||||
|  |                 ctx->PSSetShaderResources(0, 1, &texture_srv); | ||||||
|                 ctx->DrawIndexed(pcmd->ElemCount, idx_offset, vtx_offset); |                 ctx->DrawIndexed(pcmd->ElemCount, idx_offset, vtx_offset); | ||||||
|             } |             } | ||||||
|             idx_offset += pcmd->ElemCount; |             idx_offset += pcmd->ElemCount; | ||||||
| @@ -286,7 +287,7 @@ static void ImGui_ImplDX11_CreateFontsTexture() | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     // Store our identifier |     // Store our identifier | ||||||
|     io.Fonts->TexID = (void *)g_pFontTextureView; |     io.Fonts->TexID = (ImTextureID)g_pFontTextureView; | ||||||
|  |  | ||||||
|     // Create texture sampler |     // Create texture sampler | ||||||
|     { |     { | ||||||
|   | |||||||
| @@ -177,7 +177,8 @@ void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data) | |||||||
|             else |             else | ||||||
|             { |             { | ||||||
|                 const RECT r = { (LONG)(pcmd->ClipRect.x - pos.x), (LONG)(pcmd->ClipRect.y - pos.y), (LONG)(pcmd->ClipRect.z - pos.x), (LONG)(pcmd->ClipRect.w - pos.y) }; |                 const RECT r = { (LONG)(pcmd->ClipRect.x - pos.x), (LONG)(pcmd->ClipRect.y - pos.y), (LONG)(pcmd->ClipRect.z - pos.x), (LONG)(pcmd->ClipRect.w - pos.y) }; | ||||||
|                 g_pd3dDevice->SetTexture(0, (LPDIRECT3DTEXTURE9)pcmd->TextureId); |                 const LPDIRECT3DTEXTURE9 texture = (LPDIRECT3DTEXTURE9)pcmd->TextureId; | ||||||
|  |                 g_pd3dDevice->SetTexture(0, texture); | ||||||
|                 g_pd3dDevice->SetScissorRect(&r); |                 g_pd3dDevice->SetScissorRect(&r); | ||||||
|                 g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.Size, idx_offset, pcmd->ElemCount/3); |                 g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.Size, idx_offset, pcmd->ElemCount/3); | ||||||
|             } |             } | ||||||
| @@ -228,7 +229,7 @@ static bool ImGui_ImplDX9_CreateFontsTexture() | |||||||
|     g_FontTexture->UnlockRect(0); |     g_FontTexture->UnlockRect(0); | ||||||
|  |  | ||||||
|     // Store our identifier |     // Store our identifier | ||||||
|     io.Fonts->TexID = (void *)g_FontTexture; |     io.Fonts->TexID = (ImTextureID)g_FontTexture; | ||||||
|  |  | ||||||
|     return true; |     return true; | ||||||
| } | } | ||||||
|   | |||||||
| @@ -190,7 +190,7 @@ bool ImGui_Marmalade_CreateDeviceObjects() | |||||||
|     g_FontTexture->Upload(); |     g_FontTexture->Upload(); | ||||||
|  |  | ||||||
|     // Store our identifier |     // Store our identifier | ||||||
|     io.Fonts->TexID = (void *)g_FontTexture; |     io.Fonts->TexID = (ImTextureID)g_FontTexture; | ||||||
|  |  | ||||||
|     return true; |     return true; | ||||||
| } | } | ||||||
|   | |||||||
| @@ -98,7 +98,7 @@ bool ImGui_ImplMetal_CreateFontsTexture(id<MTLDevice> device) | |||||||
|     [g_sharedMetalContext makeFontTextureWithDevice:device]; |     [g_sharedMetalContext makeFontTextureWithDevice:device]; | ||||||
|      |      | ||||||
|     ImGuiIO& io = ImGui::GetIO(); |     ImGuiIO& io = ImGui::GetIO(); | ||||||
|     io.Fonts->TexID = (__bridge void *)g_sharedMetalContext.fontTexture; |     io.Fonts->TexID = (__bridge void *)g_sharedMetalContext.fontTexture; // ImTextureID == void* | ||||||
|  |  | ||||||
|     return (g_sharedMetalContext.fontTexture != nil); |     return (g_sharedMetalContext.fontTexture != nil); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -182,7 +182,7 @@ bool ImGui_ImplOpenGL2_CreateFontsTexture() | |||||||
|     glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); |     glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); | ||||||
|  |  | ||||||
|     // Store our identifier |     // Store our identifier | ||||||
|     io.Fonts->TexID = (void *)(intptr_t)g_FontTexture; |     io.Fonts->TexID = (ImTextureID)(intptr_t)g_FontTexture; | ||||||
|  |  | ||||||
|     // Restore state |     // Restore state | ||||||
|     glBindTexture(GL_TEXTURE_2D, last_texture); |     glBindTexture(GL_TEXTURE_2D, last_texture); | ||||||
|   | |||||||
| @@ -279,7 +279,7 @@ bool ImGui_ImplOpenGL3_CreateFontsTexture() | |||||||
|     glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); |     glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); | ||||||
|  |  | ||||||
|     // Store our identifier |     // Store our identifier | ||||||
|     io.Fonts->TexID = (void *)(intptr_t)g_FontTexture; |     io.Fonts->TexID = (ImTextureID)(intptr_t)g_FontTexture; | ||||||
|  |  | ||||||
|     // Restore state |     // Restore state | ||||||
|     glBindTexture(GL_TEXTURE_2D, last_texture); |     glBindTexture(GL_TEXTURE_2D, last_texture); | ||||||
|   | |||||||
| @@ -461,7 +461,7 @@ bool ImGui_ImplVulkan_CreateFontsTexture(VkCommandBuffer command_buffer) | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     // Store our identifier |     // Store our identifier | ||||||
|     io.Fonts->TexID = (void *)(intptr_t)g_FontImage; |     io.Fonts->TexID = (ImTextureID)(intptr_t)g_FontImage; | ||||||
|  |  | ||||||
|     return true; |     return true; | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1671,7 +1671,7 @@ void* ImFileLoadToMemory(const char* filename, const char* file_open_mode, size_ | |||||||
|         return NULL; |         return NULL; | ||||||
|     } |     } | ||||||
|     if (padding_bytes > 0) |     if (padding_bytes > 0) | ||||||
|         memset((void *)(((char*)file_data) + file_size), 0, (size_t)padding_bytes); |         memset((void*)(((char*)file_data) + file_size), 0, (size_t)padding_bytes); | ||||||
|  |  | ||||||
|     fclose(f); |     fclose(f); | ||||||
|     if (out_file_size) |     if (out_file_size) | ||||||
| @@ -8476,7 +8476,7 @@ bool ImGui::ImageButton(ImTextureID user_texture_id, const ImVec2& size, const I | |||||||
|  |  | ||||||
|     // Default to using texture ID as ID. User can still push string/integer prefixes. |     // Default to using texture ID as ID. User can still push string/integer prefixes. | ||||||
|     // We could hash the size/uv to create a unique ID but that would prevent the user from animating UV. |     // We could hash the size/uv to create a unique ID but that would prevent the user from animating UV. | ||||||
|     PushID((void *)user_texture_id); |     PushID((void*)user_texture_id); | ||||||
|     const ImGuiID id = window->GetID("#image"); |     const ImGuiID id = window->GetID("#image"); | ||||||
|     PopID(); |     PopID(); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -71,7 +71,7 @@ bool binary_to_compressed_c(const char* filename, const char* symbol, bool use_b | |||||||
|     if (fseek(f, 0, SEEK_END) || (data_sz = (int)ftell(f)) == -1 || fseek(f, 0, SEEK_SET)) { fclose(f); return false; } |     if (fseek(f, 0, SEEK_END) || (data_sz = (int)ftell(f)) == -1 || fseek(f, 0, SEEK_SET)) { fclose(f); return false; } | ||||||
|     char* data = new char[data_sz+4]; |     char* data = new char[data_sz+4]; | ||||||
|     if (fread(data, 1, data_sz, f) != (size_t)data_sz) { fclose(f); delete[] data; return false; } |     if (fread(data, 1, data_sz, f) != (size_t)data_sz) { fclose(f); delete[] data; return false; } | ||||||
|     memset((void *)(((char*)data) + data_sz), 0, 4); |     memset((void*)(((char*)data) + data_sz), 0, 4); | ||||||
|     fclose(f); |     fclose(f); | ||||||
|  |  | ||||||
|     // Compress |     // Compress | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user