mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2025-02-16 22:08:26 +00:00
Fix shader issue from multiple viewports
This commit is contained in:
parent
307747ba1b
commit
cc2e7df037
8 changed files with 27 additions and 19 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -191,6 +191,8 @@ namespace Switch_Toolbox.Library
|
|||
}
|
||||
private void LoadBaseDrawables()
|
||||
{
|
||||
Runtime.OpenTKInitialized = true;
|
||||
|
||||
var floor = new DrawableFloor();
|
||||
var xyzLnes = new DrawableXyzLines();
|
||||
var skybox = new DrawableSkybox();
|
||||
|
@ -205,7 +207,6 @@ namespace Switch_Toolbox.Library
|
|||
|
||||
// LoadFog();
|
||||
|
||||
Runtime.OpenTKInitialized = true;
|
||||
}
|
||||
|
||||
public int FogStart = 1;
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Switch_Toolbox.Library.Rendering
|
|||
{
|
||||
public class DrawableBackground : AbstractGlDrawable
|
||||
{
|
||||
protected static ShaderProgram solidColorShaderProgram;
|
||||
ShaderProgram defaultShaderProgram;
|
||||
|
||||
int vbo_position;
|
||||
|
||||
|
@ -46,7 +46,7 @@ namespace Switch_Toolbox.Library.Rendering
|
|||
|
||||
public override void Draw(GL_ControlModern control, Pass pass)
|
||||
{
|
||||
if (pass == Pass.TRANSPARENT || Runtime.PBR.UseSkybox || solidColorShaderProgram == null)
|
||||
if (pass == Pass.TRANSPARENT || Runtime.PBR.UseSkybox)
|
||||
return;
|
||||
|
||||
bool buffersWereInitialized = vbo_position != 0;
|
||||
|
@ -59,20 +59,20 @@ namespace Switch_Toolbox.Library.Rendering
|
|||
GL.Enable(EnableCap.DepthTest);
|
||||
GL.DepthFunc(DepthFunction.Lequal);
|
||||
|
||||
control.CurrentShader = solidColorShaderProgram;
|
||||
control.CurrentShader = defaultShaderProgram;
|
||||
control.UpdateModelMatrix(Matrix4.Identity);
|
||||
|
||||
solidColorShaderProgram.EnableVertexAttributes();
|
||||
defaultShaderProgram.EnableVertexAttributes();
|
||||
|
||||
Vector3 topColor = ColorUtility.ToVector3(Runtime.backgroundGradientTop);
|
||||
Vector3 bottomColor = ColorUtility.ToVector3(Runtime.backgroundGradientBottom);
|
||||
|
||||
solidColorShaderProgram.SetVector4("topColor", new Vector4(topColor, 1.0f));
|
||||
solidColorShaderProgram.SetVector4("bottomColor", new Vector4(bottomColor, 1.0f));
|
||||
defaultShaderProgram.SetVector4("topColor", new Vector4(topColor, 1.0f));
|
||||
defaultShaderProgram.SetVector4("bottomColor", new Vector4(bottomColor, 1.0f));
|
||||
|
||||
BindBuffer();
|
||||
|
||||
solidColorShaderProgram.DisableVertexAttributes();
|
||||
defaultShaderProgram.DisableVertexAttributes();
|
||||
|
||||
GL.UseProgram(0);
|
||||
GL.Enable(EnableCap.CullFace);
|
||||
|
@ -114,8 +114,12 @@ namespace Switch_Toolbox.Library.Rendering
|
|||
GL.PopMatrix();
|
||||
}
|
||||
|
||||
private bool Initialized = false;
|
||||
public override void Prepare(GL_ControlModern control)
|
||||
{
|
||||
if (Initialized)
|
||||
return;
|
||||
|
||||
var solidColorFrag = new FragmentShader(
|
||||
@"#version 330
|
||||
uniform vec4 bottomColor;
|
||||
|
@ -139,7 +143,8 @@ namespace Switch_Toolbox.Library.Rendering
|
|||
gl_Position = vec4(position, 1);
|
||||
}");
|
||||
|
||||
solidColorShaderProgram = new ShaderProgram(solidColorFrag, solidColorVert, control);
|
||||
defaultShaderProgram = new ShaderProgram(solidColorFrag, solidColorVert, control);
|
||||
Initialized = true;
|
||||
}
|
||||
|
||||
public override void Prepare(GL_ControlLegacy control)
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Switch_Toolbox.Library.Rendering
|
|||
{
|
||||
public class DrawableXyzLines : AbstractGlDrawable
|
||||
{
|
||||
protected static ShaderProgram solidColorShaderProgram;
|
||||
ShaderProgram defaultShaderProgram;
|
||||
|
||||
int vbo_position;
|
||||
|
||||
|
@ -86,28 +86,25 @@ namespace Switch_Toolbox.Library.Rendering
|
|||
|
||||
public override void Draw(GL_ControlModern control, Pass pass)
|
||||
{
|
||||
if (!Runtime.OpenTKInitialized || pass == Pass.TRANSPARENT || solidColorShaderProgram == null)
|
||||
if (!Runtime.OpenTKInitialized || pass == Pass.TRANSPARENT)
|
||||
return;
|
||||
|
||||
bool buffersWereInitialized = vbo_position != 0;
|
||||
if (!buffersWereInitialized)
|
||||
UpdateVertexData();
|
||||
|
||||
if (!Runtime.OpenTKInitialized)
|
||||
return;
|
||||
|
||||
GL.UseProgram(0);
|
||||
GL.Disable(EnableCap.CullFace);
|
||||
GL.Disable(EnableCap.DepthTest);
|
||||
|
||||
control.CurrentShader = solidColorShaderProgram;
|
||||
control.CurrentShader = defaultShaderProgram;
|
||||
control.UpdateModelMatrix(Matrix4.Identity);
|
||||
|
||||
Matrix4 previewScale = Utils.TransformValues(Vector3.Zero, Vector3.Zero, Runtime.previewScale);
|
||||
|
||||
solidColorShaderProgram.EnableVertexAttributes();
|
||||
Draw(solidColorShaderProgram);
|
||||
solidColorShaderProgram.DisableVertexAttributes();
|
||||
defaultShaderProgram.EnableVertexAttributes();
|
||||
Draw(defaultShaderProgram);
|
||||
defaultShaderProgram.DisableVertexAttributes();
|
||||
|
||||
GL.UseProgram(0);
|
||||
GL.Enable(EnableCap.CullFace);
|
||||
|
@ -164,8 +161,12 @@ namespace Switch_Toolbox.Library.Rendering
|
|||
GL.Enable(EnableCap.Texture2D);
|
||||
}
|
||||
|
||||
private bool Initialized = false;
|
||||
public override void Prepare(GL_ControlModern control)
|
||||
{
|
||||
if (Initialized)
|
||||
return;
|
||||
|
||||
var solidColorFrag = new FragmentShader(
|
||||
@"#version 330
|
||||
in vec3 color;
|
||||
|
@ -189,7 +190,8 @@ namespace Switch_Toolbox.Library.Rendering
|
|||
gl_Position = mtxCam * mtxMdl * vec4(vPosition.xyz, 1);
|
||||
}");
|
||||
|
||||
solidColorShaderProgram = new ShaderProgram(solidColorFrag, solidColorVert, control);
|
||||
defaultShaderProgram = new ShaderProgram(solidColorFrag, solidColorVert, control);
|
||||
Initialized = true;
|
||||
}
|
||||
|
||||
public override void Prepare(GL_ControlLegacy control)
|
||||
|
|
Loading…
Add table
Reference in a new issue