int DrawIndexedPrimitivesHook(IntPtr devicePtr, SlimDX.Direct3D9.PrimitiveType primitiveType, int baseVertexIndex, int minimumVertexIndex, int numVertices, int startIndex, int primCount) { using (SlimDX.Direct3D9.Device device = SlimDX.Direct3D9.Device.FromPointer(devicePtr)) { Primitive prim = new Primitive(primCount, numVertices); int hRet = 0; try { if (Interface.CaptureFrame) { RipModel(device, primitiveType, baseVertexIndex, startIndex, primCount); } //if new primitive being rendered, add it to our list if (!prims.Contains(prim)) { prims.Add(prim); } Primitive selectedPrim = prims.GetSelectedPrimitive(); if (selectedPrim != null) { if (selectedPrim.Equals(prim)) { if (RedTexture == null) { RedTexture = SlimDX.Direct3D9.Texture.FromMemory(device, red); } if (Interface.chamed == true) { selectedPrim.Chamed = true; Interface.Togglecham(); } device.SetRenderState(SlimDX.Direct3D9.RenderState.FillMode, SlimDX.Direct3D9.FillMode.Solid); device.SetTexture(0, RedTexture); if (selectedPrim.Chamed) { //device.Clear(ClearFlags.ZBuffer, Color.Red, 1.0f, 0); device.SetRenderState(SlimDX.Direct3D9.RenderState.ZEnable, false); hRet = device.DrawIndexedPrimitives(primitiveType, baseVertexIndex, minimumVertexIndex, numVertices, startIndex, primCount).Code; device.SetRenderState(SlimDX.Direct3D9.RenderState.ZEnable, true); } if (Interface.rip) { if (!Interface.CaptureFrame) { RipModel(device, primitiveType, baseVertexIndex, startIndex, primCount); Interface.ToggleRip(); } } hRet = device.DrawIndexedPrimitives(primitiveType, baseVertexIndex, minimumVertexIndex, numVertices, startIndex, primCount).Code; } } //if not to display, don't render if (prims.IndexOf(prim) != -1) { if (prims[prims.IndexOf(prim)].Displayed == false) { return(0); } } } catch (Exception e) { Interface.ReportException(e); return(hRet); } if (hRet == 0) { if (prims[prims.IndexOf(prim)].Chamed == false) { hRet = device.DrawIndexedPrimitives(primitiveType, baseVertexIndex, minimumVertexIndex, numVertices, startIndex, primCount).Code; } else { PixelShader previous = device.PixelShader; if (chamPixelShader == null) { chamPixelShader = new PixelShader(device, ShaderBytecode.Compile("float4 PShader(float4 position : SV_POSITION) : SV_Target\n" + "{\nreturn float4(1.0f, 1.0f, 0.0f, 1.0f);\n}", "PShader", "ps_3_0", ShaderFlags.None)); } device.PixelShader = chamPixelShader; hRet = device.DrawIndexedPrimitives(primitiveType, baseVertexIndex, minimumVertexIndex, numVertices, startIndex, primCount).Code; device.SetRenderState(SlimDX.Direct3D9.RenderState.ZEnable, false); hRet = device.DrawIndexedPrimitives(primitiveType, baseVertexIndex, minimumVertexIndex, numVertices, startIndex, primCount).Code; device.SetRenderState(RenderState.ZEnable, true); device.PixelShader = previous; } } return(hRet); } }