void Render(const Vect2 &pos, const Vect2 &size) { Texture *texture = bitmapImage.GetTexture(); if(texture) { if(bUseColorKey) { Shader *lastPixelShader = GetCurrentPixelShader(); DWORD alpha = ((opacity*255/100)&0xFF); DWORD outputColor = (alpha << 24) | color&0xFFFFFF; LoadPixelShader(colorKeyShader); float fSimilarity = float(keySimilarity)*0.01f; float fBlend = float(keyBlend)*0.01f; colorKeyShader->SetColor(colorKeyShader->GetParameter(2), keyColor); colorKeyShader->SetFloat(colorKeyShader->GetParameter(3), fSimilarity); colorKeyShader->SetFloat(colorKeyShader->GetParameter(4), fBlend); DrawSprite(texture, outputColor, pos.x, pos.y, pos.x+size.x, pos.y+size.y); LoadPixelShader(lastPixelShader); } else { DWORD alpha = ((opacity*255/100)&0xFF); DWORD outputColor = (alpha << 24) | color&0xFFFFFF; DrawSprite(texture, outputColor, pos.x, pos.y, pos.x+size.x, pos.y+size.y); } } }
void MeshEntity::RenderWireframe() { traceInFast(MeshEntity::RenderWireframe); Shader *shader = GetCurrentVertexShader(); if(shader) shader->SetColor(shader->GetParameter(1), wireframeColor | 0xFF000000); MatrixPush(); MatrixMultiply(invTransform); LoadVertexBuffer(VertBuffer); LoadIndexBuffer(mesh->WireframeBuffer); GS->DrawBare(GS_LINES); MatrixPop(); traceOutFast; }
void RotationManipulator::RenderScaled(const Vect &cameraDir, float scale) { traceInFast(RotationManipulator::RenderScaled); DWORD i; Shader *rotManipShader = GetVertexShader(TEXT("Editor:RotationManipulator.vShader")); LoadVertexShader(rotManipShader); LoadPixelShader(GetPixelShader(TEXT("Base:SolidColor.pShader"))); rotManipShader->SetVector(rotManipShader->GetParameter(2), cameraDir); MatrixPush(); MatrixTranslate(GetWorldPos()); MatrixScale(scale, scale, scale); for(i=0; i<3; i++) { Vect axisColor(0.0f, 0.0f, 0.0f); axisColor.ptr[i] = 1.0f; if(i == activeAxis) axisColor.Set(1.0f, 1.0f, 0.0f); else axisColor.ptr[i] = 1.0f; rotManipShader->SetVector(rotManipShader->GetParameter(1), axisColor); LoadVertexBuffer(axisBuffers[i]); LoadIndexBuffer(NULL); Draw(GS_LINESTRIP); } LoadVertexBuffer(NULL); //---------------------------------------------------- Shader *solidShader = GetVertexShader(TEXT("Base:SolidColor.vShader")); LoadVertexShader(solidShader); MatrixPush(); MatrixRotate(Quat().SetLookDirection(cameraDir)); LoadVertexBuffer(axisBuffers[2]); LoadIndexBuffer(NULL); solidShader->SetColor(solidShader->GetParameter(1), 0.5, 0.5, 0.5, 0.5); Draw(GS_LINESTRIP); MatrixScale(1.25f, 1.25f, 1.25f); //--------------- if(activeAxis == 4) solidShader->SetColor(solidShader->GetParameter(1), 1.0f, 1.0f, 0.0, 1.0f); else solidShader->SetColor(solidShader->GetParameter(1), 0.8, 0.8, 0.8, 0.8); Draw(GS_LINESTRIP); MatrixPop(); MatrixPop(); LoadVertexShader(NULL); LoadPixelShader(NULL); traceOutFast; }