public void DisplayLevel(int level) { int characterStart = 30; int characterSpacing = 15; Vector3 displayPosition = new Vector3((float)this.Width / 2 - characterStart, (float)this.Height / 2, 0f); int digit; NixieSprite nixie = new NixieSprite(nixiesTileSet); //Render the level indicator device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0); device.BeginScene(); using (D3D.Sprite d3dSprite = new D3D.Sprite(device)) { d3dSprite.Begin(D3D.SpriteFlags.AlphaBlend); //Show the letter L nixie.Draw(d3dSprite, NixieSprite.NixieCharacters.L, displayPosition); //Show the letter E displayPosition.X -= characterSpacing; nixie.Draw(d3dSprite, NixieSprite.NixieCharacters.E, displayPosition); //Show the letter V displayPosition.X -= characterSpacing; nixie.Draw(d3dSprite, NixieSprite.NixieCharacters.V, displayPosition); //Show the letter E displayPosition.X -= characterSpacing; nixie.Draw(d3dSprite, NixieSprite.NixieCharacters.E, displayPosition); //Show the letter L displayPosition.X -= characterSpacing; nixie.Draw(d3dSprite, NixieSprite.NixieCharacters.L, displayPosition); displayPosition.X = (float)this.Width / 2 + 40; for (int digitCount = 1; digitCount <= maxLevelDigits; digitCount++) { digit = level % 10; level /= 10; nixie.Draw(d3dSprite, (NixieSprite.NixieCharacters)digit, displayPosition); displayPosition.X -= characterSpacing; } d3dSprite.End(); } device.EndScene(); device.Present(); Thread.Sleep(3000); //wait for 3 seconds }
public void RenderOnScreen(Microsoft.DirectX.Direct3D.Device d3dDevice, float elapsedTime) { d3dDevice.BeginScene(); //Cargamos para renderizar el unico modelo que tenemos, un Quad que ocupa toda la pantalla, con la textura de todo lo dibujado antes d3dDevice.VertexFormat = CustomVertex.PositionTextured.Format; d3dDevice.SetStreamSource(0, screenQuadVB, 0); //Ver si el efecto de alarma esta activado, configurar Technique del shader segun corresponda //Cargamos parametros en el shader de Post-Procesado this.postProcessMerge.SetValue("escenaTextura", this.escena); if (cant_pasadas == 0) { this.postProcessMerge.SetValue("propulsoresTextura", this.propulsores); } else { this.postProcessMerge.SetValue("propulsoresTextura", this.propulsoresBlurAux2); } this.postProcessMerge.Technique = "TechniqueMerge"; //Limiamos la pantalla y ejecutamos el render del shader d3dDevice.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0); this.postProcessMerge.Begin(FX.None); this.postProcessMerge.BeginPass(0); d3dDevice.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2); this.postProcessMerge.EndPass(); this.postProcessMerge.End(); //DrawText.drawText("Desfase: " + TGCVector3.PrintVector3(desfase), 0, 500, Color.White); //Terminamos el renderizado de la escena RenderFPS(); RenderAxis(); d3dDevice.EndScene(); d3dDevice.Present(); }
public static void Render() { if (!dGDevice.Disposed) { dGDevice.Clear(ClearFlags.Target, System.Drawing.Color.Black, 1.0f, 0); dGDevice.BeginScene(); m_ZOrderedSprites.Sort(Sprite.ComparisonZOrder); foreach (Sprite s in m_ZOrderedSprites) { s.Render(); } foreach (Text2D t in m_Text2Ds) { t.Render(); } dGDevice.EndScene(); dGDevice.Present(); } else { Quit(); } }
/// <summary> /// 将在Render中准备好的内容绘制到viewport。旧的内容不会被自动清理 /// </summary> public static void Present() { Device.BeginScene(); Render.Invoke(); Device.EndScene(); Device.Present(); }
/// <summary> /// 用单一颜色覆盖整个viewport /// </summary> /// <param name="color">指定的颜色</param> public static void ClearDevice(Color color) { Device.BeginScene(); Device.Clear(ClearFlags.Target, color, 1f, 0); Device.EndScene(); Device.Present(); }
void Render() { m_d3DDevice.BeginScene(); // Render target needs to be set to 640x360 for optimal scaling. However the pixel coordinates for // Direct3D 9 render target is actually (-0.5,-0.5) to (639.5,359.5). As such the Viewport is set // to 639x359 to account for the pixel coordinate offset of render target tagRECT rect; rect.top = m_d3DDevice.Viewport.Y; rect.left = m_d3DDevice.Viewport.X; rect.bottom = m_d3DDevice.Viewport.Y + m_d3DDevice.Viewport.Height; rect.right = m_d3DDevice.Viewport.X + m_d3DDevice.Viewport.Width; m_previewHelper.Render(rect); // Draw the timecode top-center with a slight drop-shadow Rectangle rc = m_d3DFont.MeasureString(null, m_timeCodeString, Direct3D.DrawTextFormat.Center, Color.Black); int x = (m_d3DDevice.Viewport.Width / 2) - (rc.Width / 2); int y = 10; m_d3DFont.DrawText(null, m_timeCodeString, x + 1, y + 1, Color.Black); m_d3DFont.DrawText(null, m_timeCodeString, x, y, Color.White); m_d3DDevice.EndScene(); m_d3DDevice.Present(); }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { ReadMouse(); ReadKeyboard(); d3ddevice.Clear(ClearFlags.Target | ClearFlags.ZBuffer, System.Drawing.Color.Cyan, 1.0f, 0); //theta += Geometry.DegreeToRadian(1); d3ddevice.BeginScene(); d3ddevice.Transform.World = Matrix.Translation(-spacing - .5f, -spacing - .5f, -spacing - .5f); for (int x = 0; x < 3; x++) { for (int y = 0; y < 3; y++) { for (int z = 0; z < 3; z++) { rubixCube.GetBlock(x, y, z).draw(x * spacing, y * spacing, z * spacing); } } } d3ddevice.EndScene(); PositionCamera(); d3ddevice.Present(); this.Invalidate(); }
/// <summary> /// 使用指定颜色清理viewport,然后绘制在Render中准备好的内容 /// </summary> public static void Present(Color color) { Device.BeginScene(); Device.Clear(ClearFlags.Target, color, 1f, 0); Render.Invoke(); Device.EndScene(); Device.Present(); }
public void Render() { device.Clear(ClearFlags.Target, Color.DarkSlateGray, 1, 0); device.BeginScene(); device.VertexFormat = CustomVertex.PositionNormalColored.Format; device.DrawUserPrimitives(PrimitiveType.TriangleList, vertex.Length / 3, vertex); device.EndScene(); device.Present(); }
private void MainForm_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { try { if (dxEnable) { device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0); device.BeginScene(); obj.Draw(device, worldMatrix); device.Transform.World = worldMatrix; LineTo(ref device, new Vector3(0, 0, -1), new Vector3(0, 0, 1), Color.Blue); LineTo(ref device, new Vector3(1, 0, -1), new Vector3(1, 0, 1), Color.Blue); LineTo(ref device, new Vector3(-1, 0, -1), new Vector3(-1, 0, 1), Color.Blue); LineTo(ref device, new Vector3(0.5f, 0, -1), new Vector3(0.5f, 0, 1), Color.Blue); LineTo(ref device, new Vector3(-0.5f, 0, -1), new Vector3(-0.5f, 0, 1), Color.Blue); LineTo(ref device, new Vector3(0, -1, 0), new Vector3(0, 1, 0), Color.Red); LineTo(ref device, new Vector3(-1, 0, 0), new Vector3(1, 0, 0), Color.Blue); LineTo(ref device, new Vector3(-1, 0, 1), new Vector3(1, 0, 1), Color.Blue); LineTo(ref device, new Vector3(-1, 0, 0.5f), new Vector3(1, 0, 0.5f), Color.Blue); LineTo(ref device, new Vector3(-1, 0, -1), new Vector3(1, 0, -1), Color.Blue); LineTo(ref device, new Vector3(-1, 0, -0.5f), new Vector3(1, 0, -0.5f), Color.Blue); device.EndScene(); device.Present(); this.Invalidate(); if (bDrawObj) { obj.Step(); toolform.label6.Text = "" + obj.PotentialEnergy; toolform.label14.Text = "" + (obj.PotentialEnergy + obj.KineticEnergyW); toolform.label13.Text = "" + obj.KineticEnergyW; } ReadKeyboard(); UpdateInputState(); } if (bResized) { bResized = false; dxEnable = false; InitializeDevice(); InitializeLights(); InitializeCamera(); InitializeObjects(); dxEnable = true; } } catch (Exception er) { MessageBox.Show(er.Message); } }
private void Form1_Paint(object sender, PaintEventArgs e) { device.Clear(ClearFlags.Target, Color.Chartreuse, 1, 0); device.BeginScene(); device.SetTexture(0, texture); device.VertexFormat = CustomVertex.PositionTextured.Format; device.DrawUserPrimitives(PrimitiveType.TriangleList, vertex.Length / 3, vertex); device.EndScene(); device.Present(); }
/// <summary> /// 绘制在Render中准备好的内容 /// </summary> /// <param name="auto_clear">绘制之前是否用黑色清理整个viewport</param> public static void Present(bool auto_clear) { Device.BeginScene(); if (auto_clear) { Device.Clear(ClearFlags.Target, Color.Black, 1f, 0); } Render.Invoke(); Device.EndScene(); Device.Present(); }
private void Form1_MouseClick_1(object sender, MouseEventArgs e) { device.Clear(ClearFlags.Target, Color.CornflowerBlue, 0, 1); device.BeginScene(); using (Sprite s = new Sprite(device)) { s.Begin(SpriteFlags.AlphaBlend); s.Draw2D(texture_blood, new Rectangle(0, 0, 200, 200), new Rectangle(0, 0, 0, 0), new Point(0, 0), 0f, new Point(e.X - 100, e.Y - 100), Color.White); s.End(); } device.EndScene(); device.Present(); int toDel = -1; for (int i = 0; i < ch.Count; i++) { Characters cat = ch[i]; if ((e.X >= cat.CharacterCoordinates.X && e.X <= cat.CharacterCoordinates.X + 150) && (e.Y >= cat.CharacterCoordinates.Y && e.Y <= cat.CharacterCoordinates.Y + 150)) { using (soundPlayer4 = new SoundPlayer(@"C:\Users\андрей\Documents\Visual Studio 2015\Projects\NewGame\NewGame\bin\Debug\Gun.wav")) { soundPlayer4.Play(); } toDel = i; newHit(); newScore(50); break; } if (hits % 5 == 0) { // newLevel(1); } } if (toDel != -1) { ch.Remove(ch[toDel]); } }
public virtual void Render() { renderDevice.Clear(ClearFlags.Target, Color.Black, 1.0F, 0); renderDevice.BeginScene(); foreach (GameEntity entity in entities) { entity.Render(); } renderDevice.EndScene(); renderDevice.Present(renderSurface); }
public void render_window(double dt) { if (m_D3DDevice == null) { return; } m_D3DDevice.BeginScene(); Root.instance().scene_director().draw_scene(dt); m_D3DDevice.EndScene(); m_D3DDevice.Present(); }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { device.Clear(ClearFlags.Target, Color.Navy, 1.0f, 0); device.BeginScene(); device.VertexFormat = CustomVertex.PositionColored.Format; device.Transform.World = Matrix.Translation(MyMaticeX, MyMaticeY, MyMaticeZ); device.DrawUserPrimitives(PrimitiveType.TriangleList, 1, vertices); device.EndScene(); device.Present(); this.Invalidate(); ReadKeyboard(); }
} //take any texture image as bg. private void Render() { device.Clear(ClearFlags.Target, Color.CornflowerBlue, 0, 1); device.BeginScene(); using (Sprite s = new Sprite(device)) { s.Begin(SpriteFlags.AlphaBlend); s.Draw2D(texture, new Rectangle(0, 0, 0, 0), new Rectangle(0, 0, device.Viewport.Width, device.Viewport.Height), new Point(0, 0), 0f, new Point(0, 0), Color.DarkSlateGray); font.DrawText(s, "TYCS-6070", new Point(0, 0), Color.White); s.End(); } device.EndScene(); device.Present(); }
void Render() { m_d3DDevice.BeginScene(); tagRECT rect; rect.top = m_d3DDevice.Viewport.Y; rect.left = m_d3DDevice.Viewport.X; rect.bottom = m_d3DDevice.Viewport.Y + m_d3DDevice.Viewport.Height; rect.right = m_d3DDevice.Viewport.X + m_d3DDevice.Viewport.Width; m_previewHelper.Render(rect); m_d3DDevice.EndScene(); m_d3DDevice.Present(); }
public void Render() { if (DXDevice == null) { return; } DXDevice.Clear(Direct3D.ClearFlags.Target, Color.Gray, 1, 0); DXDevice.BeginScene(); DXDevice.VertexFormat = Direct3D.CustomVertex.PositionColored.Format; DXDevice.SetStreamSource(0, vb, 0); DXDevice.Indices = ib; DXDevice.Transform.World = Matrix.RotationY(angle); DXDevice.DrawIndexedPrimitives(Direct3D.PrimitiveType.TriangleList, 0, 0, vertices.Length, 0, indexes.Length / 3); DXDevice.EndScene(); DXDevice.Present(); angle += 0.02f; }
private void Render() { CustomVertex.TransformedColored[] vertexes = new CustomVertex.TransformedColored[3]; vertexes[0].Position = new Vector4(240, 110, 0, 1.0f); //first point vertexes[0].Color = System.Drawing.Color.FromArgb(0, 255, 0).ToArgb(); vertexes[1].Position = new Vector4(380, 420, 0, 1.0f); //second point vertexes[1].Color = System.Drawing.Color.FromArgb(0, 0, 255).ToArgb(); vertexes[2].Position = new Vector4(110, 420, 0, 1.0f); //third point vertexes[2].Color = System.Drawing.Color.FromArgb(255, 0, 0).ToArgb(); device.Clear(ClearFlags.Target, Color.CornflowerBlue, 1.0f, 0); device.BeginScene(); device.VertexFormat = CustomVertex.TransformedColored.Format; device.DrawUserPrimitives(PrimitiveType.TriangleList, 1, vertexes); device.EndScene(); device.Present(); }
/// <summary> /// Begins the Device. /// </summary> /// <returns>true if successful, false otherwise.</returns> public bool DeviceBegin() { if (device == null) { return(false); } try { device.BeginScene(); } catch (InvalidCallException) { DialogResult r = MessageBox.Show("Failed to begin device scene.", "ManagedDirect3D::Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } return(true); }
public bool Render() { if (p_D3DDevice == null) { return(false); } p_D3DDevice.Clear(ClearFlags.Target, System.Drawing.Color.Black, 1.0f, 0); p_D3DDevice.BeginScene(); DrawScene(); p_D3DDevice.EndScene(); p_D3DDevice.Present(); return(true); }
public void Render() { try { Microsoft.DirectX.Direct3D.Device device = GameAppFramework.GetGameAppFramework().Device; device.Clear(ClearFlags.Target, Color.HotPink, 0, 1); device.BeginScene(); using (Sprite MenuSprite = new Sprite(device)) { MenuSprite.Begin(SpriteFlags.AlphaBlend); MenuSprite.Draw2D(background, new Rectangle(0, 0, 0, 0), new Rectangle(0, 0, device.Viewport.Width, device.Viewport.Height), new Point(0, 0), 0f, new Point(0, 0), Color.White); font.DrawText(MenuSprite, "Press Space to START", new Point((device.Viewport.Width / 2) - 200, device.Viewport.Height / 2), Color.White); font.DrawText(MenuSprite, "Press Escape to END", new Point((device.Viewport.Width / 2) - 200, (device.Viewport.Height / 2) + 100), Color.White); MenuSprite.End(); } device.EndScene(); device.Present(); } catch (Exception e) { }; }
private void Render() { // check new settings LoadSettings(); // print stats PrintStats(); // check for camera movement HandleInput(); // keep up the frame time Toolbox.FrameTime.NextFrame(); // rotate the landscape angle += rotateSpeed * Toolbox.FrameTime.Time; // clear device device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0); // render scene device.BeginScene(); device.Transform.World = Matrix.Translation(-SIZE / 2, 0, -SIZE / 2) * Matrix.RotationY(angle); int numSubSets = mesh.GetAttributeTable().Length; for (int i = 0; i < numSubSets; ++i) { mesh.DrawSubset(0); } device.EndScene(); // show scene device.Present(); this.Invalidate(); }
public void OnFrameRender(Microsoft.DirectX.Direct3D.Device device, double totalTime, float elapsedTime) { currentTime = totalTime; bool beginSceneCalled = false; if (scenery != null) { scenery.RenderTextures(device, totalTime, elapsedTime); } // Clear the render target and the zbuffer device.Clear(ClearFlags.ZBuffer | ClearFlags.Target, 0x00424B79, 1.0f, 0); try { device.BeginScene(); beginSceneCalled = true; // Get the world matrix //Matrix worldMatrix = worldCenter * camera.WorldMatrix; Framework.Instance.Device.RenderState.Ambient = System.Drawing.Color.FromArgb(148, 148, 148); scenery.OnFrameRender(device, totalTime, elapsedTime); birds.OnFrameRender(device, totalTime, elapsedTime); if (airplaneMesh != null) { airplaneMesh.OnFrameRender(device, totalTime, elapsedTime); } transparentObjectManager.OnFrameRender(device, totalTime, elapsedTime); cursor3d.OnFrameRender(device, totalTime, elapsedTime); selectedObject.OnFrameRender(device, totalTime, elapsedTime); // Show UI hud.OnRender(elapsedTime); } finally { if (beginSceneCalled) { device.EndScene(); } } }
/// <summary> /// Se toma todo lo dibujado antes, que se guardo en una textura, y se le aplica un shader para distorsionar la imagen /// </summary> private void drawPostProcess(Microsoft.DirectX.Direct3D.Device d3dDevice) { //Arrancamos la escena d3dDevice.BeginScene(); //Cargamos para renderizar el unico modelo que tenemos, un Quad que ocupa toda la pantalla, con la textura de todo lo dibujado antes d3dDevice.VertexFormat = CustomVertex.PositionTextured.Format; d3dDevice.SetStreamSource(0, screenQuadVB, 0); //Ver si el efecto de oscurecer esta activado, configurar Technique del shader segun corresponda effect.Technique = "RainTechnique"; if (!presentacion && lloviendo) { effect.Technique = "RainTechnique"; } else { effect.Technique = "DefaultTechnique"; } //Cargamos parametros en el shader de Post-Procesado effect.SetValue("render_target2D", renderTarget2D); effect.SetValue("textura_alarma", lluviaTexture.D3dTexture); effect.SetValue("time", this.ElapsedTime); //Limiamos la pantalla y ejecutamos el render del shader d3dDevice.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0); effect.Begin(FX.None); effect.BeginPass(0); d3dDevice.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2); effect.EndPass(); effect.End(); //Terminamos el renderizado de la escena d3dDevice.EndScene(); d3dDevice.Present(); }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { deltaTime = hrt.ElapsedTime; ProcessInputState(); UpdateSprite(deltaTime); device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Blue, 1.0f, 0); device.BeginScene(); using (Sprite sprite = new Sprite(device)) { sprite.Begin(SpriteFlags.None); //Set rotation center for sprite spriteCenter.X = spritePosition.X + tileSet.ExtentX; spriteCenter.Y = spritePosition.Y + tileSet.ExtentY; //Spin, Shift, Stretch :-) sprite.Transform = Matrix.RotationZ(angle) * Matrix.Translation(spriteCenter); sprite.Draw(tileSet.Texture, tilePosition, spriteCenter, spritePosition, Color.FromArgb(255, 255, 255, 255)); sprite.End(); } device.EndScene(); device.Present(); this.Invalidate(); }
/// <summary> /// The render. /// </summary> /// <remarks></remarks> private void Render() { if (pause) { return; } device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0); device.BeginScene(); cam.move(); SetupMatrices(); device.Material = DefaultMaterial; device.Transform.World = Matrix.Identity; device.RenderState.CullMode = Cull.Clockwise; // Raw.ParsedModel.DisplayedInfo.Draw(ref device, ref bsp.SkyBox); Material m = new Material(); device.RenderState.CullMode = Cull.None; device.RenderState.FillMode = FillMode.WireFrame; device.RenderState.AlphaBlendEnable = false; device.RenderState.AlphaTestEnable = false; device.Material = DefaultMaterial; dxcoll.DrawMeshes(ref device); if (sphereDisplayAll) { device.Material = BlueMaterial; dxcoll.DrawSpheres(ref device); device.Transform.World = Matrix.Identity; } if (planeDisplayAll) { for (int i = 0; i < mList.Count; i++) { m.Ambient = Color.FromArgb(130, (24 - (i % 25)) * 10, i % 25 * 10); m.Diffuse = m.Ambient; device.Material = m; device.SetTexture(0, null); device.RenderState.AlphaBlendEnable = true; device.RenderState.AlphaTestEnable = true; device.RenderState.DestinationBlend = Blend.Zero; device.RenderState.SourceBlend = Blend.One; device.RenderState.FillMode = FillMode.Solid; mList[i].DrawSubset(0); } // Draw normals device.SetStreamSource(0, Vb, 0); device.Transform.World = Matrix.Identity; device.VertexFormat = CustomVertex.PositionColored.Format; device.DrawPrimitives(PrimitiveType.LineList, 0, normalVertices.Length / 2); } else { m.Ambient = Color.Red; m.Diffuse = Color.Red; device.Material = m; device.SetTexture(0, null); device.RenderState.AlphaBlendEnable = true; device.RenderState.AlphaTestEnable = true; device.RenderState.DestinationBlend = Blend.Zero; device.RenderState.SourceBlend = Blend.One; device.RenderState.FillMode = FillMode.Solid; mList[planeDisplay].DrawSubset(0); // Draw normals device.SetStreamSource(0, Vb, 0); device.Transform.World = Matrix.Identity; device.VertexFormat = CustomVertex.PositionColored.Format; int tpd = planeDisplay; int mesh = 0; while (tpd >= coll.Meshes[mesh].SurfaceData.Length) { tpd -= coll.Meshes[mesh++].SurfaceData.Length; } short s = (short)coll.Meshes[mesh].SurfaceData[tpd].Plane; if (s >= 0) { device.DrawPrimitives(PrimitiveType.LineList, coll.Meshes[mesh].SurfaceData[tpd].Plane * 2, 1); } } device.EndScene(); // Update the screen device.Present(); }
/// <summary> /// Dibujamos toda la escena pero en vez de a la pantalla, la dibujamos al Render Target que se cargo antes. /// Es como si dibujaramos a una textura auxiliar, que luego podemos utilizar. /// </summary> private void drawSceneToRenderTarget(Microsoft.DirectX.Direct3D.Device d3dDevice) { //Arrancamos el renderizado. Esto lo tenemos que hacer nosotros a mano porque estamos en modo CustomRenderEnabled = true d3dDevice.BeginScene(); //Dibujamos todos los meshes del escenario // Si se muestra menu principal if (presentacion) { drawer2D.BeginDrawSprite(); //buttonUnselected.Position = new Vector2((D3DDevice.Instance.Width / 16) * 6, ((float)D3DDevice.Instance.Height / 4) * 1.5f); drawer2D.DrawSprite(menuPresentacion); buttonUnselected.Position = new Vector2(((float)D3DDevice.Instance.Width / 2) - 150, 210); drawer2D.DrawSprite(buttonUnselected); buttonUnselected.Position = new Vector2(((float)D3DDevice.Instance.Width / 2) - 150, 280); drawer2D.DrawSprite(buttonUnselected); buttonUnselected.Position = new Vector2(((float)D3DDevice.Instance.Width / 2) - 150, 350); drawer2D.DrawSprite(buttonUnselected); drawer2D.DrawSprite(buttonSelected); drawer2D.DrawSprite(logoWilson); drawer2D.EndDrawSprite(); /* * textoMenuPppal[1] = "Menú Principal"; * textoMenuPppal[2] = "Movimiento Personaje: W A S D"; * textoMenuPppal[3] = "Comer (1), Beber (2), Usar Madera (3), Usar Piedra (4)"; * textoMenuPppal[4] = "Acciones: Agarrar (E) - Destruir (Click Izq) - Correr (Shift Izq)"; * textoMenuPppal[5] = "Modos: Normal (N) - God (G)"; * textoMenuPppal[6] = "Pausa: ESC"; * textoMenuPppal[7] = "Comenzar: Espacio"; * textoMenuPppal[8] = "Salir: Alt+F4"; */ textoMenuPppal[1] = "Menú Principal"; textoMenuPppal[2] = ""; textoMenuPppal[3] = "Comenzar "; textoMenuPppal[4] = "Reiniciar"; textoMenuPppal[5] = "Salir "; for (var j = 1; j <= 5; j++) { if (j == 1) { DrawText.changeFont((new System.Drawing.Font("Tahoma", 35, FontStyle.Underline))); } else { DrawText.changeFont((new System.Drawing.Font("Tahoma", 35, FontStyle.Regular))); } DrawText.drawText(textoMenuPppal[j], (D3DDevice.Instance.Width / 2) - (textoMenuPppal[j].Length * 10) + 2, (70 * j) + 2, Color.Black); DrawText.drawText(textoMenuPppal[j], (D3DDevice.Instance.Width / 2) - (textoMenuPppal[j].Length * 10), 70 * j, Color.OrangeRed); } textoMenuPppal[7] = "Acciones: Agarrar (E), Destruir (Click Izq), Correr (Shift)"; textoMenuPppal[8] = "Interacción Inventario: Comer (1), Beber (2), Usar Madera (3), Usar Piedra (4)"; textoMenuPppal[9] = "Modos del Juego: Normal (N) - God (G)"; for (var j = 7; j <= 9; j++) { DrawText.changeFont((new System.Drawing.Font("Tahoma", 25, FontStyle.Regular))); DrawText.drawText(textoMenuPppal[j], (D3DDevice.Instance.Width / 2) - (textoMenuPppal[j].Length * 7) + 2, (68 * j) + 2 - 20, Color.Black); DrawText.drawText(textoMenuPppal[j], (D3DDevice.Instance.Width / 2) - (textoMenuPppal[j].Length * 7), (68 * j) - 20, Color.BlueViolet); } textoMenuPppal[10] = "Objetivo: Sobrevivir en la Isla y pedir ayuda al exterior."; DrawText.drawText(textoMenuPppal[10], (D3DDevice.Instance.Width / 2) - (textoMenuPppal[10].Length * 7) + 2, (D3DDevice.Instance.Height - 70) + 2, Color.Black); DrawText.drawText(textoMenuPppal[10], (D3DDevice.Instance.Width / 2) - (textoMenuPppal[10].Length * 7), D3DDevice.Instance.Height - 70, Color.GreenYellow); if (Input.keyDown(Key.Space) || Input.keyDown(Key.Return)) { switch (opcionMenuSelecionado) { case 0: // Comenzar Juego presentacion = false; break; case 1: presentacion = false; Reiniciar(); break; case 2: Dispose(); //Program.Terminate(); break; } presentacion = false; } } else { if (Input.keyDown(Key.Escape)) { presentacion = true; } // Si se da la condicion de partido ganado if (partidoGanado) { hud.ganarJuego(); } else { terreno.Render(ElapsedTime); // Creo la fogata if (terreno.activarFogata) { terreno.fogata.render(); } //cajaMenu.render(); RenderHelpText(); personaje.Render(ElapsedTime); RenderFPS(); RenderAxis(); } hud.Render(); } //Terminamos manualmente el renderizado de esta escena. Esto manda todo a dibujar al GPU al Render Target que cargamos antes d3dDevice.EndScene(); }
public static void renderBackground(Texture texture) { // To store the converted video // no longer required - textures now saved out and sent to a memory stream. //convertedVideo[frameCounter++] = texture; // Prevent anything from being rendered until ready if (globalSettings.videoPortal_eRenderReady == false) { return; } // Origionaly split out but more stable as part of this method if (device == null || device.Disposed) { return; } device.BeginScene(); // Renders to a flat plane - i.e. the screen CustomVertex.TransformedTextured[] screenVert = new CustomVertex.TransformedTextured[4]; screenVert[0] = new CustomVertex.TransformedTextured(0, 0, 0, 1, 0, 0); screenVert[1] = new CustomVertex.TransformedTextured(clientForm.Width, 0, 0, 1, 1, 0); screenVert[2] = new CustomVertex.TransformedTextured(clientForm.Width, clientForm.Height, 0, 1, 1, 1); screenVert[3] = new CustomVertex.TransformedTextured(0, clientForm.Height, 0, 1, 0, 1); // To tile textures, use the wrap texture type - It's used by default... // device.SamplerState[1].AddressU = TextureAddress.Wrap; device.SamplerState[1].AddressV = TextureAddress.Wrap; // Then set the U&V co-ordinates to the number of times you want the texture replicated // i.e. if you change both the U&V co-ords to 2 then you will see the texture tiled 4 times, 2 across and 2 down // Turn off while drawing the background //device.RenderState.ZBufferEnable = false; // Test with vertex buffer // buffer.SetData(screenVert, 0, LockFlags.None); // -----------Stuffn with -------------------------------- //SamplerStateManager sam = new SamplerStateManager(); //sam = TextureAddress.Border; //device.SetSamplerState(0,SamplerStageStates.SrgbTexture, true); //TextureAddress tex = new TextureAddress(); //tex = TextureAddress.Border; // -----------Stuffn with -------------------------------- //// These would probably work if the textures were first copied to a newly created texture in this //// transactions scope //fUtil.addFrame(device.GetTexture(0)); //fUtil.addFrame(texture); //// This works to save the rendered frame to a BMP //Bitmap bmp = SaveToBitmap(device); //fUtil.addBmpFrame(bmp); // Attemptng to save the frame as a memory stream in the DDS format //SaveToDDSFile(device); //fUtil.addDDSFrame("TempDDSConv.dds"); //fUtil.addMSFrame(aMS); // Set the texture to render to the background device.SetTexture(0, texture); if (lastFrame != null) { // For Vertex Buffer //device.SetStreamSource(0, buffer, 0,0); device.SetTexture(1, lastFrame); // Sets the U&V co-ordinates for the '1' (i.e. second) texture stage to the same as the first! // I wish ths was better f*****g documented, seriosuly device.TextureState[1].TextureCoordinateIndex = 0; // For Vertex Buffer //device.SetStreamSource(1, buffer, 0,0); //-------------- more stuffn //device.SamplerState[0].AddressU = TextureAddress.Border; //device.SamplerState[0].AddressV = TextureAddress.Border; // wrap is the default mode device.SamplerState[1].AddressU = TextureAddress.Wrap; device.SamplerState[1].AddressV = TextureAddress.Wrap; //------------- //// Blend and mix - around 50% transperancy device.SetTextureStageState(0, TextureStageStates.ColorArgument1, (int)TextureArgument.TextureColor); device.SetTextureStageState(0, TextureStageStates.ColorOperation, (int)TextureOperation.SelectArg1); device.SetTextureStageState(1, TextureStageStates.ColorArgument1, (int)TextureArgument.Current); device.SetTextureStageState(1, TextureStageStates.ColorArgument2, (int)TextureArgument.TextureColor); device.SetTextureStageState(1, TextureStageStates.ColorOperation, (int)TextureOperation.Add); // Lighter blend //device.SetTextureStageState(0, TextureStageStates.ColorArgument1, (int)TextureArgument.TextureColor); //device.SetTextureStageState(0, TextureStageStates.ColorOperation, (int)TextureOperation.SelectArg1); //device.SetTextureStageState(1, TextureStageStates.ColorArgument1, (int)TextureArgument.Current); //device.SetTextureStageState(1, TextureStageStates.ColorArgument2, (int)TextureArgument.TextureColor); //device.SetTextureStageState(1, TextureStageStates.ColorOperation, (int)TextureOperation.MultiplyAdd); // Subtract the darker colour from the lighter colour //device.SetTextureStageState(0, TextureStageStates.ColorArgument1, (int)TextureArgument.TextureColor); //device.SetTextureStageState(0, TextureStageStates.ColorOperation, (int)TextureOperation.SelectArg1); //device.SetTextureStageState(1, TextureStageStates.ColorArgument1, (int)TextureArgument.Current); //device.SetTextureStageState(1, TextureStageStates.ColorArgument2, (int)TextureArgument.TextureColor); //device.SetTextureStageState(1, TextureStageStates.ColorOperation, (int)TextureOperation.Subtract); // Add with a darker tinge //device.SetTextureStageState(0, TextureStageStates.ColorArgument1, (int)TextureArgument.TextureColor); //device.SetTextureStageState(0, TextureStageStates.ColorOperation, (int)TextureOperation.SelectArg1); //device.SetTextureStageState(1, TextureStageStates.ColorArgument1, (int)TextureArgument.Current); //device.SetTextureStageState(1, TextureStageStates.ColorArgument2, (int)TextureArgument.TextureColor); //device.SetTextureStageState(1, TextureStageStates.ColorOperation, (int)TextureOperation.AddSigned); // Add with highted highlights and darkened shadows //device.SetTextureStageState(0, TextureStageStates.ColorArgument1, (int)TextureArgument.TextureColor); //device.SetTextureStageState(0, TextureStageStates.ColorOperation, (int)TextureOperation.SelectArg1); //device.SetTextureStageState(1, TextureStageStates.ColorArgument1, (int)TextureArgument.Current); //device.SetTextureStageState(1, TextureStageStates.ColorArgument2, (int)TextureArgument.TextureColor); //device.SetTextureStageState(1, TextureStageStates.ColorOperation, (int)TextureOperation.AddSigned2X); // Add with a lighter mix //device.SetTextureStageState(0, TextureStageStates.ColorArgument1, (int)TextureArgument.TextureColor); //device.SetTextureStageState(0, TextureStageStates.ColorOperation, (int)TextureOperation.SelectArg1); //device.SetTextureStageState(1, TextureStageStates.ColorArgument1, (int)TextureArgument.Current); //device.SetTextureStageState(1, TextureStageStates.ColorArgument2, (int)TextureArgument.TextureColor); //device.SetTextureStageState(1, TextureStageStates.ColorOperation, (int)TextureOperation.AddSmooth); // Use colour to tint image mix //device.SetTextureStageState(0, TextureStageStates.ColorArgument1, (int)TextureArgument.TextureColor); //device.SetTextureStageState(0, TextureStageStates.ColorOperation, (int)TextureOperation.SelectArg1); //device.SetTextureStageState(1, TextureStageStates.ColorArgument1, (int)TextureArgument.Current); //device.SetTextureStageState(1, TextureStageStates.ColorArgument2, (int)TextureArgument.TextureColor); //device.SetTextureStageState(1, TextureStageStates.ColorOperation, (int)TextureOperation.Modulate); // Add image and inverse white parts of the image being added //device.SetTextureStageState(0, TextureStageStates.ColorArgument1, (int)TextureArgument.TextureColor); //device.SetTextureStageState(0, TextureStageStates.ColorOperation, (int)TextureOperation.SelectArg1); //device.SetTextureStageState(1, TextureStageStates.ColorArgument1, (int)TextureArgument.Current); //device.SetTextureStageState(1, TextureStageStates.ColorArgument2, (int)TextureArgument.TextureColor); //device.SetTextureStageState(1, TextureStageStates.ColorOperation, (int)TextureOperation.Lerp); // Black and white image add. //device.SetTextureStageState(0, TextureStageStates.ColorArgument1, (int)TextureArgument.TextureColor); //device.SetTextureStageState(0, TextureStageStates.ColorOperation, (int)TextureOperation.SelectArg1); //device.SetTextureStageState(1, TextureStageStates.ColorArgument1, (int)TextureArgument.Current); //device.SetTextureStageState(1, TextureStageStates.ColorArgument2, (int)TextureArgument.TextureColor); //device.SetTextureStageState(1, TextureStageStates.ColorOperation, (int)TextureOperation.DotProduct3); //if (secondLastFrame != null) //{ // device.TextureState[2].TextureCoordinateIndex = 0; // device.SetTextureStageState(1, TextureStageStates.ColorOperation, (int)TextureOperation.SelectArg1); // device.SetTexture(2, secondLastFrame); // device.SetTextureStageState(2, TextureStageStates.ColorArgument1, (int)TextureArgument.Current); // device.SetTextureStageState(2, TextureStageStates.ColorArgument2, (int)TextureArgument.TextureColor); // device.SetTextureStageState(2, TextureStageStates.ColorOperation, (int)TextureOperation.Add); //} } //secondLastFrame = lastFrame; lastFrame = texture; //device.VertexFormat = CustomVertex.TransformedTextured.Format; device.VertexFormat = vertexFormat; device.DrawUserPrimitives(PrimitiveType.TriangleFan, 2, screenVert); // Turn it back on // device.RenderState.ZBufferEnable = true; // Origionaly split out but more stable in the same method device.EndScene(); device.Present(); }