本文整理汇总了C++中GEdge::bottom方法的典型用法代码示例。如果您正苦于以下问题:C++ GEdge::bottom方法的具体用法?C++ GEdge::bottom怎么用?C++ GEdge::bottom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GEdge
的用法示例。
在下文中一共展示了GEdge::bottom方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: shadeDevicePolygon
void MyCanvas::shadeDevicePolygon(std::vector<GEdge>& Edges, GShader* shader)
{
assert(shader != nullptr);
if (Edges.size() < 2)
{
//printf("Error: ShadeDevicePolygon needs at least 2 edges to draw\n");
return;
}
// Sort the edges from top to bottom, left to right
std::sort(Edges.begin(), Edges.end());
// The first two edges will be the top most edges
GEdge LeftEdge = Edges[0];
GEdge RightEdge = Edges[1];
// Get start of pixel address for bitmap and offset to the top row
GPixel *DstPixels = (GPixel*)((char*)Bitmap.pixels() + Bitmap.fRowBytes * LeftEdge.top());
// Set the context in the shader to the CTM
float TwoRows[6];
CTM.GetTwoRows(TwoRows);
shader->setContext(TwoRows);
int EdgeCounter = 2;
for (int y = LeftEdge.top(); y < Edges.back().bottom(); ++y)
{
int startX = Utility::round(LeftEdge.currentX());
int count = (int)(RightEdge.currentX() - LeftEdge.currentX());
count = Utility::clamp(1, count, BmpRect.width() - 1);
/* Allocate a row of pixels to calculate shader pixel values
* then blend shader pixels into the dst bitmap */
GPixel *row = new GPixel[count];
shader->shadeRow(startX, y, count, row);
blendRow(DstPixels, startX, row, count);
delete[] row;
// Move currentX of the left and right edges to the next row
LeftEdge.moveCurrentX(1.0f);
RightEdge.moveCurrentX(1.0f);
// Check left and right edge for y has passed bottom, if we have edges left then set the next edge
if (y >= LeftEdge.bottom() && EdgeCounter < Edges.size())
{
LeftEdge = Edges[EdgeCounter];
++EdgeCounter;
}
if (y >= RightEdge.bottom() && EdgeCounter < Edges.size())
{
RightEdge = Edges[EdgeCounter];
++EdgeCounter;
}
DstPixels = (GPixel*)((char*)DstPixels + Bitmap.fRowBytes);
}
}