public override void Initialize(ContentManager Content) { base.Initialize(Content); CreateFramesFromXML("ui/ui_frames"); CurrentFrame = "levelbutton"; ResetDimensions(); UniformScale = 0.8f * ScaleFactor / Camera.Get.UniformWorldScale; Colour = new Color(1, 1, 1, 0); text = new TextDrawer("ui/LevelFont"); text.Initialize(Content); text.Text = Level.ToString(); if (!ChicksnVixensGame.Get.LevelUnlocked(location, Level)) { text.Text = "X"; padLock.Initialize(Content); padLock.CreateFramesFromXML("ui/ui_frames"); padLock.CurrentFrame = "lock"; padLock.ResetDimensions(); padLock.UniformScale = ScaleFactor; } stars = new Sprite("ui/ui"); stars.Initialize(Content); stars.CreateFramesFromXML("ui/ui_frames"); stars.CurrentFrame = "star"; stars.ResetDimensions(); stars.UniformScale = ScaleFactor * 0.3f; }
public override void Draw(Graphics graphics) { if (graphics == null) { throw new ArgumentNullException("graphics"); } using (Brush b = new SolidBrush(this.BackColor)){ graphics.FillRectangle(b, base.DrawingRectangle); } StringTrimming designTrimmimg = StringTrimming.EllipsisCharacter; if (this.stringTrimming != StringTrimming.None) { designTrimmimg = stringTrimming; } StringFormat stringFormat = TextDrawer.BuildStringFormat(designTrimmimg, contentAlignment); if (this.RightToLeft == System.Windows.Forms.RightToLeft.Yes) { stringFormat.FormatFlags = stringFormat.FormatFlags | StringFormatFlags.DirectionRightToLeft; } TextDrawer.DrawString(graphics, this.Text, this.Font, new SolidBrush(this.ForeColor), this.ClientRectangle, stringFormat); base.DrawControl(graphics, base.DrawingRectangle); }
public override void Start() { inventory = FindObjectOfType <Inventory>(); player = FindObjectOfType <Player>(); textDrawer = FindObjectOfType <TextDrawer>(); base.Start(); }
protected override void Draw(GameTime dt) { if (drawer == null) { drawer = new TextDrawer("font"); drawer.Initialize(Content); } ScreenManager.Get.Draw(); base.Draw(dt); spriteBatch.Begin(); int milliSeconds = watch.Elapsed.Milliseconds; drawer.Text = ((int)(1000.0f / watch.ElapsedMilliseconds)).ToString(); drawer.Text = ((int)(1000.0f / dt.ElapsedGameTime.Milliseconds)).ToString(); drawer.DrawIn = BaseSprite.DrawSpace.SCREENSPACE; drawer.PosX = 0.1f; drawer.PosY = 0.1f; //drawer.Draw(); watch.Stop(); watch.Reset(); spriteBatch.End(); AdSystem.Draw(); }
private void Update() { var currentPos = MinimumPosition; for (var i = 0; i < Amount; i++) { var pos = currentPos; pos.y += (Mathf.Sin((Time.time + i) * VetticalPosDIsplacementSpeedFactor) * VerticalPosDisplacementFactor); var lerpFactor = Mathf.Sin(Time.time + i); var color = Color.Lerp(GreenColor, BlueColor, lerpFactor); if (lerpFactor < 0.0f) { color = Color.Lerp(GreenColor, RedColor, -lerpFactor); } TextDrawer.DrawText(_letters[i % _letters.Count], TextSize, color, Matrix4x4.TRS(pos, Quaternion.LookRotation(Vector3.up, Vector3.forward), Vector3.one), Fonts[i % Fonts.Length]); currentPos.x += PositionIncrement.x; if (currentPos.x > MaximumPosition.x) { currentPos.x = MinimumPosition.x; currentPos.z += PositionIncrement.z; } } }
public DebugFpsHelper(GraphicsDevice graphics) { stopWatch = new Stopwatch(); textDrawer = new TextDrawer(graphics); floatSmoother = new FloatSmoother(60); stopWatch.Start(); }
public void DrawString(string text, int fontsize = 24) { //For now this is a refernce for the positions of gui texts, may vary based on fontsize //left -65 //right 90 //top 70 //bottom -80 ((GUIRenderState)actor.RenderState).Texture = TextDrawer.RenderString(text, Color4.White, fontsize); }
/// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); titleFont.Dispose(); TextDrawer.Dispose(); } base.Dispose(disposing); }
public void SetName(int index, string name) { if (scoreName[index] != null) { scoreName[index].Dispose(); } scoreName[index] = new TextDrawer(1000, 1000); scoreName[index].Write(name, 0.5f, 1f, 1f, System.Drawing.StringAlignment.Center, System.Drawing.StringAlignment.Far); scoreName[index].UpdateTexture(); }
public void TextDrawerConstructorTest() { SpriteFont font = null; // TODO: Initialize to an appropriate value string text = string.Empty; // TODO: Initialize to an appropriate value Vector2 position = new Vector2(); // TODO: Initialize to an appropriate value Color color = new Color(); // TODO: Initialize to an appropriate value TextAlign align = new TextAlign(); // TODO: Initialize to an appropriate value TextDrawer target = new TextDrawer(font, text, position, color, align); Assert.Inconclusive("TODO: Implement code to verify target"); }
private void Awake() { _instance = this; _instanced = true; DontDestroyOnLoad(gameObject); _textMeshPro = gameObject.AddComponent <TextMeshPro>(); _textMeshPro.alignment = TextAlignmentOptions.Center; _textMeshPro.GetComponent <MeshRenderer>().enabled = false; _materialPropertyBlock = new MaterialPropertyBlock(); _materialTextColorPropertyId = Shader.PropertyToID("_FaceColor"); _defaultFontAsset = _textMeshPro.font; }
public GamePlayState(Game game, Player player, List <Character> worldObjects) : base(game) { this.map = new Map(); Tile.TileSetTexture = Game1.Content.Load <Texture2D>(@"Tiles\tileset"); this.worldObjects = worldObjects; Rnd = new Random(); this.EnemySpawn(EnemyCount); this.player = player; this.defaultFont = Game1.Content.Load <SpriteFont>("Fonts\\Arial"); this.textDrawer = new TextDrawer(this.defaultFont); }
private void InitializeTextDrawer() { var desc = new TextDrawerDescription() { Name = "Text", Font = "Viner Hand ITC", FontSize = 18, Style = FontMapStyles.Bold, TextColor = Color.LightGoldenrodYellow, }; textDrawer = this.AddComponent <TextDrawer>(desc, SceneObjectUsages.UI, layerHUD).Instance; }
public GUIText(Vector2 pos, string text = "", int fontsize = 24) { //Set up Actor actor = new Actor(); actor.AddComponent(new Body()); //Set up the GUIRenderState for the Actor texture = TextDrawer.RenderString(text, Color4.White, fontsize); GUIRenderState guiRState = new GUIRenderState(texture); guiRState.Scale = new Vector2(2.5f, 1); actor.AddComponent(guiRState); }
public void DrawTest() { SpriteFont font = null; // TODO: Initialize to an appropriate value string text = string.Empty; // TODO: Initialize to an appropriate value Vector2 position = new Vector2(); // TODO: Initialize to an appropriate value Color color = new Color(); // TODO: Initialize to an appropriate value TextAlign align = new TextAlign(); // TODO: Initialize to an appropriate value TextDrawer target = new TextDrawer(font, text, position, color, align); // TODO: Initialize to an appropriate value SpriteBatch sb = null; // TODO: Initialize to an appropriate value target.Draw(sb); Assert.Inconclusive("A method that does not return a value cannot be verified."); }
public void originTest() { SpriteFont font = null; // TODO: Initialize to an appropriate value string text = string.Empty; // TODO: Initialize to an appropriate value Vector2 position = new Vector2(); // TODO: Initialize to an appropriate value Color color = new Color(); // TODO: Initialize to an appropriate value TextAlign align = new TextAlign(); // TODO: Initialize to an appropriate value TextDrawer target = new TextDrawer(font, text, position, color, align); // TODO: Initialize to an appropriate value Vector2 actual; actual = target.origin; Assert.Inconclusive("Verify the correctness of this test method."); }
private void Awake() { if (Input == null) { Input = this; } else { Destroy(this); } textDrawer = GetComponent <TextDrawer>(); RefreshText(); }
public void CropToEdgeSingleTest() { var fontName = "Adobe Devanagari"; var letter = "7"; int fontSize = 50; var textDrawer = new TextDrawer(); var font = new Font(fontName, fontSize); //draw image var bmp = (Bitmap)textDrawer.DrawTextOnImage(letter, font, Color.Black, Color.White); //crop to edge - the main method under test here var bmpCrop = bmp.CropImageToEdge(letter); bmp.Save(Guid.NewGuid() + ".jpg"); bmpCrop.Save(Guid.NewGuid() + ".jpg"); CropEdgeAssert(bmp, bmpCrop, fontName, letter, true); }
public void SaveOneImage(string txt, string fileName, FontData fontdata, string imagePath, List <ImageDecorator> imgDecorators = null) { var image = new ImageData { Text = txt }; var drawer = new TextDrawer(); var font = fontdata.GetFont(); using (image.bitmap = drawer.DrawTextOnImage(txt, font, Color.Black, Color.White) as Bitmap) { if (imgDecorators != null) { foreach (var dec in imgDecorators) { image.bitmap = dec.DecorateImage(image.bitmap); } } image.bitmap.Save($"{imagePath}/{fileName}.jpg"); } }
public override void Draw(Graphics graphics) { if (graphics == null) { throw new ArgumentNullException("graphics"); } using (Brush b = new SolidBrush(this.BackColor)){ graphics.FillRectangle(b, base.DrawingRectangle); } string s = String.Format(System.Globalization.CultureInfo.CurrentCulture, "Error : <{0}> is missing or obsolete", base.Text); StringFormat stringFormat = TextDrawer.BuildStringFormat(base.StringTrimming, base.ContentAlignment); TextDrawer.DrawString(graphics, s, this.Font, new SolidBrush(Color.Red), this.ClientRectangle, stringFormat); base.DrawControl(graphics, base.DrawingRectangle); }
protected override void LoadContent() { dataFont = Content.Load <SpriteFont>("DataFont"); tinyFont = Content.Load <SpriteFont>("TinyFont"); controlsMenu = Content.Load <Texture2D>("bepuphysicscontrols"); IsFixedTimeStep = false; LineDrawer = new BasicEffect(GraphicsDevice); UIDrawer = new SpriteBatch(GraphicsDevice); DataTextDrawer = new TextDrawer(UIDrawer, dataFont, Color.White); TinyTextDrawer = new TextDrawer(UIDrawer, tinyFont, Color.White); #if WINDOWS Mouse.SetPosition(200, 200); //This helps the camera stay on track even if the mouse is offset during startup. #endif SwitchSimulation(1); }
public override void Draw(Graphics graphics) { if (graphics == null) { throw new ArgumentNullException("graphics"); } using (var backgroundBrush = new SolidBrush(this.BackColor)){ graphics.FillRectangle(backgroundBrush, base.DrawingRectangle); } var designTrimmimg = StringTrimming.EllipsisCharacter; if (stringTrimming != StringTrimming.None) { designTrimmimg = stringTrimming; } stringFormat = TextDrawer.BuildStringFormat(designTrimmimg, contentAlignment); using (var textBrush = new SolidBrush(ForeColor)) { TextDrawer.DrawString(graphics, Text, Font, textBrush, ClientRectangle, stringFormat); } DrawControl(graphics, base.DrawingRectangle); }
public CTFMap(int id, string filename) : base(id, filename, GameMode.CaptureTheFlag) { text = new TextDrawer(1000, 1000); mesh = new Mesh(text); roundTimerText = new TextDrawer(1000, 1000); roundTimerMesh = new Mesh(roundTimerText); roundTimerMesh.Orthographic = true; roundTimerMesh.Translate(0.5f, -0.04f); roundTimerMesh.Scale(0.2f); scoreText = new TextDrawer(500, 500); scoreMesh = new Mesh(scoreText); scoreMesh.Orthographic = true; scoreMesh.Translate(0.5f, -0.08f); scoreMesh.Scale(0.1f); UpdateScoreText(); }
public override void Draw(Graphics graphics) { StringTrimming designTrimmimg = StringTrimming.EllipsisCharacter; if (graphics == null) { throw new ArgumentNullException("graphics"); } using (Brush b = new SolidBrush(this.BackColor)){ graphics.FillRectangle(b, base.DrawingRectangle); } if (this.stringTrimming != StringTrimming.None) { designTrimmimg = stringTrimming; } TextDrawer.DrawString(graphics, this.Text, this.Font, new SolidBrush(this.ForeColor), this.ClientRectangle, designTrimmimg, this.contentAlignment); base.DrawControl(graphics, base.DrawingRectangle); }
protected override void OnLoad() { // The font factory allows us to extract the font information and construct a font texture using the // System.Drawing library. var systemFont = new System.Drawing.Font(FontFamily.GenericSansSerif, 64, GraphicsUnit.Pixel); var(textureData, font) = FontFactory.From(systemFont, 1); fontTexture = textureData.ToTexture(t => { t.SetFilterMode(TextureMinFilter.LinearMipmapLinear, TextureMagFilter.Nearest); t.GenerateMipmap(); }); // We set up a mesh builder, and renderer as usual. We bind the font texture from the font loading into the // shader. meshBuilder = new ExpandingIndexedTrianglesMeshBuilder <UVVertexData>(); var renderable = meshBuilder.ToRenderable(); shaderProgram = ShaderProgram.FromShaders( ShaderFactory.Vertex.FromFile("text.vs"), ShaderFactory.Fragment.FromFile("text.fs")); renderer = BatchedRenderer.From(renderable, shaderProgram, new TextureUniform("fontTexture", TextureUnit.Texture0, fontTexture)); // The text drawer is a helper class to help us draw text assuming that it will be rendered with the right // font texture bound. var textDrawer = new TextDrawer <UVVertexData, Void>(font, meshBuilder, (p, uv, _) => new UVVertexData(p, uv)); textDrawer.DrawLine( Vector3.Zero, "Hello World!", 64, 0.5f, 0.5f, Vector3.UnitX * 2 / 1280, -Vector3.UnitY * 2 / 720, default); }
public override void Initialize(Microsoft.Xna.Framework.Content.ContentManager content) { base.Initialize(content); BlankNess n = new BlankNess(); n.Initialize(Content); n.RaiseFlag(Jabber.Flags.FADE_IN); n.fullBlankity = 0.25f; Components.Add(n); if (gameplay.GetRemainingFox() == 0) { MenuObj logo = new MenuObj("ui/ui"); logo.Initialize(Content); logo.CreateFramesFromXML("ui/ui_frames"); logo.CurrentFrame = "cannonfire"; logo.ResetDimensions(); logo.UniformScale = ScaleFactor; logo.PosX = 0.1f * BaseGame.Get.BackBufferWidth; logo.PosY = 0.1f * BaseGame.Get.BackBufferHeight; logo.PosY -= 0.1f * BaseGame.Get.BackBufferHeight; logo.Colour = Color.White * 0.5f; Components.Add(logo); } else { MenuObj logo = new MenuObj("ui/ui"); logo.Initialize(Content); logo.CreateFramesFromXML("ui/ui_frames"); logo.CurrentFrame = "chickenincannon"; logo.ResetDimensions(); logo.UniformScale = ScaleFactor; logo.Colour = Color.White * 0.5f; logo.PosY -= 0.1f * BaseGame.Get.BackBufferHeight; Components.Add(logo); } ThinBlackLine b = new ThinBlackLine(); b.Initialize(Content); Components.Add(b); Button restart = new FadeInButton(); restart.Initialize(Content); restart.CreateFramesFromXML("ui/ui_frames"); restart.CurrentFrame = "restart"; restart.ResetDimensions(); restart.Colour = Color.LightGreen; restart.RegularScale = ScaleFactor / 2.0f; restart.ScaleOnHover = restart.RegularScale * 1.1f; restart.PosY = -BaseGame.Get.HalfBackBufferHeight * 0.5f; Components.Add(restart); if (gameplay.GetRemainingFox() == 0) { restart = new FadeInButton(); restart.Initialize(Content); restart.CreateFramesFromXML("ui/ui_frames"); restart.CurrentFrame = "doublearrow"; restart.ResetDimensions(); restart.Colour = Color.LightBlue; restart.RegularScale = ScaleFactor / 2.0f; restart.ScaleOnHover = restart.RegularScale * 1.1f; restart.PosX = BaseGame.Get.BackBufferWidth * 0.14f; restart.PosY = -BaseGame.Get.HalfBackBufferHeight * 0.5f; Components.Add(restart); } restart = new FadeInButton(); restart.Initialize(Content); restart.CreateFramesFromXML("ui/ui_frames"); restart.CurrentFrame = "quit"; restart.ResetDimensions(); restart.Colour = Color.Red * 0.8f; restart.RegularScale = ScaleFactor / 2.0f; restart.ScaleOnHover = restart.RegularScale * 1.1f; restart.PosX = -BaseGame.Get.BackBufferWidth * 0.14f; restart.PosY = -BaseGame.Get.HalfBackBufferHeight * 0.5f; Components.Add(restart); TextDrawer text = new TextDrawer("ui/LevelFont"); text.Handle = BaseSprite.SpriteHandle.CENTER; text.Initialize(Content); text.Text = "Best: " + ChicksnVixensGame.Get.GetLevelState(gameplay.location, gameplay.levelNum).Score; text.PosX = 0 * BaseGame.Get.BackBufferWidth; text.PosY = 0.1f * BaseGame.Get.BackBufferHeight; text.UniformScale = ScaleFactor * 0.7f; Components.Add(text); text = new TextDrawer("ui/LevelFont"); text.Handle = BaseSprite.SpriteHandle.CENTER; text.Initialize(Content); text.Text = "Score: " + gameplay.score.score.ToString(); text.Colour = Color.OrangeRed; text.UniformScale = ScaleFactor; text.PosX = 0; text.PosY = 0.175f * BaseGame.Get.BackBufferHeight; Components.Add(text); StarDrawer s = new StarDrawer(gameplay.NumStars); s.Initialize(Content); Components.Add(s); Donut.Initialize(Content); Donut.CreateFramesFromXML("misc_frames"); Donut.CurrentFrame = "donut"; Donut.ResetDimensions(); Donut.UniformScale = ScaleFactor; Donut.PosY = -0.06f * BaseGame.Get.BackBufferHeight; Donut.Colour = Color.White * 0.4f; Components.Add(Donut); text = new TextDrawer("ui/LevelFont"); text.Handle = BaseSprite.SpriteHandle.CENTER; text.Initialize(Content); text.Text = "Donuts: " + gameplay.donutScore.TargetScore; text.Colour = Color.OrangeRed; text.UniformScale = ScaleFactor; text.PosX = 0; text.PosY = -0.025f * BaseGame.Get.BackBufferHeight; Components.Add(text); text = new TextDrawer("ui/LevelFont"); text.Handle = BaseSprite.SpriteHandle.CENTER; text.Initialize(Content); text.Text = "Best: " + ChicksnVixensGame.Get.GetLevelState(gameplay.location, gameplay.levelNum).NumDonuts; text.UniformScale = ScaleFactor * 0.7f; text.PosX = 0; text.PosY = -0.1f * BaseGame.Get.BackBufferHeight; Components.Add(text); }
public override void DrawItem(Graphics graphics) { base.DrawItem(graphics); base.Decorate(graphics); TextDrawer.DrawString(graphics, this.text, this.StyleDecorator); }
public override void Initialize(ContentManager content) { base.Initialize(content); blank = new BlankNess(); blank.Initialize(Content); blank.RaiseFlag(Flags.FADE_IN); blank.fullBlankity = 0.85f; blank.fadeSpeed = 4.0f; Components.Add(blank); VolumeControl v = new VolumeControl(AudioManager.MusicVolume); v.Initialize(Content); v.Name = "MusicVol"; v.CurrentVolume = AudioManager.MusicVolume; v.PosY = 100.0f * ScaleFactor; Components.Add(v); TextDrawer text = new TextDrawer("ui/LevelFont"); text.Initialize(Content); text.Text = "Music Volume"; text.Colour = Color.Gold; if (!AudioManager.IsMusicAllowed) { text.Text = "Music Disabled"; text.Colour = Color.Red; v.Disabled = true; v.CurrentVolume = 0; } text.Position = v.Position; text.UniformScale = ScaleFactor; Components.Add(text); v = new VolumeControl(AudioManager.SoundVolume); v.Initialize(Content); v.Name = "SoundVol"; v.CurrentVolume = AudioManager.SoundVolume; v.PosY = 0 * ScaleFactor; v.PlayTickWhenDone = true; Components.Add(v); text = new TextDrawer("ui/LevelFont"); text.Initialize(Content); text.Text = "Sound Volume"; text.Colour = Color.Gold; text.Position = v.Position; text.UniformScale = ScaleFactor; Components.Add(text); Button back = new Button("ui/ui"); back.Initialize(Content); back.CreateFramesFromXML("ui/ui_frames"); back.CurrentFrame = "quit"; back.ResetDimensions(); back.UniformScale = ScaleFactor * 0.001f; back.RegularScale = ScaleFactor * 0.5f; back.ScaleOnHover = ScaleFactor * 0.55f; back.Colour = Color.Red; back.Effect = BaseSprite.SpriteEffect.FLIPHORIZONTAL; back.PosX = 0.40f * BaseGame.Get.BackBufferWidth; back.PosY = 0.40f * BaseGame.Get.BackBufferHeight; back.PlaySFXOnRelease = "Sounds/PlayStateSelect"; Components.Add(back); arrowToggle = new Button("ui/ui"); arrowToggle.CreateFramesFromXML("ui/ui_frames"); arrowToggle.Initialize(Content); arrowToggle.CurrentFrame = "levelbutton"; arrowToggle.ResetDimensions(); arrowToggle.RegularScale = ScaleFactor * 1.5f; arrowToggle.ScaleOnHover = arrowToggle.RegularScale * 1.1f; arrowToggle.PosX = 0 * BaseGame.Get.BackBufferWidth; arrowToggle.PosY = -0.45f * BaseGame.Get.HalfBackBufferHeight; if (ChicksnVixensGame.Get.UseTrajectory) { arrowToggle.SetText("Trajectory", "ui/Play"); } else { arrowToggle.SetText("Arrow", "ui/Play"); } arrowToggle.Text.Colour = Color.Black; arrowToggle.PlaySFXOnRelease = "Sounds/PlayStateSelect"; arrowToggle.TextScaler = 0.65f; arrowToggle.UniformScale = arrowToggle.RegularScale; Components.Add(arrowToggle); }
private void LateUpdate() { TextDrawer.DrawText("Pivot", 12f, Color.white, transform.localToWorldMatrix, Pivot); }
public static void Run() { ShaderProgram prog = null, terrProg = null; Texture tex = null, t2 = null; GraphicsContext context = new GraphicsContext() { Camera = new FirstPersonCamera(new Vector3(4, 3, 3), Vector3.UnitY) }; BitmapTextureSource bmpTex, b2, b3; bmpTex = TextDrawer.CreateWriter("Times New Roman", FontStyle.Regular).Write("Hello!", 200, System.Drawing.Color.White); b2 = new BitmapTextureSource("test.jpg", 0); b3 = new BitmapTextureSource("test.png", 0); Texture fbufTex = null, t3 = null; FramebufferTextureSource fbufTexSrc = new FramebufferTextureSource(256, 256, 0); Framebuffer fbuf = null; Matrix4 World = Matrix4.Identity; EngineObject eObj = null, fsq = null; float timer = 0; CubeMapTextureSource tFace = new CubeMapTextureSource(CubeMapTextureSource.CubeMapFace.PositiveY, b3), bFace = new CubeMapTextureSource(CubeMapTextureSource.CubeMapFace.PositiveX, b3), lFace = new CubeMapTextureSource(CubeMapTextureSource.CubeMapFace.PositiveZ, b3), rFace = new CubeMapTextureSource(CubeMapTextureSource.CubeMapFace.NegativeX, b3), fFace = new CubeMapTextureSource(CubeMapTextureSource.CubeMapFace.NegativeY, b3), hFace = new CubeMapTextureSource(CubeMapTextureSource.CubeMapFace.NegativeZ, b3); GraphicsDevice.Load += () => { // setup settings, load textures, sounds GraphicsDevice.Wireframe = false; GraphicsDevice.AlphaEnabled = true; GraphicsDevice.DepthTestEnabled = true; GraphicsDevice.CullEnabled = false; GraphicsDevice.CullMode = CullFaceMode.Back; eObj = new EngineObject(); float[] data = { -1, -1, 1, 1, -1, 1, 0, 1, 1 }; uint[] indexData = new uint[] { 0, 1, 2 }; ShaderSource vert = ShaderSource.Load(ShaderType.VertexShader, "Testing/TG_A/vertex.glsl"); ShaderSource frag = ShaderSource.Load(ShaderType.FragmentShader, "Testing/TG_A/fragment.glsl"); ShaderSource tctrl = ShaderSource.Load(ShaderType.TessControlShader, "Testing/TG_A/tesscontrol.glsl"); ShaderSource teval = ShaderSource.Load(ShaderType.TessEvaluationShader, "Testing/TG_A/tessdomain.glsl"); ShaderSource vA = ShaderSource.Load(ShaderType.VertexShader, "Shaders/TerrainGen/vertex.glsl"); ShaderSource fA = ShaderSource.Load(ShaderType.FragmentShader, "Shaders/TerrainGen/fragment.glsl"); terrProg = new ShaderProgram(vA, fA); terrProg.Set("World", Matrix4.Identity); fbuf = new Framebuffer(256, 256); fbufTex = new Texture(); fbufTex.SetData(fbufTexSrc); fbuf[FramebufferAttachment.ColorAttachment0] = fbufTex; fsq = FullScreenQuadFactory.Create(); t3 = new Texture(); t3.SetData(tFace); t3.SetData(bFace); t3.SetData(lFace); t3.SetData(rFace); t3.SetData(fFace); t3.SetData(hFace); t3.SetEnableLinearFilter(true); t3.SetAnisotropicFilter(Texture.MaxAnisotropy); tex = new Texture(); tex.SetData(bmpTex); tex.SetAnisotropicFilter(Texture.MaxAnisotropy); t2 = new Texture(); t2.SetData(b3); t2.SetAnisotropicFilter(Texture.MaxAnisotropy); prog = new ShaderProgram(vert, tctrl, teval, frag); prog.Set("img", 0); prog.Set("heightmap", 1); prog.Set("World", World); vert.Dispose(); frag.Dispose(); tctrl.Dispose(); teval.Dispose(); //eObj = FullScreenQuadFactory.Create(); eObj = CubeFactory.Create(); eObj.SetTexture(0, t2); eObj.SetTexture(1, t3); b3.Dispose(); }; bool eyePosStill = false; GraphicsDevice.Update += (e) => { // add game logic, input handling if (GraphicsDevice.Keyboard[Key.Escape]) { GraphicsDevice.Exit(); } if (GraphicsDevice.Keyboard[Key.Z]) { GraphicsDevice.Wireframe = !GraphicsDevice.Wireframe; //GraphicsDevice.CullEnabled = !GraphicsDevice.Wireframe; } if (GraphicsDevice.Keyboard[Key.F]) { eyePosStill = !eyePosStill; Console.WriteLine("EyePosStill = " + eyePosStill); } context.Update(e); //context.Projection = Matrix4.Identity; //context.View = Matrix4.Identity; prog.Set("View", context.View); prog.Set("Proj", context.Projection); if (!eyePosStill) { prog.Set("eyePos", context.Camera.Position); } prog.Set("Fcoef", (float)(2.0f / Math.Log(1000001) / Math.Log(2))); //timer += 0.001f; //World = Matrix4.RotateY(timer); World = Matrix4.CreateScale(10); prog.Set("World", World); prog.Set("timer", timer); terrProg.Set("timer", timer); }; bool te1 = false; GraphicsDevice.Render += (e) => { GraphicsDevice.SetFramebuffer(fbuf); GraphicsDevice.Clear(); fsq.Bind(); GraphicsDevice.SetShaderProgram(terrProg); GraphicsDevice.SetViewport(0, 0, 256, 256); GraphicsDevice.Draw(PrimitiveType.Triangles, 0, fsq.IndexCount); eObj.Bind(); GraphicsDevice.SetShaderProgram(prog); GraphicsDevice.SetViewport(0, 0, GraphicsDevice.WindowSize.Width, GraphicsDevice.WindowSize.Height); GraphicsDevice.PatchCount = 3; GraphicsDevice.Draw(PrimitiveType.Patches, 0, eObj.IndexCount); GraphicsDevice.SwapBuffers(); if (!te1) { te1 = true; GraphicsDevice.SaveTexture(fbufTex, "test1.png"); } }; GraphicsDevice.Name = "The Julis Faction"; // Run the game at 60 updates per second GraphicsDevice.Run(60.0, 60.0); if (GraphicsDevice.Cleanup != null) { GraphicsDevice.Cleanup(); } }