void Indicator::RenderBox(GraphicsDevice &GD, MatrixController &MC, float Radius, const Rectangle3f &Rect, RGBColor Color) { RenderCylinder(GD, MC, Radius, Vec3f(Rect.Min.x, Rect.Min.y, Rect.Min.z), Vec3f(Rect.Max.x, Rect.Min.y, Rect.Min.z), Color); RenderCylinder(GD, MC, Radius, Vec3f(Rect.Max.x, Rect.Min.y, Rect.Min.z), Vec3f(Rect.Max.x, Rect.Max.y, Rect.Min.z), Color); RenderCylinder(GD, MC, Radius, Vec3f(Rect.Max.x, Rect.Max.y, Rect.Min.z), Vec3f(Rect.Min.x, Rect.Max.y, Rect.Min.z), Color); RenderCylinder(GD, MC, Radius, Vec3f(Rect.Min.x, Rect.Max.y, Rect.Min.z), Vec3f(Rect.Min.x, Rect.Min.y, Rect.Min.z), Color); RenderCylinder(GD, MC, Radius, Vec3f(Rect.Min.x, Rect.Min.y, Rect.Min.z), Vec3f(Rect.Min.x, Rect.Min.y, Rect.Max.z), Color); RenderCylinder(GD, MC, Radius, Vec3f(Rect.Max.x, Rect.Min.y, Rect.Min.z), Vec3f(Rect.Max.x, Rect.Min.y, Rect.Max.z), Color); RenderCylinder(GD, MC, Radius, Vec3f(Rect.Max.x, Rect.Max.y, Rect.Min.z), Vec3f(Rect.Max.x, Rect.Max.y, Rect.Max.z), Color); RenderCylinder(GD, MC, Radius, Vec3f(Rect.Min.x, Rect.Max.y, Rect.Min.z), Vec3f(Rect.Min.x, Rect.Max.y, Rect.Max.z), Color); RenderCylinder(GD, MC, Radius, Vec3f(Rect.Min.x, Rect.Min.y, Rect.Max.z), Vec3f(Rect.Max.x, Rect.Min.y, Rect.Max.z), Color); RenderCylinder(GD, MC, Radius, Vec3f(Rect.Max.x, Rect.Min.y, Rect.Max.z), Vec3f(Rect.Max.x, Rect.Max.y, Rect.Max.z), Color); RenderCylinder(GD, MC, Radius, Vec3f(Rect.Max.x, Rect.Max.y, Rect.Max.z), Vec3f(Rect.Min.x, Rect.Max.y, Rect.Max.z), Color); RenderCylinder(GD, MC, Radius, Vec3f(Rect.Min.x, Rect.Max.y, Rect.Max.z), Vec3f(Rect.Min.x, Rect.Min.y, Rect.Max.z), Color); Matrix4 Scale = Matrix4::Scaling(Rect.Dimensions()); Matrix4 Translate = Matrix4::Translation(Rect.Min); MC.World = Scale * Translate; LPDIRECT3DDEVICE9 Device = GD.CastD3D9().GetDevice(); D3DCOLOR D3DColor = RGBColor(90, 90, 90); Device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_BLENDFACTOR); Device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVBLENDFACTOR); Device->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); Device->SetRenderState(D3DRS_BLENDFACTOR, D3DColor); _Box.SetColor(Color); _Box.Render(); Device->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); }
void D3D9PixelShader::Reset(GraphicsDevice &graphics) { FreeMemory(); HRESULT hr; _device = graphics.CastD3D9().GetDevice(); Assert(_device != NULL, "_device == NULL"); DWORD dwShaderFlags = 0; #ifdef DEBUG_PS dwShaderFlags |= D3DXSHADER_SKIPOPTIMIZATION | D3DXSHADER_DEBUG; #endif LPD3DXBUFFER pCode = NULL; LPD3DXBUFFER pErrors = NULL; PersistentAssert(Utility::FileExists(_shaderFile), String("Shader file not found: ") + _shaderFile); // Assemble the vertex shader from the file hr = D3DXCompileShaderFromFile( _shaderFile.CString(), NULL, NULL, "PShaderEntry", "ps_3_0", dwShaderFlags, &pCode, &pErrors, &_constantTable ); String ErrorString; if(pErrors) { char *ErrorMessage = (char *)pErrors->GetBufferPointer(); DWORD ErrorLength = pErrors->GetBufferSize(); ofstream file("ShaderDebug.txt"); for(UINT i = 0; i < ErrorLength; i++) { file << ErrorMessage[i]; ErrorString += String(ErrorMessage[i]); } file.close(); } PersistentAssert(!FAILED(hr), String("D3DXCompileShaderFromFile failed: ") + ErrorString); hr = _device->CreatePixelShader( (DWORD*)pCode->GetBufferPointer(), &_shader ); if(pErrors) { pErrors->Release(); } if(pCode) { pCode->Release(); } PersistentAssert(!FAILED(hr), "CreatePixelShader failed"); }
void D3D9Font::Reset(GraphicsDevice &graphics) { FreeMemory(); _Device = graphics.CastD3D9().GetDevice(); Assert(_Device != NULL, "Device == NULL"); HRESULT hr; hr = D3DXCreateFont( _Device, _FontHeight, // Height 0, // Width _FontWeight, // Weight 1, // MipLevels, 0 = autogen mipmaps FALSE, // Italic DEFAULT_CHARSET, // CharSet OUT_DEFAULT_PRECIS, // OutputPrecision DEFAULT_QUALITY, // Quality DEFAULT_PITCH | FF_DONTCARE, // PitchAndFamily _FontName.CString(), // pFaceName &_Font); // ppFont Assert(SUCCEEDED(hr) && _Font != NULL, "D3DXCreateFont failed"); }
void D3D9VertexShader::Init(const String &Filename, GraphicsDevice &GD) { _ShaderFile = Filename; Reset(GD.CastD3D9().GetDevice()); }
void D3D9Texture::Reset(GraphicsDevice &graphics) { _Device = graphics.CastD3D9().GetDevice(); }