public override void Update() { texQuad[0] = new CustomVertex.TransformedTextured(origin.X, origin.Y, 0, 1, 0, 0); texQuad[1] = new CustomVertex.TransformedTextured(origin.X + dimensions.Width, origin.Y, 0, 1, 0, 0); texQuad[2] = new CustomVertex.TransformedTextured(origin.X, origin.Y + dimensions.Height, 0, 1, 0, 0); texQuad[3] = new CustomVertex.TransformedTextured(origin.X + dimensions.Width, origin.Y + dimensions.Height, 0, 1, 0, 0); }
public override void Update() { texQuad[0] = new CustomVertex.TransformedTextured(origin.X, origin.Y, 0, 1, 0, 0); texQuad[1] = new CustomVertex.TransformedTextured(origin.X + dimensions.Width, origin.Y, 0, 1, 0, 0); texQuad[2] = new CustomVertex.TransformedTextured(origin.X, origin.Y + dimensions.Height, 0, 1, 0, 0); texQuad[3] = new CustomVertex.TransformedTextured(origin.X + dimensions.Width, origin.Y + dimensions.Height, 0, 1, 0, 0); }
public void Render(Device Device3D, DeviceInfo deviceInfo) { try { Device3D.RenderState.FogEnable = false; CustomVertex.TransformedTextured[] data = new CustomVertex.TransformedTextured[4]; data[0].X = 0.0f; data[0].Y = 0.0f; data[0].Z = 0.0f; data[0].Tu = 0.0f; data[0].Tv = 0.0f; data[1].X = Device3D.Viewport.Width; data[1].Y = 0.0f; data[1].Z = 0.0f; data[1].Tu = 1.0f; data[1].Tv = 0.0f; data[2].X = 0.0f; data[2].Y = Device3D.Viewport.Height; data[2].Z = 0.0f; data[2].Tu = 0.0f; data[2].Tv = 1.0f; data[3].X = Device3D.Viewport.Width; data[3].Y = Device3D.Viewport.Height; data[3].Z = 0.0f; data[3].Tu = 1.0f; data[3].Tv = 1.0f; m_vb.SetData(data, 0, 0); Device3D.SetStreamSource(0, m_vb, 0); Device3D.VertexFormat = CustomVertex.TransformedTextured.Format; // Set the texture Device3D.SetTexture(0, image.GetTexture()); // Render the face Device3D.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2); Device3D.RenderState.FogEnable = deviceInfo.FogEnabled; } catch (DirectXException d3de) { Console.AddLine("Unable to display SplashScreen "); Console.AddLine(d3de.ErrorString); } catch (Exception e) { Console.AddLine("Unable to display SplashScreen "); Console.AddLine(e.Message); } // check for timeout float fCurrentTime = Utils.Timer(TIMER.GETABSOLUTETIME); fTimeLeft = m_EndTime - fCurrentTime; //return (fCurrentTime > m_EndTime); }
public void Initialize(int height, int width, int posx, int posy) { origin.X = posx; origin.Y = posy; Height = height; Width = width; renderButtonVerts[0] = new CustomVertex.TransformedTextured(origin.X, origin.Y, 0.5f, 1, 0, 0); renderButtonVerts[1] = new CustomVertex.TransformedTextured(origin.X, origin.Y + Height, 0.5f, 1, 0, 1); renderButtonVerts[2] = new CustomVertex.TransformedTextured(origin.X + width, origin.Y, 0.5f, 1, 1, 0); renderButtonVerts[3] = new CustomVertex.TransformedTextured(origin.X + width, origin.Y + Height, 0.5f, 1, 1, 1); }
public ScreenBillboard(Point pos, int sizeX, int sizeY, IShader shader) { billboardShader = shader; verts = new CustomVertex.TransformedTextured[6]; verts[2] = new CustomVertex.TransformedTextured(pos.X, pos.Y, 0.0f, 1.0f, 0, 0); verts[1] = new CustomVertex.TransformedTextured(pos.X, pos.Y + sizeY, 0.0f, 1.0f, 0, 1); verts[0] = new CustomVertex.TransformedTextured(pos.X + sizeX, pos.Y, 0.0f, 1.0f, 1, 0); verts[3] = new CustomVertex.TransformedTextured(pos.X + sizeX, pos.Y + sizeY, 0.0f, 1.0f, 1, 1); verts[4] = new CustomVertex.TransformedTextured(pos.X, pos.Y + sizeY, 0.0f, 1.0f, 0, 1); verts[5] = new CustomVertex.TransformedTextured(pos.X + sizeX, pos.Y, 0.0f, 1.0f, 1, 0); }
private void SetMovieWindow() { double movieAspectRatio = (double)currentVideo.DefaultSize.Height / (double)currentVideo.DefaultSize.Width;; int targetHeight = (int)(screenWidth * movieAspectRatio); int diff = (screenHeight - targetHeight) / 2; CustomVertex.TransformedTextured[] verts = (CustomVertex.TransformedTextured[])vertices.Lock(0, 0); verts[0] = new CustomVertex.TransformedTextured(0, diff, 0.5f, 1, 0, 0); verts[1] = new CustomVertex.TransformedTextured(screenWidth, diff, 0.5f, 1, 1, 0); verts[2] = new CustomVertex.TransformedTextured(0, screenHeight - diff, 0.5f, 1, 0, 1); verts[3] = new CustomVertex.TransformedTextured(screenWidth, screenHeight - diff, 0.5f, 1, 1, 1); vertices.Unlock(); }
public SplashScreen(Device device3D, string fileName, SplashButton[] buttons) { sButtons = buttons; device3d = device3D; int h = device3d.PresentationParameters.BackBufferHeight; int w = device3d.PresentationParameters.BackBufferWidth; vertices = new CustomVertex.TransformedTextured[6]; vertices[0] = new CustomVertex.TransformedTextured(new Vector4(0, 0, 0.1f, 1f), 0, 0); vertices[1] = new CustomVertex.TransformedTextured(new Vector4(w, 0, 0.1f, 1f), 1, 0); vertices[2] = new CustomVertex.TransformedTextured(new Vector4(0, h, 0.1f, 1f), 0, 1); vertices[3] = new CustomVertex.TransformedTextured(new Vector4(0, h, 0.1f, 1f), 0, 1); vertices[4] = new CustomVertex.TransformedTextured(new Vector4(w, 0, 0.1f, 1f), 1, 0); vertices[5] = new CustomVertex.TransformedTextured(new Vector4(w, h, 0.1f, 1f), 1, 1); texture = TextureLoader.FromFile(device3d, fileName); Enable = true; }
private void CreateVertexBuffer(int wx, int wy, int wwidth, int wheight) { if (_vertexBuffer == null) { Usage usage = Usage.None; if (OSInfo.OSInfo.VistaOrLater()) { usage = Usage.Dynamic | Usage.WriteOnly; } _vertexBuffer = new VertexBuffer(typeof(CustomVertex.TransformedTextured), 4, GUIGraphicsContext.DX9Device, usage, CustomVertex.TransformedTextured.Format, GUIGraphicsContext.GetTexturePoolType()); _wx = _wy = _wwidth = _wheight = 0; } if (_wx != wx || _wy != wy || _wwidth != wwidth || _wheight != wheight) { CustomVertex.TransformedTextured[] verts = (CustomVertex.TransformedTextured[])_vertexBuffer.Lock(0, 0); // upper left verts[0] = new CustomVertex.TransformedTextured(wx, wy, 0, 1, 0, 0); // upper right verts[1] = new CustomVertex.TransformedTextured(wx + wwidth, wy, 0, 1, 1, 0); // lower left verts[2] = new CustomVertex.TransformedTextured(wx, wy + wheight, 0, 1, 0, 1); // lower right verts[3] = new CustomVertex.TransformedTextured(wx + wwidth, wy + wheight, 0, 1, 1, 1); _vertexBuffer.SetData(verts, 0, LockFlags.None); _vertexBuffer.Unlock(); // remember what the vertexBuffer is set to _wy = wy; _wx = wx; _wheight = wheight; _wwidth = wwidth; } }
/// <summary> /// Creates a vertex buffer for a transformed textured quad matching /// the given rectangle and stores it in vertexBuffer /// </summary> /// <param name="wx"></param> /// <param name="wy"></param> /// <param name="wwidth"></param> /// <param name="wheight"></param> private void CreateVertexBuffer(int wx, int wy, int wwidth, int wheight) { if (_vertexBuffer == null) { Log.Debug("Subtitle: Creating vertex buffer"); _vertexBuffer = new VertexBuffer(typeof(CustomVertex.TransformedTextured), 4, GUIGraphicsContext.DX9Device, Usage.Dynamic | Usage.WriteOnly, CustomVertex.TransformedTextured.Format, GUIGraphicsContext.GetTexturePoolType()); _wx = _wy = _wwidth = _wheight = 0; } if (_wx != wx || _wy != wy || _wwidth != wwidth || _wheight != wheight) { Log.Debug("Subtitle: Setting vertices"); CustomVertex.TransformedTextured[] verts = (CustomVertex.TransformedTextured[])_vertexBuffer.Lock(0, 0); // upper left verts[0] = new CustomVertex.TransformedTextured(wx, wy, 0, 1, 0, 0); // upper right verts[1] = new CustomVertex.TransformedTextured(wx + wwidth, wy, 0, 1, 1, 0); // lower left verts[2] = new CustomVertex.TransformedTextured(wx, wy + wheight, 0, 1, 0, 1); // lower right verts[3] = new CustomVertex.TransformedTextured(wx + wwidth, wy + wheight, 0, 1, 1, 1); _vertexBuffer.SetData(verts, 0, LockFlags.None); // remember what the vertexBuffer is set to _wy = wy; _wx = wx; _wheight = wheight; _wwidth = wwidth; } }
public virtual void Init(Device dxDevice, Texture tex, System.Drawing.Rectangle rect, Matrix xform, float uTiling = 1.0f, float vTiling = 1.0f) { texture = tex; surface = texture.GetSurfaceLevel(0); vertices = new VertexBuffer(typeof(CustomVertex.TransformedTextured), 4, dxDevice, 0, CustomVertex.TransformedTextured.Format, Pool.Default); GraphicsStream str = vertices.Lock(0, 0, 0); CustomVertex.TransformedTextured[] quad = new CustomVertex.TransformedTextured[4]; Vector4 topRight = Vector4.Transform(new Vector4(rect.X + rect.Width, rect.Y, 0.0f, 1.0f), xform); Vector4 topLeft = Vector4.Transform(new Vector4(rect.X, rect.Y, 0.0f, 1.0f), xform); Vector4 bottomRight = Vector4.Transform(new Vector4(rect.X + rect.Width, rect.Y + rect.Height, 0.0f, 1.0f), xform); Vector4 bottomLeft = Vector4.Transform(new Vector4(rect.X, rect.Y + rect.Height, 0.0f, 1.0f), xform); Console.WriteLine(topRight); quad[0] = new CustomVertex.TransformedTextured(topLeft.X, topLeft.Y, topLeft.Z, 1.0f, 0.0f, 0.0f); quad[1] = new CustomVertex.TransformedTextured(topRight.X, topRight.Y, topRight.Z, 1.0f, uTiling, 0.0f); quad[2] = new CustomVertex.TransformedTextured(bottomLeft.X, bottomLeft.Y, bottomLeft.Z, 1.0f, 0, vTiling); quad[3] = new CustomVertex.TransformedTextured(bottomRight.X, bottomRight.Y, bottomRight.Z, 1.0f, uTiling, vTiling); str.Write(quad); vertices.Unlock(); }
public void DrawTexture( Point pt, Rectangle rectOrigin, D3DTexture2D pTexture) { CustomVertex.TransformedTextured[] vertices = new CustomVertex.TransformedTextured[4]; int witWidth = pTexture.BaseSurface.Description.Width; int witHeight = pTexture.BaseSurface.Description.Height; vertices[0].Position = new Vector4(pt.X, pt.Y, 0.0f, 1.0f); vertices[0].Rhw = 1.0f; vertices[0].Tu = ((float)rectOrigin.X/witWidth); vertices[0].Tv = ((float)rectOrigin.Y / witHeight); vertices[1].Position = new Vector4(pt.X + rectOrigin.Width, pt.Y, 0.0f, 1.0f); vertices[1].Rhw = 1.0f; vertices[1].Tu = ((float)(rectOrigin.X + rectOrigin.Width)/witWidth); vertices[1].Tv = ((float)rectOrigin.Y/witHeight); vertices[2].Position = new Vector4(pt.X, pt.Y + rectOrigin.Height, 0.0f, 1.0f); vertices[2].Rhw = 1.0f; vertices[2].Tu = ((float) rectOrigin.X/witWidth); vertices[2].Tv = ((float)(rectOrigin.Y + rectOrigin.Height) / witHeight); vertices[3].Position = new Vector4(pt.X + rectOrigin.Width, pt.Y + rectOrigin.Height, 0.0f, 1.0f); vertices[3].Rhw = 1.0f; vertices[3].Tu = ((float)(rectOrigin.X + rectOrigin.Width) / witWidth); vertices[3].Tv = ((float)(rectOrigin.Y + rectOrigin.Height) / witHeight); m_d3dDevice.SetSamplerState(0, SamplerStageStates.AddressU, true); m_d3dDevice.SetSamplerState(0, SamplerStageStates.AddressV, true); m_d3dDevice.SetSamplerState(0, SamplerStageStates.MinFilter, (int)TextureFilter.Linear); //m_d3dDevice.SetSamplerState(0, SamplerStageStates.MagFilter, (int)TextureFilter.Linear); m_d3dDevice.SetRenderState(RenderStates.CullMode, (int)Cull.None); m_d3dDevice.SetRenderState(RenderStates.AlphaBlendEnable, true); m_d3dDevice.SetRenderState(RenderStates.SourceBlend, (int)Blend.SourceAlpha); m_d3dDevice.SetRenderState(RenderStates.DestinationBlend, (int)Blend.InvSourceAlpha); m_d3dDevice.SetRenderState(RenderStates.ZEnable, false); m_d3dDevice.SetTextureStageState( 0, TextureStageStates.ColorOperation, (int)TextureOperation.SelectArg1 ); m_d3dDevice.SetTextureStageState( 0, TextureStageStates.ColorArgument1, (int)TextureArgument.TextureColor); m_d3dDevice.SetTextureStageState( 0, TextureStageStates.AlphaOperation, (int)TextureOperation.Modulate ); m_d3dDevice.SetTextureStageState(0, TextureStageStates.AlphaArgument1, (int)TextureArgument.TextureColor); m_d3dDevice.SetTextureStageState(0, TextureStageStates.AlphaArgument2, (int)TextureArgument.TFactor); //m_d3dDevice.SetRenderState(RenderStates.TextureFactor, Color.FromArgb(255, 0, 0, 0).ToArgb()); m_d3dDevice.VertexShader = null; m_d3dDevice.SetTexture(0, pTexture.BaseTexture); m_d3dDevice.VertexFormat = CustomVertex.TransformedTextured.Format; m_d3dDevice.DrawUserPrimitives(PrimitiveType.TriangleStrip, 2, vertices); m_d3dDevice.SetTexture( 0, null ); }
private void CreateVertexBuffer(int wx, int wy, int wwidth, int wheight) { if (_vertexBuffer == null) { _vertexBuffer = new VertexBuffer(typeof(CustomVertex.TransformedTextured), 4, GUIGraphicsContext.DX9Device, Usage.Dynamic | Usage.WriteOnly, CustomVertex.TransformedTextured.Format, GUIGraphicsContext.GetTexturePoolType()); _wx = _wy = _wwidth = _wheight = 0; } if (_wx != wx || _wy != wy || _wwidth != wwidth || _wheight != wheight) { CustomVertex.TransformedTextured[] verts = (CustomVertex.TransformedTextured[])_vertexBuffer.Lock(0, 0); // upper left verts[0] = new CustomVertex.TransformedTextured(wx, wy, 0, 1, 0, 0); // upper right verts[1] = new CustomVertex.TransformedTextured(wx + wwidth, wy, 0, 1, 1, 0); // lower left verts[2] = new CustomVertex.TransformedTextured(wx, wy + wheight, 0, 1, 0, 1); // lower right verts[3] = new CustomVertex.TransformedTextured(wx + wwidth, wy + wheight, 0, 1, 1, 1); _vertexBuffer.SetData(verts, 0, LockFlags.None); _vertexBuffer.Unlock(); // remember what the vertexBuffer is set to _wy = wy; _wx = wx; _wheight = wheight; _wwidth = wwidth; } }
private void setup_screen() { customvertex = new CustomVertex.TransformedTextured[6]; vb = new VertexBuffer(device, Marshal.SizeOf(typeof(CustomVertex.TransformedTextured)) * 6, Usage.WriteOnly, CustomVertex.TransformedTextured.Format, Pool.Default); customvertex[0] = new CustomVertex.TransformedTextured(new Vector4(0.0f, 0.0f, 0.0f, 1.0f), new Vector2(0.0f, 0.0f)); customvertex[1] = new CustomVertex.TransformedTextured(new Vector4(width, 0.0f, 0.0f, 1.0f), new Vector2(0.625f, 0.0f)); customvertex[2] = new CustomVertex.TransformedTextured(new Vector4(0.0f, height, 0.0f, 1.0f), new Vector2(0.0f, 0.5625f)); customvertex[3] = new CustomVertex.TransformedTextured(new Vector4(width, 0.0f, 0.0f, 1.0f), new Vector2(0.625f, 0.0f)); customvertex[4] = new CustomVertex.TransformedTextured(new Vector4(width, height, 0.0f, 1.0f), new Vector2(0.625f, 0.5625f)); customvertex[5] = new CustomVertex.TransformedTextured(new Vector4(0.0f, height, 0.0f, 1.0f), new Vector2(0.0f, 0.5625f)); vertex_data = vb.Lock(0, Marshal.SizeOf(typeof(CustomVertex.TransformedTextured)) * 6, LockFlags.Discard); vertex_data.WriteRange(customvertex); vb.Unlock(); }
/// <summary> /// Draw the bitmap to the back buffer. /// </summary> /// <param name="x">X destination of the draw</param> /// <param name="y">Y destination of the draw</param> /// <param name="sourceRegion">Source region of the draw</param> /// <param name="bmp">Bitmap to be drawn</param> public void DrawBitmap(int x, int y, Rectangle sourceRegion, IBitmap bmp) { // make sure the function is passed an appropriate implementation DirectXBitmap dxBitmap = null; try { dxBitmap = (DirectXBitmap)bmp; } catch (InvalidCastException e) { throw new ApplicationException( "The bitmap given was not created by" + "this class' CreateBitmap() method.", e); } // Clip the regions to the screen if (!ValidateRegions(ref x, ref y, ref sourceRegion)) { return; } // determine texture coordinates so that // the there is a 1-1 mapping between texels and screen pixels Rectangle dest = new Rectangle(x, y, sourceRegion.Width, sourceRegion.Height); RectangleF textureRect = new RectangleF( ((float)sourceRegion.X + 0.5F) / dxBitmap.Width, ((float)sourceRegion.Y + 0.5F) / dxBitmap.Height, ((float)sourceRegion.Width + 0.5F) / dxBitmap.Width, ((float)sourceRegion.Height + 0.5F) / dxBitmap.Height); // load the vertex buffer with data for the two triangles // in the rectangle GraphicsStream stm = vbTex.Lock(0, 0, 0); CustomVertex.TransformedTextured[] verts = new CustomVertex.TransformedTextured[4]; if ((drawOptions & DrawOptions.BlitMirrorLeftRight) == 0) { verts[0].X = dest.Right; verts[0].Y = dest.Top; verts[0].Z = 0.5f; verts[0].Rhw = 1; verts[0].Tu = textureRect.Right; verts[0].Tv = textureRect.Top; verts[1].X = dest.Right; verts[1].Y = dest.Bottom; verts[1].Z = 0.5f; verts[1].Rhw = 1; verts[1].Tu = textureRect.Right; verts[1].Tv = textureRect.Bottom; verts[2].X = dest.Left; verts[2].Y = dest.Top; verts[2].Z = 0.5f; verts[2].Rhw = 1; verts[2].Tu = textureRect.Left; verts[2].Tv = textureRect.Top; verts[3].X = dest.Left; verts[3].Y = dest.Bottom; verts[3].Z = 0.5f; verts[3].Rhw = 1; verts[3].Tu = textureRect.Left; verts[3].Tv = textureRect.Bottom; } else { verts[0].X = dest.Right; verts[0].Y = dest.Top; verts[0].Z = 0.5f; verts[0].Rhw = 1; verts[0].Tu = textureRect.Left; verts[0].Tv = textureRect.Top; verts[1].X = dest.Right; verts[1].Y = dest.Bottom; verts[1].Z = 0.5f; verts[1].Rhw = 1; verts[1].Tu = textureRect.Left; verts[1].Tv = textureRect.Bottom; verts[2].X = dest.Left; verts[2].Y = dest.Top; verts[2].Z = 0.5f; verts[2].Rhw = 1; verts[2].Tu = textureRect.Right; verts[2].Tv = textureRect.Top; verts[3].X = dest.Left; verts[3].Y = dest.Bottom; verts[3].Z = 0.5f; verts[3].Rhw = 1; verts[3].Tu = textureRect.Right; verts[3].Tv = textureRect.Bottom; } stm.Write(verts); vbTex.Unlock(); // bind the texture to next drawing operation device.SetTexture(0, dxBitmap.Texture); // bind the vertex data to the next drawing operation device.SetStreamSource(0, vbTex, 0); #if DESKTOP device.VertexFormat = CustomVertex.TransformedTextured.Format; #endif // perform the draw device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2); }
/// <summary> /// Draw the console if it is visible /// </summary> public static void Render() { if (m_bVisible) { bool fog_state = CGameEngine.Device3D.RenderState.FogEnable; CGameEngine.Device3D.RenderState.FogEnable = false; // determine how much of the console will be visible based on whether it is opening, // open, or closing if (m_bOpening && m_Percent <= m_MaxPercent) { m_Percent += 0.05f; } else if (m_bClosing && m_Percent >= 0.0f) { m_Percent -= 0.05f; if (m_Percent <= 0.0f) { m_bClosing = false; m_bVisible = false; } } // render the console background try { int line = (int)((m_Percent * CGameEngine.Device3D.Viewport.Height) - 5 - m_pFont.LineHeight); if (line > 5) { // draw the image to the device try { CustomVertex.TransformedTextured[] data = new CustomVertex.TransformedTextured[4]; data[0].X = CGameEngine.Device3D.Viewport.Width; data[0].Y = 0.0f - (1.0f - m_Percent) * CGameEngine.Device3D.Viewport.Height; data[0].Z = 0.0f; data[0].Tu = 1.0f; data[0].Tv = 0.0f; data[1].X = 0.0f; data[1].Y = 0.0f - (1.0f - m_Percent) * CGameEngine.Device3D.Viewport.Height; data[1].Z = 0.0f; data[1].Tu = 0.0f; data[1].Tv = 0.0f; data[2].X = CGameEngine.Device3D.Viewport.Width; data[2].Y = CGameEngine.Device3D.Viewport.Height - (1.0f - m_Percent) * CGameEngine.Device3D.Viewport.Height; data[2].Z = 0.0f; data[2].Tu = 1.0f; data[2].Tv = 1.0f; data[3].X = 0.0f; data[3].Y = CGameEngine.Device3D.Viewport.Height - (1.0f - m_Percent) * CGameEngine.Device3D.Viewport.Height; data[3].Z = 0.0f; data[3].Tu = 0.0f; data[3].Tv = 1.0f; VertexBuffer vb = new VertexBuffer(typeof(CustomVertex.TransformedTextured), 4, CGameEngine.Device3D, Usage.WriteOnly, CustomVertex.TransformedTextured.Format, Pool.Default); vb.SetData(data, 0, 0); CGameEngine.Device3D.SetStreamSource(0, vb, 0); CGameEngine.Device3D.VertexFormat = CustomVertex.TransformedTextured.Format; CGameEngine.Device3D.RenderState.CullMode = Microsoft.DirectX.Direct3D.Cull.Clockwise; // Set the texture CGameEngine.Device3D.SetTexture(0, m_Image.GetTexture()); // Render the face CGameEngine.Device3D.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2); } catch (DirectXException d3de) { Console.AddLine("Unable to display console "); Console.AddLine(d3de.ErrorString); } catch (Exception e) { Console.AddLine("Unable to display console "); Console.AddLine(e.Message); } m_pFont.DrawText(2, line, Color.White, m_Entryline.ToString()); line -= (int)m_pFont.LineHeight; foreach (String entry in m_Entries) { if (line < 5 || line > 300) { // Debug.WriteLine("line is " + line); } if (line > 5) { m_pFont.DrawText(2, line, Color.White, entry); line -= (int)m_pFont.LineHeight; } } } } catch (DirectXException d3de) { Debug.WriteLine("unable to render console"); Debug.WriteLine(d3de.ErrorString); } catch (Exception e) { Debug.WriteLine("unable to render console"); Debug.WriteLine(e.Message); } CGameEngine.Device3D.RenderState.FogEnable = fog_state; } }
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(); }
/// <summary> /// Creates a vertex buffer for a transformed textured quad matching /// the given rectangle and stores it in vertexBuffer /// </summary> /// <param name="wx"></param> /// <param name="wy"></param> /// <param name="wwidth"></param> /// <param name="wheight"></param> private void CreateVertexBuffer(int wx, int wy, int wwidth, int wheight) { if (_vertexBuffer == null) { Log.Debug("Subtitle: Creating vertex buffer"); _vertexBuffer = new VertexBuffer(typeof (CustomVertex.TransformedTextured), 4, GUIGraphicsContext.DX9Device, 0, CustomVertex.TransformedTextured.Format, GUIGraphicsContext.GetTexturePoolType()); _wx = _wy = _wwidth = _wheight = 0; } if (_wx != wx || _wy != wy || _wwidth != wwidth || _wheight != wheight) { Log.Debug("Subtitle: Setting vertices"); CustomVertex.TransformedTextured[] verts = (CustomVertex.TransformedTextured[])_vertexBuffer.Lock(0, 0); // upper left verts[0] = new CustomVertex.TransformedTextured(wx, wy, 0, 1, 0, 0); // upper right verts[1] = new CustomVertex.TransformedTextured(wx + wwidth, wy, 0, 1, 1, 0); // lower left verts[2] = new CustomVertex.TransformedTextured(wx, wy + wheight, 0, 1, 0, 1); // lower right verts[3] = new CustomVertex.TransformedTextured(wx + wwidth, wy + wheight, 0, 1, 1, 1); _vertexBuffer.Unlock(); // remember what the vertexBuffer is set to _wy = wy; _wx = wx; _wheight = wheight; _wwidth = wwidth; } }
/// <summary> /// Creates a vertex buffer for a transformed textured quad matching /// the given rectangle and stores it in vertexBuffer /// </summary> /// <param name="wx"></param> /// <param name="wy"></param> /// <param name="wwidth"></param> /// <param name="wheight"></param> private void CreateVertexBuffer(int wx, int wy, int wwidth, int wheight) { if (_vertexBuffer == null) { Log.Debug("Subtitle: Creating vertex buffer"); var usage = OSInfo.OSInfo.VistaOrLater() ? Usage.Dynamic | Usage.WriteOnly : 0; _vertexBuffer = new VertexBuffer(typeof (CustomVertex.TransformedTextured), 4, GUIGraphicsContext.DX9Device, usage, CustomVertex.TransformedTextured.Format, GUIGraphicsContext.GetTexturePoolType()); _wx = _wy = _wwidth = _wheight = 0; } if (_wx != wx || _wy != wy || _wwidth != wwidth || _wheight != wheight) { Log.Debug("Subtitle: Setting vertices"); CustomVertex.TransformedTextured[] verts = (CustomVertex.TransformedTextured[])_vertexBuffer.Lock(0, 0); // upper left verts[0] = new CustomVertex.TransformedTextured(wx, wy, 0, 1, 0, 0); // upper right verts[1] = new CustomVertex.TransformedTextured(wx + wwidth, wy, 0, 1, 1, 0); // lower left verts[2] = new CustomVertex.TransformedTextured(wx, wy + wheight, 0, 1, 0, 1); // lower right verts[3] = new CustomVertex.TransformedTextured(wx + wwidth, wy + wheight, 0, 1, 1, 1); _vertexBuffer.SetData(verts, 0, LockFlags.None); // remember what the vertexBuffer is set to _wy = wy; _wx = wx; _wheight = wheight; _wwidth = wwidth; } }
public bool BuildTexturedQuads(Rectangle targetArea, out TexturedQuad[] quads) { // calc where each point is int left = (int)Math.Floor((double)targetArea.Left / MatrixSquareCount1D); int right = (int)Math.Floor((double)targetArea.Right / MatrixSquareCount1D); if (targetArea.Right % MatrixSquareCount1D == 0) { right--; } int top = (int)Math.Floor((double)targetArea.Top / MatrixSquareCount1D); int bottom = (int)Math.Floor((double)targetArea.Bottom / MatrixSquareCount1D); if (targetArea.Bottom % MatrixSquareCount1D == 0) { bottom--; } // process intersections into quads TexturedQuad[] temp = new TexturedQuad[(right - left) * (bottom - top)]; int tempCount = 0; for (int x = left; x <= right; x++) { for (int y = top; y < bottom; y++) { Texture square = MatrixSquares[x][y]; if (square != null) { int bLeft = x * MatrixSquareSize; int bRight = bLeft + MatrixSquareSize; int bTop = y * MatrixSquareSize; int bBottom = bTop + MatrixSquareSize; // test to see if intersects this square if (targetArea.Left > bRight || targetArea.Right < bLeft || targetArea.Top > bBottom || targetArea.Bottom < bTop) { continue; } // clip original target area int rLeft = targetArea.Left < bLeft ? bLeft : targetArea.Left; int rRight = targetArea.Right > bRight ? bRight : targetArea.Right; int rTop = targetArea.Top < bTop ? bTop : targetArea.Top; int rBottom = targetArea.Bottom > bBottom ? bBottom : targetArea.Bottom; CustomVertex.TransformedTextured[] quad = new CustomVertex.TransformedTextured[] { new CustomVertex.TransformedTextured(rLeft, rTop, 1, 1, 0, 0), new CustomVertex.TransformedTextured(rRight, rTop, 1, 1, 1, 0), new CustomVertex.TransformedTextured(rLeft, rBottom, 1, 1, 0, 1), new CustomVertex.TransformedTextured(rRight, rBottom, 1, 1, 1, 1) }; temp[tempCount++] = new TexturedQuad(quad, square); } } } // refactor quads array if (tempCount > 0) { quads = new TexturedQuad[tempCount]; Array.Copy(temp, quads, tempCount); return(true); } else { quads = null; return(false); } }
public static TextureMatrixLayer[] RenderDatabaseTree(RasterDatabase.RasterDatabase db, Device device) { // setup device device.RenderState.ZBufferEnable = false; device.Indices = null; device.VertexFormat = CustomVertex.TransformedTextured.Format; //device.Transform.World = Matrix.Identity; Surface rt0 = device.GetRenderTarget(0); // setup template quad CustomVertex.TransformedTextured[] tQuad = new CustomVertex.TransformedTextured[4]; foreach (DataLayer layer in db.Layers) { RectangleGroupQuadTree tree = db.ProduceLayerMipMap(layer, 2048); Texture[][] textures = new Texture[tree.Depth][]; for (int i = 1; i <= tree.Depth; i++) { RectangleGroupQuadTree.GroupNode[] nodes; tree.GetNodes(i, out nodes); textures[i] = new Texture[nodes.Length]; // render each node to texture int texIdx = 0; foreach (RectangleGroupQuadTree.GroupNode node in nodes) { Texture texture = textures[i][texIdx++] = new Texture(device, node.NodeArea.Width, node.NodeArea.Height, 0, Usage.WriteOnly, Format.X8R8G8B8, Pool.Managed); device.SetRenderTarget(0, texture.GetSurfaceLevel(0)); device.Clear(ClearFlags.Target, Color.Black, 1, 0); device.BeginScene(); // draw each rectangle quad foreach (DataArea area in node.Rectangles) { // setup quad tQuad[0] = new CustomVertex.TransformedTextured(area.Area.Left, area.Area.Top, 1, 1, area.TexCoords.Left, area.TexCoords.Top); tQuad[1] = new CustomVertex.TransformedTextured(area.Area.Right, area.Area.Top, 1, 1, area.TexCoords.Right, area.TexCoords.Top); tQuad[2] = new CustomVertex.TransformedTextured(area.Area.Left, area.Area.Bottom, 1, 1, area.TexCoords.Left, area.TexCoords.Bottom); tQuad[3] = new CustomVertex.TransformedTextured(area.Area.Right, area.Area.Bottom, 1, 1, area.TexCoords.Right, area.TexCoords.Bottom); // render quad device.SetTexture(0, (Texture)area.Data); device.DrawUserPrimitives(PrimitiveType.TriangleStrip, 2, tQuad); } device.EndScene(); } } } device.SetRenderTarget(0, rt0); device.RenderState.ZBufferEnable = true; return(null); }
public static TextureMatrixLayer[] RenderDatabaseTree(RasterDatabase.RasterDatabase db, Device device) { // setup device device.RenderState.ZBufferEnable = false; device.Indices = null; device.VertexFormat = CustomVertex.TransformedTextured.Format; //device.Transform.World = Matrix.Identity; Surface rt0 = device.GetRenderTarget(0); // setup template quad CustomVertex.TransformedTextured[] tQuad = new CustomVertex.TransformedTextured[4]; foreach(DataLayer layer in db.Layers) { RectangleGroupQuadTree tree = db.ProduceLayerMipMap(layer, 2048); Texture[][] textures = new Texture[tree.Depth][]; for (int i = 1; i <= tree.Depth; i++) { RectangleGroupQuadTree.GroupNode[] nodes; tree.GetNodes(i, out nodes); textures[i] = new Texture[nodes.Length]; // render each node to texture int texIdx = 0; foreach (RectangleGroupQuadTree.GroupNode node in nodes) { Texture texture = textures[i][texIdx++] = new Texture(device, node.NodeArea.Width, node.NodeArea.Height, 0, Usage.WriteOnly, Format.X8R8G8B8, Pool.Managed); device.SetRenderTarget(0, texture.GetSurfaceLevel(0)); device.Clear(ClearFlags.Target, Color.Black, 1, 0); device.BeginScene(); // draw each rectangle quad foreach (DataArea area in node.Rectangles) { // setup quad tQuad[0] = new CustomVertex.TransformedTextured(area.Area.Left, area.Area.Top, 1, 1, area.TexCoords.Left, area.TexCoords.Top); tQuad[1] = new CustomVertex.TransformedTextured(area.Area.Right, area.Area.Top, 1, 1, area.TexCoords.Right, area.TexCoords.Top); tQuad[2] = new CustomVertex.TransformedTextured(area.Area.Left, area.Area.Bottom, 1, 1, area.TexCoords.Left, area.TexCoords.Bottom); tQuad[3] = new CustomVertex.TransformedTextured(area.Area.Right, area.Area.Bottom, 1, 1, area.TexCoords.Right, area.TexCoords.Bottom); // render quad device.SetTexture(0, (Texture)area.Data); device.DrawUserPrimitives(PrimitiveType.TriangleStrip, 2, tQuad); } device.EndScene(); } } } device.SetRenderTarget(0, rt0); device.RenderState.ZBufferEnable = true; return null; }
public bool BuildTexturedQuads(Rectangle targetArea, out TexturedQuad[] quads) { // calc where each point is int left = (int)Math.Floor((double)targetArea.Left / MatrixSquareCount1D); int right = (int)Math.Floor((double)targetArea.Right / MatrixSquareCount1D); if (targetArea.Right % MatrixSquareCount1D == 0) right--; int top = (int)Math.Floor((double)targetArea.Top / MatrixSquareCount1D); int bottom = (int)Math.Floor((double)targetArea.Bottom / MatrixSquareCount1D); if (targetArea.Bottom % MatrixSquareCount1D == 0) bottom--; // process intersections into quads TexturedQuad[] temp = new TexturedQuad[(right - left) * (bottom - top)]; int tempCount = 0; for (int x = left; x <= right; x++) { for (int y = top; y < bottom; y++) { Texture square = MatrixSquares[x][y]; if (square != null) { int bLeft = x * MatrixSquareSize; int bRight = bLeft + MatrixSquareSize; int bTop = y * MatrixSquareSize; int bBottom = bTop + MatrixSquareSize; // test to see if intersects this square if (targetArea.Left > bRight || targetArea.Right < bLeft || targetArea.Top > bBottom || targetArea.Bottom < bTop) continue; // clip original target area int rLeft = targetArea.Left < bLeft ? bLeft : targetArea.Left; int rRight = targetArea.Right > bRight ? bRight : targetArea.Right; int rTop = targetArea.Top < bTop ? bTop : targetArea.Top; int rBottom = targetArea.Bottom > bBottom ? bBottom : targetArea.Bottom; CustomVertex.TransformedTextured[] quad = new CustomVertex.TransformedTextured[] { new CustomVertex.TransformedTextured(rLeft, rTop, 1, 1, 0, 0), new CustomVertex.TransformedTextured(rRight, rTop, 1, 1, 1, 0), new CustomVertex.TransformedTextured(rLeft, rBottom, 1, 1, 0, 1), new CustomVertex.TransformedTextured(rRight, rBottom, 1, 1, 1, 1) }; temp[tempCount++] = new TexturedQuad(quad, square); } } } // refactor quads array if (tempCount > 0) { quads = new TexturedQuad[tempCount]; Array.Copy(temp, quads, tempCount); return true; } else { quads = null; return false; } }
public void Render() { try { bool fog_state = CGameEngine.Device3D.RenderState.FogEnable; CGameEngine.Device3D.RenderState.FogEnable = false; CustomVertex.TransformedTextured[] data = new CustomVertex.TransformedTextured[4]; data[0].X = 0.0f; data[0].Y = 0.0f; data[0].Z = 1.0f; data[0].Tu = 0.0f; data[0].Tv = 0.0f; data[1].X = CGameEngine.Device3D.Viewport.Width; data[1].Y = 0.0f; data[1].Z = 1.0f; data[1].Tu = 1.0f; data[1].Tv = 0.0f; data[2].X = 0.0f; data[2].Y = CGameEngine.Device3D.Viewport.Height; data[2].Z = 1.0f; data[2].Tu = 0.0f; data[2].Tv = 1.0f; data[3].X = CGameEngine.Device3D.Viewport.Width; data[3].Y = CGameEngine.Device3D.Viewport.Height; data[3].Z = 1.0f; data[3].Tu = 1.0f; data[3].Tv = 1.0f; m_vb.SetData(data, 0, 0); CGameEngine.Device3D.SetStreamSource(0, m_vb, 0); CGameEngine.Device3D.VertexFormat = CustomVertex.TransformedTextured.Format; // Set the texture CGameEngine.Device3D.SetTexture(0, m_Background.GetTexture()); // Render the screen background CGameEngine.Device3D.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2); // Set diffuse blending for alpha set in vertices. CGameEngine.Device3D.RenderState.AlphaBlendEnable = true; CGameEngine.Device3D.RenderState.SourceBlend = Blend.SourceAlpha; CGameEngine.Device3D.RenderState.DestinationBlend = Blend.InvSourceAlpha; // Enable alpha testing (skips pixels with less than a certain alpha.) if (CGameEngine.Device3D.DeviceCaps.AlphaCompareCaps.SupportsGreaterEqual) { CGameEngine.Device3D.RenderState.AlphaTestEnable = true; CGameEngine.Device3D.RenderState.ReferenceAlpha = 0x08; CGameEngine.Device3D.RenderState.AlphaFunction = Compare.GreaterEqual; } // copy on the buttons foreach (ImageButton button in m_buttons) { button.HoverTest(m_MousePoint); if (m_bMouseIsDown && !m_bMouseWasDown) { button.ClickTest(m_MousePoint); } button.Render(); } m_bMouseWasDown = m_bMouseIsDown; // draw cursor Rectangle mouserect = new Rectangle(m_MousePoint, m_Cursor.GetSize()); try { data[0].X = (float)mouserect.X; data[0].Y = (float)mouserect.Y; data[0].Z = 0.0f; data[0].Tu = 0.0f; data[0].Tv = 0.0f; data[1].X = (float)(mouserect.X + mouserect.Width); data[1].Y = (float)mouserect.Y; data[1].Z = 0.0f; data[1].Tu = 1.0f; data[1].Tv = 0.0f; data[2].X = (float)mouserect.X; data[2].Y = (float)(mouserect.Y + mouserect.Height); data[2].Z = 0.0f; data[2].Tu = 0.0f; data[2].Tv = 1.0f; data[3].X = (float)(mouserect.X + mouserect.Width); data[3].Y = (float)(mouserect.Y + mouserect.Height); data[3].Z = 0.0f; data[3].Tu = 1.0f; data[3].Tv = 1.0f; m_vb.SetData(data, 0, 0); CGameEngine.Device3D.SetStreamSource(0, m_vb, 0); CGameEngine.Device3D.VertexFormat = CustomVertex.TransformedTextured.Format; // Set the texture CGameEngine.Device3D.SetTexture(0, m_Cursor.GetTexture()); // Set diffuse blending for alpha set in vertices. CGameEngine.Device3D.RenderState.AlphaBlendEnable = true; CGameEngine.Device3D.RenderState.SourceBlend = Blend.SourceAlpha; CGameEngine.Device3D.RenderState.DestinationBlend = Blend.InvSourceAlpha; // Enable alpha testing (skips pixels with less than a certain alpha.) if (CGameEngine.Device3D.DeviceCaps.AlphaCompareCaps.SupportsGreaterEqual) { CGameEngine.Device3D.RenderState.AlphaTestEnable = true; CGameEngine.Device3D.RenderState.ReferenceAlpha = 0x08; CGameEngine.Device3D.RenderState.AlphaFunction = Compare.GreaterEqual; } // Render the face CGameEngine.Device3D.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2); } catch (DirectXException d3de) { Console.AddLine("Unable to display cursor "); Console.AddLine(d3de.ErrorString); } catch (Exception e) { Console.AddLine("Unable to display cursor "); Console.AddLine(e.Message); } CGameEngine.Device3D.RenderState.FogEnable = fog_state; } catch (DirectXException d3de) { Console.AddLine("Error rendering Option Screen "); Console.AddLine(d3de.ErrorString); } catch (Exception e) { Console.AddLine("Error rendering Option Screen "); Console.AddLine(e.Message); } }