Sfoglia il codice sorgente

Textures: ImTextureData::GetPixels() returns void* for clarity.

ocornut 3 mesi fa
parent
commit
2f9c518ca8
3 ha cambiato i file con 7 aggiunte e 7 eliminazioni
  1. 2 2
      imgui.h
  2. 4 4
      imgui_draw.cpp
  3. 1 1
      imgui_internal.h

+ 2 - 2
imgui.h

@@ -3440,8 +3440,8 @@ struct ImTextureData
     ~ImTextureData()    { DestroyPixels(); }
     ~ImTextureData()    { DestroyPixels(); }
     IMGUI_API void      Create(ImTextureFormat format, int w, int h);
     IMGUI_API void      Create(ImTextureFormat format, int w, int h);
     IMGUI_API void      DestroyPixels();
     IMGUI_API void      DestroyPixels();
-    unsigned char*      GetPixels()                 { IM_ASSERT(Pixels != NULL); return Pixels; }
-    unsigned char*      GetPixelsAt(int x, int y)   { IM_ASSERT(Pixels != NULL); return Pixels + (x + y * Width) * BytesPerPixel; }
+    void*               GetPixels()                 { IM_ASSERT(Pixels != NULL); return Pixels; }
+    void*               GetPixelsAt(int x, int y)   { IM_ASSERT(Pixels != NULL); return Pixels + (x + y * Width) * BytesPerPixel; }
     int                 GetSizeInBytes() const      { return Width * Height * BytesPerPixel; }
     int                 GetSizeInBytes() const      { return Width * Height * BytesPerPixel; }
     int                 GetPitch() const            { return Width * BytesPerPixel; }
     int                 GetPitch() const            { return Width * BytesPerPixel; }
     ImTextureRef        GetTexRef()                 { ImTextureRef tex_ref; tex_ref._TexData = this; tex_ref._TexID = ImTextureID_Invalid; return tex_ref; }
     ImTextureRef        GetTexRef()                 { ImTextureRef tex_ref; tex_ref._TexData = this; tex_ref._TexID = ImTextureID_Invalid; return tex_ref; }

+ 4 - 4
imgui_draw.cpp

@@ -2863,7 +2863,7 @@ void ImFontAtlasTextureBlockPostProcess(ImFontAtlasPostProcessData* data)
 
 
 void ImFontAtlasTextureBlockPostProcessMultiply(ImFontAtlasPostProcessData* data, float multiply_factor)
 void ImFontAtlasTextureBlockPostProcessMultiply(ImFontAtlasPostProcessData* data, float multiply_factor)
 {
 {
-    unsigned char* pixels = data->Pixels;
+    unsigned char* pixels = (unsigned char*)data->Pixels;
     int pitch = data->Pitch;
     int pitch = data->Pitch;
     if (data->Format == ImTextureFormat_Alpha8)
     if (data->Format == ImTextureFormat_Alpha8)
     {
     {
@@ -3448,7 +3448,7 @@ void ImFontAtlasBuildRenderBitmapFromString(ImFontAtlas* atlas, int x, int y, in
     {
     {
     case ImTextureFormat_Alpha8:
     case ImTextureFormat_Alpha8:
     {
     {
-        ImU8* out_p = tex->GetPixelsAt(x, y);
+        ImU8* out_p = (ImU8*)tex->GetPixelsAt(x, y);
         for (int off_y = 0; off_y < h; off_y++, out_p += tex->Width, in_str += w)
         for (int off_y = 0; off_y < h; off_y++, out_p += tex->Width, in_str += w)
             for (int off_x = 0; off_x < w; off_x++)
             for (int off_x = 0; off_x < w; off_x++)
                 out_p[off_x] = (in_str[off_x] == in_marker_char) ? 0xFF : 0x00;
                 out_p[off_x] = (in_str[off_x] == in_marker_char) ? 0xFF : 0x00;
@@ -3456,7 +3456,7 @@ void ImFontAtlasBuildRenderBitmapFromString(ImFontAtlas* atlas, int x, int y, in
     }
     }
     case ImTextureFormat_RGBA32:
     case ImTextureFormat_RGBA32:
     {
     {
-        ImU32* out_p = (ImU32*)(void*)tex->GetPixelsAt(x, y);
+        ImU32* out_p = (ImU32*)tex->GetPixelsAt(x, y);
         for (int off_y = 0; off_y < h; off_y++, out_p += tex->Width, in_str += w)
         for (int off_y = 0; off_y < h; off_y++, out_p += tex->Width, in_str += w)
             for (int off_x = 0; off_x < w; off_x++)
             for (int off_x = 0; off_x < w; off_x++)
                 out_p[off_x] = (in_str[off_x] == in_marker_char) ? IM_COL32_WHITE : IM_COL32_BLACK_TRANS;
                 out_p[off_x] = (in_str[off_x] == in_marker_char) ? IM_COL32_WHITE : IM_COL32_BLACK_TRANS;
@@ -5124,7 +5124,7 @@ void ImFontAtlasBakedSetFontGlyphBitmap(ImFontAtlas* atlas, ImFontBaked* baked,
 {
 {
     ImTextureData* tex = atlas->TexData;
     ImTextureData* tex = atlas->TexData;
     IM_ASSERT(r->x + r->w <= tex->Width && r->y + r->h <= tex->Height);
     IM_ASSERT(r->x + r->w <= tex->Width && r->y + r->h <= tex->Height);
-    ImFontAtlasTextureBlockConvert(src_pixels, src_fmt, src_pitch, tex->GetPixelsAt(r->x, r->y), tex->Format, tex->GetPitch(), r->w, r->h);
+    ImFontAtlasTextureBlockConvert(src_pixels, src_fmt, src_pitch, (unsigned char*)tex->GetPixelsAt(r->x, r->y), tex->Format, tex->GetPitch(), r->w, r->h);
     ImFontAtlasPostProcessData pp_data = { atlas, baked->ContainerFont, src, baked, glyph, tex->GetPixelsAt(r->x, r->y), tex->Format, tex->GetPitch(), r->w, r->h };
     ImFontAtlasPostProcessData pp_data = { atlas, baked->ContainerFont, src, baked, glyph, tex->GetPixelsAt(r->x, r->y), tex->Format, tex->GetPitch(), r->w, r->h };
     ImFontAtlasTextureBlockPostProcess(&pp_data);
     ImFontAtlasTextureBlockPostProcess(&pp_data);
     ImFontAtlasTextureBlockQueueUpload(atlas, tex, r->x, r->y, r->w, r->h);
     ImFontAtlasTextureBlockQueueUpload(atlas, tex, r->x, r->y, r->w, r->h);

+ 1 - 1
imgui_internal.h

@@ -3746,7 +3746,7 @@ struct ImFontAtlasPostProcessData
     ImFontGlyph*        Glyph;
     ImFontGlyph*        Glyph;
 
 
     // Pixel data
     // Pixel data
-    unsigned char*      Pixels;
+    void*               Pixels;
     ImTextureFormat     Format;
     ImTextureFormat     Format;
     int                 Pitch;
     int                 Pitch;
     int                 Width;
     int                 Width;