示例#1
0
Texture::Texture(
	std::shared_ptr<RawTexture> rt,
	int x,
	int y,
	int width,
	int height):
	m_rt(rt),
	m_x(x),
	m_y(y),
	m_width(width),
	m_height(height)
{
	glGenBuffers(1, &m_texcoord);
	glBindBuffer(GL_ARRAY_BUFFER, m_texcoord);

	GLdouble tc[4][2] = {
		{GetCoordLeft() , GetCoordTop()   },
		{GetCoordLeft() , GetCoordBottom()},
		{GetCoordRight(), GetCoordTop()   },
		{GetCoordRight(), GetCoordBottom()}
	};

	glBufferData(GL_ARRAY_BUFFER, sizeof(tc) * sizeof(GLdouble), tc, GL_STATIC_DRAW);
}
示例#2
0
float plugin::screen::GetCoord(float a, eScreenCoordTranslationSide side) {
    switch (side) {
    case SIDE_ANY:
        return GetCoord(a);
    case SIDE_LEFT:
        return GetCoordLeft(a);
    case SIDE_RIGHT:
        return GetCoordRight(a);
    case SIDE_TOP:
        return GetCoordTop(a);
    case SIDE_BOTTOM:
        return GetCoordBottom(a);
    case SIDE_CENTER_LEFT:
        return GetCoordCenterLeft(a);
    case SIDE_CENTER_RIGHT:
        return GetCoordCenterRight(a);
    case SIDE_CENTER_UP:
        return GetCoordCenterUp(a);
    case SIDE_CENTER_DOWN:
        return GetCoordCenterDown(a);
    }
    return 0.0f;
}
示例#3
0
Texture::Texture(
	std::shared_ptr<Texture> tex,
	int x,
	int y,
	int width,
	int height):
	m_rt(tex->GetRawTexture()),
	m_x(tex->GetX() + x),
	m_y(tex->GetY() + y),
	m_width(width),
	m_height(height)
{
	int x2 = m_x + m_width;
	int y2 = m_y + m_height;

	if (m_x < tex->GetX())
	{
		m_x = tex->GetX();
	}
	else if (tex->GetX() + tex->GetWidth() < m_x)
	{
		m_x = tex->GetX() + tex->GetWidth();
	}

	if (x2 < tex->GetX())
	{
		x2 = tex->GetX();
	}
	else if (tex->GetX() + tex->GetWidth() < x2)
	{
		x2 = tex->GetX() + tex->GetWidth();
	}

	if (m_y < tex->GetY())
	{
		m_y = tex->GetY();
	}
	else if (tex->GetY() + tex->GetHeight() < m_y)
	{
		m_y = tex->GetY() + tex->GetHeight();
	}

	if (y2 < tex->GetY())
	{
		y2 = tex->GetY();
	}
	else if (tex->GetY() + tex->GetHeight() < y2)
	{
		y2 = tex->GetY() + tex->GetHeight();
	}

	m_width  = x2 - m_x;
	m_height = y2 - m_y;


	glGenBuffers(1, &m_texcoord);
	glBindBuffer(GL_ARRAY_BUFFER, m_texcoord);

	GLdouble tc[4][2] = {
		{GetCoordLeft() , GetCoordTop()   },
		{GetCoordLeft() , GetCoordBottom()},
		{GetCoordRight(), GetCoordTop()   },
		{GetCoordRight(), GetCoordBottom()}
	};

	glBufferData(GL_ARRAY_BUFFER, sizeof(tc) * sizeof(GLdouble), tc, GL_STATIC_DRAW);
}