From 1ff542a821c89ea947fc8f67e428847d7a4ed13d Mon Sep 17 00:00:00 2001 From: Pilzinsel64 Date: Fri, 20 Mar 2020 18:06:55 +0100 Subject: [PATCH] s --- .../Rendering/Renderer.vb | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/Pilz.Drawing.Drawing3D.OpenGLRenderer/Rendering/Renderer.vb b/Pilz.Drawing.Drawing3D.OpenGLRenderer/Rendering/Renderer.vb index be4bd02..ef5ba9e 100644 --- a/Pilz.Drawing.Drawing3D.OpenGLRenderer/Rendering/Renderer.vb +++ b/Pilz.Drawing.Drawing3D.OpenGLRenderer/Rendering/Renderer.vb @@ -49,7 +49,9 @@ Namespace RenderingN Private Function ColorToTexture(color As Color) As Image Dim tex As New Bitmap(1, 1) + tex.MakeTransparent() tex.SetPixel(0, 0, color) + Console.WriteLine(tex.GetPixel(0, 0).ToString & vbTab & color.ToString) Return tex End Function @@ -308,14 +310,24 @@ Namespace RenderingN GL.BindBuffer(BufferTarget.ElementArrayBuffer, IndicesBuffers(mesh)(i)) - Dim texID As Integer Dim isEmptyTexture As Boolean = l.Material?.Image Is Nothing Dim isEmptyColor As Boolean = l.Material?.Color Is Nothing - If (mode And RenderMode.Fill) = RenderMode.Fill Then - texID = If(isEmptyTexture, If(isEmptyColor, dicTextureIDs(emptyTexture), dicColorIDs(l.Material.Color)), dicTextureIDs(l.Material.Image)) + Dim setMaterialTextureOrColor = + Sub() + Dim texID As Integer + If Not isEmptyTexture Then + texID = dicTextureIDs(l.Material.Image) + ElseIf Not isEmptyColor Then + texID = dicColorIDs(l.Material.Color) + Else + texID = dicTextureIDs(emptyTexture) + End If + GL.BindTexture(TextureTarget.Texture2D, texID) + End Sub - GL.BindTexture(TextureTarget.Texture2D, texID) + If (mode And RenderMode.Fill) = RenderMode.Fill Then + setMaterialTextureOrColor() If Not isEmptyTexture Then GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, l.Material.Wrap.X) @@ -332,11 +344,9 @@ Namespace RenderingN If (mode And RenderMode.Outline) = RenderMode.Outline Then If (mode And RenderMode.Fill) = RenderMode.Fill Then - texID = dicTextureIDs(lineTexture) - GL.BindTexture(TextureTarget.Texture2D, texID) + GL.BindTexture(TextureTarget.Texture2D, dicTextureIDs(lineTexture)) Else - texID = If(isEmptyTexture, If(isEmptyColor, dicTextureIDs(emptyTexture), dicColorIDs(l.Material.Color)), dicTextureIDs(l.Material.Image)) - GL.BindTexture(TextureTarget.Texture2D, texID) + setMaterialTextureOrColor() If Not isEmptyTexture Then GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, l.Material.Wrap.X)