本文整理汇总了C++中VertexArray::append方法的典型用法代码示例。如果您正苦于以下问题:C++ VertexArray::append方法的具体用法?C++ VertexArray::append怎么用?C++ VertexArray::append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VertexArray
的用法示例。
在下文中一共展示了VertexArray::append方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
Player(int player, float x, float y){
// == Создание игрока ==
rectangle.setPosition(Vector2f(x, y)); //Позиция игрока
this->player = player; //ID игрока
rectangle.setSize(Vector2f(20, 20)); //Размер
rectangle.setFillColor(Color::Green); //Цвет
// == Создание пушки ==
Vector2f centerTank = { 0, 0 };
centerTank.x = rectangle.getPosition().x + (rectangle.getSize().x / 2); //Центр танка по x
centerTank.y = rectangle.getPosition().y + (rectangle.getSize().y / 2); //Центр танка по y
turret.setPrimitiveType(LinesStrip);
turret.append(centerTank); //Начало пушки из танка
centerTank.y -= 25;
turret.append(centerTank); //Смещение по y на 10
};
示例2: main
int main(int argc, char*argv[]) {
// ████████ INITS 1 ████████
#ifndef COMMON_INITS1
cfg.init("bedlab.cfg");
ui2::init_ui();
Vec2i windowsize;
Vec2i screen_resolution = { int(VideoMode::getDesktopMode().width), int(VideoMode::getDesktopMode().height) };
if (cfg.getvar<int>("auto_winsize")) {
auto window_scale = cfg.getvar<Vec2>("window_scale");
windowsize = Vec2i(scal(Vec2(screen_resolution), window_scale));
}
else {
windowsize = cfg.getvar<Vec2i>("windowsize");
}
winsize = Vec2(windowsize);
//UI.init_console(); // ALWAYS AFTER SO IT CAN GET WINDOW SIZE
ui2::init_console(); // ALWAYS AFTER SO IT CAN GET WINDOW SIZE
wincenter = 0.5f*Vec2(windowsize);
Vec2i windowpos;
VideoMode::getDesktopMode().height;
if (cfg.getvar<int>("stick_left")) {
windowpos = Vec2i(
screen_resolution.x - windowsize.x - 10,
screen_resolution.y - windowsize.y - 40
);
}
else
windowpos = (Vec2i(5, 25));
sf::RenderWindow window(sf::VideoMode(windowsize.x, windowsize.y),
"bedlab!", 7
//,sf::ContextSettings(0, 0, 1)
);
window.setFramerateLimit(cfg.getvar<int>("fps_max"));
frame_duration = 1.0f / cfg.getvar<int>("fps_max");
window.setPosition(windowpos);
vector<string> keys;
auto choice = cfg.getstr("app");
// show_keys(cfg.getstr("app"), keys);
#endif
// ████████ INITS2 ████████
#ifndef COMMON_INITS2
// we don't have a class/interface/struct with data, everything is local to this function, like a classic stack that all programs are anyway.
// Texture cursor_tx;
// if (!cursor_tx.loadFromFile(cfg.getstr("cursor")))
// cout << "did not load cursor" << endl;
// Sprite cursor;
// cursor.setTexture(cursor_tx);
// cursor.setOrigin(3, 3);
CircleShape cursor = mkcircle({ 0,0 }, Color::Transparent, 3, 1);
Color background = cfg.getvar<Color>("background");
window.setMouseCursorVisible(false);
Vec2 mpos;
bool leftclicked = false, rightclicked = false;
// view and zoom
View view, ui_view;
ui_view = view = window.getDefaultView();
float zoomlevel = 1;
Vec2 mpos_abs;
float frame_duration = 1.0f / cfg.getvar<int>("fps_max");
#endif // COMMON_INITS2
// ████████ APP ACTUAL ████████
float smaller_size = min(windowsize.y, windowsize.x);
string descriptor;
Transform transf;
transf.translate(10, 10);
transf.scale(Vec2(smaller_size, smaller_size));
transf_glob = transf;
auto addvt_col = [&](Vec2 v, Color col) {
glob_vert_single.append(Vertex(transf.transformPoint(v), col));
};
auto va_to_va_col = [&](mesh2d&idxd_v, Color col) {
for (unsigned int i = 0; i < idxd_v.size(); ++i)
{
// if (i<)
addvt_col(idxd_v[i].first, col);
addvt_col(idxd_v[i].second, col);
//addpt(idxd_v[i].first, Orange, 5);
//addpt(idxd_v[i].second, Cyan, 5);
}
for (auto&a : idxd_v.verts) {
addpt_col(a, col, 2);
}
};
auto stripify = [&](vector<Vec2> strip, Color col) {
glob_vert_single = VertexArray(LineStrip);
//.........这里部分代码省略.........