本文整理汇总了C++中Transform::GetModelViewStack方法的典型用法代码示例。如果您正苦于以下问题:C++ Transform::GetModelViewStack方法的具体用法?C++ Transform::GetModelViewStack怎么用?C++ Transform::GetModelViewStack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transform
的用法示例。
在下文中一共展示了Transform::GetModelViewStack方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GuiButton
bool GuiButton(ui_context & ui, const ui_id id, string sprite, Transform & transform,
int x, int y, int width, int height, const mouse_info & mouse)
{
bool result = false;
bool mouseover = false;
int frame = 0;
int x1 = x - width / 2;
int x2 = x + width / 2;
int y1 = y - height / 2;
int y2 = y + height / 2;
if (!result && (mouse.x > x1 && mouse.x < x2) && (mouse.y > y1 && mouse.y < y2)) {
mouseover = true;
}
if (ui.active == id) {
frame = 2;
if (mouse.LMB == false) {
if (mouseover && ui.hot == id) {
result = true;
}
ui.active.owner = NULL;
}
} else if (ui.hot == id) {
if (!mouseover) {
ui.hot == NULL;
}
else if (mouse.LMB == true) {
ui.active = id;
}
}
if (mouseover && ui.active.owner == NULL) {
ui.hot = id;
frame = 1;
}
// get dimensions of sprite
SpritePtr btnSprite = g_Sprite.GetSprite(sprite);
const ivec4 & size = btnSprite->GetSize();
double wRatio = (double) width / (double) size.x;
double hRatio = (double) height / (double) size.y;
// draw the button
MatrixStack * mv = transform.GetModelViewStack();
mv->PushMatrix();
mv->Translate((float)x, (float)y, 0);
mv->Scale((float)wRatio, (float)hRatio, 1);
btnSprite->Draw(frame, transform);
mv->PopMatrix();
return result;
}
示例2: Draw
void Sprite::Draw(int frame, Transform & transform, int anchor, vec4 color)
{
// calculate st.uv texture offsets
assert(frame >= 0 && frame < frameCount);
int cols = size.z;
int rows = size.w;
vec4 offset;
// 0 1 2 3 4
// 5 6 7 8 9
// 10 11 12 13 14
// 15 16 17 18 19
// 20 21 22 23 24
int frameCol = frame % cols;
int frameRow = frame / cols;
// 0 - row 0, col 0
// 12 - row 2, col 2
// 24 - row 4, col 4
float tX = 1.f / cols;
float tY = 1.f / rows;
offset.x = tX * frameCol;
offset.y = tY * frameRow;
MatrixStack * mv = transform.GetModelViewStack();
mv->PushMatrix();
vec2 renderPos = GetAnchorCoords(anchor, vec2(0, 0), vec2(size.x, size.y));
renderPos += (size.xy() / 2);
mv->Translate(renderPos.x, renderPos.y, 0);
g_Sprite.SetupShader(transform.GetMVP(), offset, texture, color);
buffer.render(GL_TRIANGLE_STRIP);
mv->PopMatrix();
}