当前位置: 首页>>代码示例>>C++>>正文


C++ BBox::height方法代码示例

本文整理汇总了C++中BBox::height方法的典型用法代码示例。如果您正苦于以下问题:C++ BBox::height方法的具体用法?C++ BBox::height怎么用?C++ BBox::height使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BBox的用法示例。


在下文中一共展示了BBox::height方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: gl_draw_image_section

void gl_draw_image_section(GLimage& img, const BBox& section, int x, int y,
		const Colour& c) {
	if (section.width() == 0 || section.height() == 0)
		return;
	float xscale = img.texw / img.width, yscale = img.texh / img.height;

	float tx1 = section.x1 * xscale, tx2 = section.x2 * xscale;
	float ty1 = section.y1 * yscale, ty2 = section.y2 * yscale;

	int x2 = x + section.width(), y2 = y + section.height();

	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, img.texture);

	glColor4ub(c.r, c.g, c.b, c.a);

	glBegin(GL_QUADS);
	//Draw our four points, clockwise.
	glTexCoord2f(tx1, ty1);
	glVertex2i(x, y);

	glTexCoord2f(tx2, ty1);
	glVertex2i(x2, y);

	glTexCoord2f(tx2, ty2);
	glVertex2i(x2, y2);

	glTexCoord2f(ty1, ty2);
	glVertex2i(x, y2);

	glEnd();
	glDisable(GL_TEXTURE_2D);
	//Don't use glBindTexture(GL_TEXTURE_2D, NULL);
}
开发者ID:Zolomon,项目名称:lanarts,代码行数:34,代码来源:display_image.cpp

示例2: gl_subimage_from_bytes

void gl_subimage_from_bytes(GLimage& img, const BBox& region, char* data,
		int type) {
	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, img.texture);

	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexSubImage2D(GL_TEXTURE_2D, 0, region.x1, region.y1, region.width(),
			region.height(), type, GL_UNSIGNED_BYTE, data);
	glDisable(GL_TEXTURE_2D);
}
开发者ID:gigimoi,项目名称:lanarts,代码行数:13,代码来源:display_image.cpp

示例3: deserialize

void GameScreenSet::deserialize(GameState *gs, SerializeBuffer &serializer) {
    serializer.read_int(current_screen);
    simulation_map = read_gamemap(gs, serializer);
    serializer.read_container(screens, [&](GameScreen& screen) {
        screen.deserialize(gs, serializer);
    });

    GameSettings& settings = gs->game_settings();
    int n_local_players = 0;
    for (PlayerDataEntry &player: gs->player_data().all_players()) {
        if (player.is_local_player) {
            n_local_players++;
        }
    }
    // Number of split-screens tiled together
    int n_x = 1, n_y = 1;
    if (n_local_players <= 2) {
        n_x = n_local_players;
    } else if (n_local_players <= 4) {
        // More than 2, less than 4? Try 2x2 tiling
        n_x = 2, n_y = 2;
    } else if (n_local_players <= 6) {
        n_x = 3, n_y = 2;
    } else {
        LANARTS_ASSERT(n_local_players <= 9);
        // Last resort, Try 3x3 tiling
        n_x = 3, n_y = 3;
    }

    const int WIDTH = settings.view_width / n_x;
    const int HEIGHT = settings.view_height / n_y; // / N_PLAYERS;
    std::vector<BBox> bounding_boxes;
    for (GameScreen& screen : screens) {
        const int x1 = (screen.index % n_x) * WIDTH, y1 = (screen.index / n_x) * HEIGHT;
        bounding_boxes.push_back(BBox {x1, y1, x1 + WIDTH, y1 + HEIGHT});
    }
    if (bounding_boxes.size() == 3) {
        bounding_boxes[1] = {WIDTH, 0, settings.view_width, settings.view_height};
    }
    for (GameScreen& screen : screens) {
        BBox b = bounding_boxes[screen.index];
        screen.window_region = b;
        screen.hud = GameHud {
                BBox(b.x2 - GAME_SIDEBAR_WIDTH, b.y1, b.x2, b.y2),
                BBox(b.x1, b.y1, b.x2 - GAME_SIDEBAR_WIDTH, b.y2)
        };
        screen.view = GameView {0, 0, b.width() - GAME_SIDEBAR_WIDTH, b.height()};
    }
}
开发者ID:ludamad,项目名称:lanarts,代码行数:49,代码来源:GameScreen.cpp

示例4: overlaps

bool BBox::overlaps(const BBox& other) const
{
    return
        std::abs(xMid() - other.xMid()) < width()  / 2 + other.width()  / 2 &&
        std::abs(yMid() - other.yMid()) < height() / 2 + other.height() / 2;
}
开发者ID:jstopchick,项目名称:greyhound,代码行数:6,代码来源:grey-common.cpp


注:本文中的BBox::height方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。