public override void Run() { if (nop) { return; } //TODO: this could be more efficient (draw only in gap) GL.SetClearColor(Color.Black); GL.Clear(OpenTK.Graphics.OpenGL.ClearBufferMask.ColorBufferBit); FilterProgram.GuiRenderer.Begin(outputSize); GuiRenderer.SetBlendState(GL.BlendNoneCopy); //TODO: may depend on input, or other factors, not sure yet //watch out though... if we filter linear, then screens will bleed into each other. //so we will have to break them into render targets first. InputTexture.SetFilterNearest(); //draw screens bool renderTop = false; bool renderBottom = false; var settings = nds.GetSettings(); if (settings.ScreenLayout == MelonDS.ScreenLayoutKind.Bottom) { renderBottom = true; } if (settings.ScreenLayout == MelonDS.ScreenLayoutKind.Top) { renderTop = true; } if (settings.ScreenLayout == MelonDS.ScreenLayoutKind.Vertical) { renderTop = renderBottom = true; } if (settings.ScreenLayout == MelonDS.ScreenLayoutKind.Horizontal) { renderTop = renderBottom = true; } if (renderTop) { GuiRenderer.Modelview.Push(); GuiRenderer.Modelview.PreMultiplyMatrix(matTop); GuiRenderer.DrawSubrect(InputTexture, 0, 0, 256, 192, 0.0f, 0.0f, 1.0f, 0.5f); GuiRenderer.Modelview.Pop(); } if (renderBottom) { GuiRenderer.Modelview.Push(); GuiRenderer.Modelview.PreMultiplyMatrix(matBot); GuiRenderer.DrawSubrect(InputTexture, 0, 0, 256, 192, 0.0f, 0.5f, 1.0f, 1.0f); GuiRenderer.Modelview.Pop(); } GuiRenderer.End(); }
public void RenderString(IGuiRenderer renderer, float x, float y, string str) { int len = str.Length; for (int i = 0; i < len; i++) { Cyotek.Drawing.BitmapFont.Character c; if (!FontInfo.Characters.TryGetValue(str[i], out c)) c = FontInfo.Characters[unchecked((char)-1)]; //calculate texcoords (we shouldve already had this cached, but im speedcoding now) Texture2d tex = TexturePages[c.TexturePage]; float w = tex.Width; float h = tex.Height; float u0 = c.Bounds.Left / w; float v0 = c.Bounds.Top / h; float u1 = c.Bounds.Right / w; float v1 = c.Bounds.Bottom / h; float gx = x + c.Offset.X; float gy = y + c.Offset.Y; renderer.DrawSubrect(tex, gx, gy, c.Bounds.Width, c.Bounds.Height, u0, v0, u1, v1); x += c.XAdvance; } }
public void RenderString(IGuiRenderer renderer, float x, float y, string str) { int len = str.Length; for (int i = 0; i < len; i++) { Cyotek.Drawing.BitmapFont.Character c; if (!FontInfo.Characters.TryGetValue(str[i], out c)) { c = FontInfo.Characters[unchecked ((char)-1)]; } //calculate texcoords (we shouldve already had this cached, but im speedcoding now) Texture2d tex = TexturePages[c.TexturePage]; float w = tex.Width; float h = tex.Height; float u0 = c.Bounds.Left / w; float v0 = c.Bounds.Top / h; float u1 = c.Bounds.Right / w; float v1 = c.Bounds.Bottom / h; float gx = x + c.Offset.X; float gy = y + c.Offset.Y; renderer.DrawSubrect(tex, gx, gy, c.Bounds.Width, c.Bounds.Height, u0, v0, u1, v1); x += c.XAdvance; } }
public void RenderString(IGuiRenderer renderer, float x, float y, string str) { float ox = x; int len = str.Length; for (int i = 0; i < len; i++) { int c = str[i]; if (c == '\r') { if (i != len - 1 && str[i + 1] == '\n') { i++; } } if (c == '\r') { c = '\n'; } if (c == '\n') { x = ox; y += FontInfo.LineHeight; continue; } Cyotek.Drawing.BitmapFont.Character bfc; if (!FontInfo.Characters.TryGetValue((char)c, out bfc)) { bfc = FontInfo.Characters[unchecked ((char)-1)]; } // calculate texcoords (we shouldve already had this cached, but im speedcoding now) Texture2d tex = TexturePages[bfc.TexturePage]; float w = tex.Width; float h = tex.Height; float u0 = bfc.Bounds.Left / w; float v0 = bfc.Bounds.Top / h; float u1 = bfc.Bounds.Right / w; float v1 = bfc.Bounds.Bottom / h; float gx = x + bfc.Offset.X; float gy = y + bfc.Offset.Y; renderer.DrawSubrect(tex, gx, gy, bfc.Bounds.Width, bfc.Bounds.Height, u0, v0, u1, v1); x += bfc.XAdvance; } }
public void RenderString(IGuiRenderer renderer, float x, float y, string str) { float ox = x; int len = str.Length; for (int i = 0; i < len; i++) { var c = str[i]; if (c == '\r') { if (i != len - 1 && str[i + 1] == '\n') { i++; } } if (c == '\r') { c = '\n'; } if (c == '\n') { x = ox; y += FontInfo.LineHeight; continue; } var bfc = FontInfo[c]; // calculate texcoords (we shouldve already had this cached, but im speedcoding now) Texture2d tex = TexturePages[bfc.TexturePage]; float w = tex.Width; float h = tex.Height; sd.Rectangle bounds = new(bfc.X, bfc.Y, bfc.Width, bfc.Height); float u0 = bounds.Left / w; float v0 = bounds.Top / h; float u1 = bounds.Right / w; float v1 = bounds.Bottom / h; float gx = x + bfc.XOffset; float gy = y + bfc.YOffset; renderer.DrawSubrect(tex, gx, gy, bfc.Width, bfc.Height, u0, v0, u1, v1); x += bfc.XAdvance; } }