1
0
mirror of synced 2024-12-01 02:27:22 +01:00

Enable BRFNT and BCFNT rendering for layout editor

This commit is contained in:
KillzXGaming 2020-02-14 20:15:03 -05:00
parent 001e82bff0
commit 84352cf967
6 changed files with 65 additions and 21 deletions

View File

@ -139,8 +139,6 @@ namespace FirstPlugin
}
}
public string Name { get { return FileName; } }
public BitmapFont GetBitmapFont(bool UseChannelComp = false)
{
return bffnt.GetBitmapFont(UseChannelComp);

View File

@ -497,17 +497,11 @@ namespace LayoutBXLYT
if (updateBitmap)
BindFontBitmap(pane, fontBitmap);
var mat = textBox.Material as Cafe.Material;
BxlytShader shader = ShaderLoader.CafeShader;
ShaderLoader.CafeShader.Enable();
BflytShader.SetMaterials(ShaderLoader.CafeShader, mat, pane, Textures);
SetupShaders(pane, textBox.Material, Textures);
GL.ActiveTexture(TextureUnit.Texture0 + 1);
shader.SetInt($"numTextureMaps", 1);
shader.SetInt($"textures0", 1);
shader.SetInt($"hasTexture0", 1);
SetupTextboxShader(pane, textBox.Material);
GL.BindTexture(TextureTarget.Texture2D, textBox.RenderableFont.TexID);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureSwizzleR, ConvertChannel(STChannelType.Red));
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureSwizzleG, ConvertChannel(STChannelType.Green));
@ -534,8 +528,6 @@ namespace LayoutBXLYT
DrawRectangle(pane, gameWindow, pane.Rectangle, texCoords, Colors, false, effectiveAlpha, isSelected);
ShaderLoader.CafeShader.Disable();
GL.Disable(EnableCap.Texture2D);
GL.BindTexture(TextureTarget.Texture2D, 0);
GL.PopAttrib();
@ -1339,6 +1331,44 @@ namespace LayoutBXLYT
}
}
//Todo make a method to get the shaders and set the values that way
//Shader loading for brlyt is still experimental and not done the same way
private static void SetupTextboxShader(BasePane pane, BxlytMaterial mat)
{
if (mat is Cafe.Material)
{
ShaderLoader.CafeShader.SetInt($"numTextureMaps", 1);
ShaderLoader.CafeShader.SetInt($"textures0", 1);
ShaderLoader.CafeShader.SetInt($"hasTexture0", 1);
}
else if (mat is CTR.Material)
{
ShaderLoader.CtrShader.SetInt($"numTextureMaps", 1);
ShaderLoader.CtrShader.SetInt($"textures0", 1);
ShaderLoader.CtrShader.SetInt($"hasTexture0", 1);
}
else if (mat is Revolution.Material)
{
//Make sure the text pane texture count is 1 to bind bitmap font to
if (((Revolution.Material)mat).Shader.TextureCount != 1) {
((Revolution.Material)mat).Shader.TextureCount = 1;
((Revolution.Material)mat).Shader.Compile();
Console.WriteLine($"Updating text pane texture renderer {pane.Name}");
}
//Reload transforms
for (int i = 0; i < 3; i++) {
var matTranslate = Matrix4.CreateTranslation(0 / 1 - 0.5f, 0 / 1 - 0.5f, 0);
((Revolution.Material)mat).Shader.SetMatrix4(String.Format("textureTransforms[{0}]", i), ref matTranslate);
}
//Load ids and enable the bitmap font texture
((Revolution.Material)mat).Shader.SetInt($"numTextureMaps", 1);
((Revolution.Material)mat).Shader.SetInt($"textures0", 1);
((Revolution.Material)mat).Shader.SetInt($"hasTexture0", 1);
}
}
private static void RenderWindowContent(BasePane pane, uint sizeX, uint sizeY, BxlytWindowContent content,
byte effectiveAlpha, Dictionary<string, STGenericTexture> Textures)
{

View File

@ -238,7 +238,7 @@ namespace LayoutBXLYT.Cafe
System.Drawing.Bitmap bitmap = null;
foreach (var fontFile in FirstPlugin.PluginRuntime.BxfntFiles)
{
if (Utils.CompareNoExtension(fontFile.Name, FontName))
if (Utils.CompareNoExtension(fontFile.FileName, FontName))
bitmap = fontFile.GetBitmap(Text, false, this);
}

View File

@ -149,7 +149,17 @@ namespace LayoutBXLYT.CTR
public void UpdateTextRender()
{
if (RenderableFont == null) return;
System.Drawing.Bitmap bitmap = null;
foreach (var fontFile in FirstPlugin.PluginRuntime.BxfntFiles)
{
if (Utils.CompareNoExtension(fontFile.FileName, FontName))
bitmap = fontFile.GetBitmap(Text, false, this);
}
if (bitmap != null)
RenderableFont.UpdateFromBitmap(bitmap);
}
public void CopyMaterial()

View File

@ -158,7 +158,17 @@ namespace LayoutBXLYT.Revolution
public void UpdateTextRender()
{
if (RenderableFont == null) return;
System.Drawing.Bitmap bitmap = null;
foreach (var fontFile in FirstPlugin.PluginRuntime.BxfntFiles)
{
if (Utils.CompareNoExtension(fontFile.FileName, FontName))
bitmap = fontFile.GetBitmap(Text, false, this);
}
if (bitmap != null)
RenderableFont.UpdateFromBitmap(bitmap);
}
public void CopyMaterial()

View File

@ -493,13 +493,9 @@ namespace LayoutBXLYT
var textPane = (ITextPane)pane;
Bitmap bitmap = null;
if (pane is Cafe.TXT1)
{
foreach (var fontFile in FirstPlugin.PluginRuntime.BxfntFiles)
{
if (Utils.CompareNoExtension(fontFile.Name, textPane.FontName))
bitmap = fontFile.GetBitmap(textPane.Text, false, pane);
}
foreach (var fontFile in FirstPlugin.PluginRuntime.BxfntFiles) {
if (Utils.CompareNoExtension(fontFile.FileName, textPane.FontName))
bitmap = fontFile.GetBitmap(textPane.Text, false, pane);
}
if (bitmap != null)