本文整理汇总了C++中gdiplus::Graphics::GetTransform方法的典型用法代码示例。如果您正苦于以下问题:C++ Graphics::GetTransform方法的具体用法?C++ Graphics::GetTransform怎么用?C++ Graphics::GetTransform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gdiplus::Graphics
的用法示例。
在下文中一共展示了Graphics::GetTransform方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Render
void GameManager::Render(Gdiplus::Graphics& canvas, const CRect& clientRect)
{
// Save the current transformation of the scene
Gdiplus::Matrix transform;
canvas.GetTransform(&transform);
// tell all of the game objects to render
for (GameObject* gameObjectPtr : Everything)
{
gameObjectPtr->Render(canvas, clientRect);
gameObjectPtr->Render(canvas, clientRect);
gameObjectPtr->Render(canvas, clientRect);
gameObjectPtr->Render(canvas, clientRect);
}
// Restore the transformation of the scene
canvas.SetTransform(&transform);
}
示例2: Render
void GameManager::Render(Gdiplus::Graphics& canvas, const CRect& clientRect)
{
////////////////////////////////////////////////////////////////////////////////
// Begin example code
// Save the current transformation of the scene
Gdiplus::Matrix transform;
canvas.GetTransform(&transform);
// Offset by the negative of the player direction
canvas.TranslateTransform(-(Gdiplus::REAL)playerPtr->location.X, -(Gdiplus::REAL)playerPtr->location.Y);
int numRows = clientRect.Height() / CellSize;
int numCols = clientRect.Width() / CellSize;
// draw horizontal lines for grid
for (int row = 0; row < numRows; ++row)
{
Vector2i start = Vector2i(0, row * CellSize);
Vector2i end = Vector2i(clientRect.Width(), row * CellSize);
GameFrameworkInstance.DrawLine(canvas,
start,
end,
Gdiplus::Color::White);
}
// draw vertical lines for grid
for (int col = 0; col < numCols; ++col)
{
Vector2i start = Vector2i(col * CellSize, 0);
Vector2i end = Vector2i(col * CellSize, clientRect.Height());
GameFrameworkInstance.DrawLine(canvas,
start,
end,
Gdiplus::Color::White);
}
// Draw all of the objects
for (GameObject* objectPtr : gameObjects)
{
objectPtr->Render(canvas);
}
// Render method demonstration (You can remove all of this code)
GameFrameworkInstance.DrawLine(canvas, Vector2i(200, 200), Vector2i(400, 200), Gdiplus::Color::White);
GameFrameworkInstance.DrawRectangle(canvas, AABBi(Vector2i(10, 110), Vector2i(100, 200)), false, Gdiplus::Color::White);
GameFrameworkInstance.DrawRectangle(canvas, AABBi(Vector2i(200, 110), Vector2i(300, 200)), true, Gdiplus::Color::White);
//// restore the transform
//canvas.SetTransform(&transform);
GameFrameworkInstance.DrawCircle(canvas, Vector2i(200, 200), 50, false, Gdiplus::Color::White);
GameFrameworkInstance.DrawCircle(canvas, Vector2i(400, 200), 50, true, Gdiplus::Color::White);
GameFrameworkInstance.DrawText(canvas, Vector2i(10, 300), 12, "Arial", "Hello World!", Gdiplus::Color::White);
// Load the image file Untitled.png from the Images folder. Give it the unique name of Image1
ImageWrapper* image1 = GameFrameworkInstance.GetLoadedImage(Image1);
GameFrameworkInstance.DrawImage(canvas, Vector2i(400, 400), image1);
// Restore the transformation of the scene
canvas.SetTransform(&transform);
// End example code
////////////////////////////////////////////////////////////////////////////////
// Build Menu
Vector2i dimensions = GameManagerInstance.GetScreenDimensions();
Vector2i centrePoint = dimensions * 0.1f;
GameFrameworkInstance.DrawRectangle(canvas,
AABBi(Vector2i(0, 0) + centrePoint,
Vector2i(150, 500) + centrePoint),
true, Gdiplus::Color::Gray);
GameFrameworkInstance.DrawText(canvas, Vector2i(10, 10) + centrePoint, 12, "Arial", "[1] Wall", Gdiplus::Color::White);
GameFrameworkInstance.DrawText(canvas, Vector2i(10, 35) + centrePoint, 12, "Arial", "[2] Damage Zone", Gdiplus::Color::White);
GameFrameworkInstance.DrawText(canvas, Vector2i(10, 60) + centrePoint, 12, "Arial", "[3] Healing Zone", Gdiplus::Color::White);
}