Skip to content

Commit ec4d296

Browse files
committed
Use explict type names instead of var
1 parent 5d4436a commit ec4d296

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

Examples/ExampleMonoGame/ImGuiRenderer.cs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ public class ImGuiRenderer
3535
private int _scrollWheelValue;
3636
private int _horizontalScrollWheelValue;
3737
private readonly Keys[] _allKeys = Enum.GetValues<Keys>();
38-
39-
38+
4039
public ImGuiRenderer(Game game)
4140
{
4241
ArgumentNullException.ThrowIfNull(game);
@@ -138,11 +137,11 @@ private unsafe void CreateTexture(ImTextureDataPtr textureData)
138137

139138
if (textureData.Pixels != null)
140139
{
141-
var pixelCount = textureData.Width * textureData.Height;
142-
var bytesPerPixel = textureData.Format == ImTextureFormat.Rgba32 ? 4 : 1;
143-
var dataSize = pixelCount * bytesPerPixel;
140+
int pixelCount = textureData.Width * textureData.Height;
141+
int bytesPerPixel = textureData.Format == ImTextureFormat.Rgba32 ? 4 : 1;
142+
int dataSize = pixelCount * bytesPerPixel;
144143

145-
var managedData = new byte[dataSize];
144+
byte[] managedData = new byte[dataSize];
146145
Marshal.Copy(new IntPtr(textureData.Pixels), managedData, 0, dataSize);
147146
texture.SetData(managedData);
148147
}
@@ -160,7 +159,7 @@ private unsafe void CreateTexture(ImTextureDataPtr textureData)
160159
private unsafe void UpdateTextureData(ImTextureDataPtr textureData)
161160
{
162161
IntPtr texId = textureData.GetTexID();
163-
if (!_textures.TryGetValue(texId, out var textureInfo))
162+
if (!_textures.TryGetValue(texId, out TextureInfo textureInfo))
164163
{
165164
return;
166165
}
@@ -506,7 +505,7 @@ private unsafe void RenderCommandLists(ImDrawData* drawData)
506505
// In v1.92, we need to handle ImTextureRef instead of ImTextureID
507506
ImTextureRef textureRef = drawCmd->TexRef;
508507
ImTextureID texId = textureRef.GetTexID();
509-
if (!_textures.TryGetValue(texId, out var textureInfo))
508+
if (!_textures.TryGetValue(texId, out TextureInfo textureInfo))
510509
{
511510
throw new InvalidOperationException($"Could not find a texture with id '{texId}', please check your bindings");
512511
}
@@ -518,9 +517,9 @@ private unsafe void RenderCommandLists(ImDrawData* drawData)
518517
(int)(drawCmd->ClipRect.W - drawCmd->ClipRect.Y)
519518
);
520519

521-
var effect = UpdateEffect(textureInfo.Texture);
520+
Effect effect = UpdateEffect(textureInfo.Texture);
522521

523-
foreach (var pass in effect.CurrentTechnique.Passes)
522+
foreach (EffectPass pass in effect.CurrentTechnique.Passes)
524523
{
525524
pass.Apply();
526525

@@ -549,11 +548,11 @@ public void Dispose()
549548
_effect?.Dispose();
550549

551550
// Clean up managed textures
552-
foreach (var kvp in _textures)
551+
foreach(TextureInfo textureInfo in _textures.Values)
553552
{
554-
if (kvp.Value.IsManaged)
553+
if (textureInfo.IsManaged)
555554
{
556-
kvp.Value.Texture?.Dispose();
555+
textureInfo.Texture?.Dispose();
557556
}
558557
}
559558
_textures.Clear();

Examples/ExampleMonoGame/SampleGame.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ protected virtual void ImGuiLayout()
108108
builder.End();
109109
ImGui.Text(builder);
110110
}
111-
111+
112112
ImGui.InputText("Text input"u8, ref _textBuffer[0], 100);
113113

114114
ImGui.Text("Texture sample"u8);
@@ -135,11 +135,11 @@ protected virtual void ImGuiLayout()
135135
public static Texture2D CreateTexture(GraphicsDevice device, int width, int height, Func<int, Color> paint)
136136
{
137137
//initialize a texture
138-
var texture = new Texture2D(device, width, height);
138+
Texture2D texture = new Texture2D(device, width, height);
139139

140140
//the array holds the color for each pixel in the texture
141141
Color[] data = new Color[width * height];
142-
for (var pixel = 0; pixel < data.Length; pixel++)
142+
for (int pixel = 0; pixel < data.Length; pixel++)
143143
{
144144
//the function applies the color according to the specified pixel
145145
data[pixel] = paint(pixel);

0 commit comments

Comments
 (0)