Enable BRFNT and BCFNT rendering for layout editor
This commit is contained in:
parent
001e82bff0
commit
84352cf967
@ -139,8 +139,6 @@ namespace FirstPlugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Name { get { return FileName; } }
|
|
||||||
|
|
||||||
public BitmapFont GetBitmapFont(bool UseChannelComp = false)
|
public BitmapFont GetBitmapFont(bool UseChannelComp = false)
|
||||||
{
|
{
|
||||||
return bffnt.GetBitmapFont(UseChannelComp);
|
return bffnt.GetBitmapFont(UseChannelComp);
|
||||||
|
@ -497,17 +497,11 @@ namespace LayoutBXLYT
|
|||||||
if (updateBitmap)
|
if (updateBitmap)
|
||||||
BindFontBitmap(pane, fontBitmap);
|
BindFontBitmap(pane, fontBitmap);
|
||||||
|
|
||||||
var mat = textBox.Material as Cafe.Material;
|
SetupShaders(pane, textBox.Material, Textures);
|
||||||
|
|
||||||
BxlytShader shader = ShaderLoader.CafeShader;
|
|
||||||
|
|
||||||
ShaderLoader.CafeShader.Enable();
|
|
||||||
BflytShader.SetMaterials(ShaderLoader.CafeShader, mat, pane, Textures);
|
|
||||||
|
|
||||||
GL.ActiveTexture(TextureUnit.Texture0 + 1);
|
GL.ActiveTexture(TextureUnit.Texture0 + 1);
|
||||||
shader.SetInt($"numTextureMaps", 1);
|
SetupTextboxShader(pane, textBox.Material);
|
||||||
shader.SetInt($"textures0", 1);
|
|
||||||
shader.SetInt($"hasTexture0", 1);
|
|
||||||
GL.BindTexture(TextureTarget.Texture2D, textBox.RenderableFont.TexID);
|
GL.BindTexture(TextureTarget.Texture2D, textBox.RenderableFont.TexID);
|
||||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureSwizzleR, ConvertChannel(STChannelType.Red));
|
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureSwizzleR, ConvertChannel(STChannelType.Red));
|
||||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureSwizzleG, ConvertChannel(STChannelType.Green));
|
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);
|
DrawRectangle(pane, gameWindow, pane.Rectangle, texCoords, Colors, false, effectiveAlpha, isSelected);
|
||||||
|
|
||||||
ShaderLoader.CafeShader.Disable();
|
|
||||||
|
|
||||||
GL.Disable(EnableCap.Texture2D);
|
GL.Disable(EnableCap.Texture2D);
|
||||||
GL.BindTexture(TextureTarget.Texture2D, 0);
|
GL.BindTexture(TextureTarget.Texture2D, 0);
|
||||||
GL.PopAttrib();
|
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,
|
private static void RenderWindowContent(BasePane pane, uint sizeX, uint sizeY, BxlytWindowContent content,
|
||||||
byte effectiveAlpha, Dictionary<string, STGenericTexture> Textures)
|
byte effectiveAlpha, Dictionary<string, STGenericTexture> Textures)
|
||||||
{
|
{
|
||||||
|
@ -238,7 +238,7 @@ namespace LayoutBXLYT.Cafe
|
|||||||
System.Drawing.Bitmap bitmap = null;
|
System.Drawing.Bitmap bitmap = null;
|
||||||
foreach (var fontFile in FirstPlugin.PluginRuntime.BxfntFiles)
|
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);
|
bitmap = fontFile.GetBitmap(Text, false, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,7 +149,17 @@ namespace LayoutBXLYT.CTR
|
|||||||
|
|
||||||
public void UpdateTextRender()
|
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()
|
public void CopyMaterial()
|
||||||
|
@ -158,7 +158,17 @@ namespace LayoutBXLYT.Revolution
|
|||||||
|
|
||||||
public void UpdateTextRender()
|
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()
|
public void CopyMaterial()
|
||||||
|
@ -493,13 +493,9 @@ namespace LayoutBXLYT
|
|||||||
var textPane = (ITextPane)pane;
|
var textPane = (ITextPane)pane;
|
||||||
Bitmap bitmap = null;
|
Bitmap bitmap = null;
|
||||||
|
|
||||||
if (pane is Cafe.TXT1)
|
foreach (var fontFile in FirstPlugin.PluginRuntime.BxfntFiles) {
|
||||||
{
|
if (Utils.CompareNoExtension(fontFile.FileName, textPane.FontName))
|
||||||
foreach (var fontFile in FirstPlugin.PluginRuntime.BxfntFiles)
|
bitmap = fontFile.GetBitmap(textPane.Text, false, pane);
|
||||||
{
|
|
||||||
if (Utils.CompareNoExtension(fontFile.Name, textPane.FontName))
|
|
||||||
bitmap = fontFile.GetBitmap(textPane.Text, false, pane);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bitmap != null)
|
if (bitmap != null)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user