Пример #1
0
void GameControl::setBounds(const Rectangle& rect)
{
	m_originalBounds = rect;
	m_bounds = rect;

	// index 0 is bottom left in the plane actually. This is a bit unfortunate
	// and since opengl counts from bottom left and we want top left corner of the screen as
	// (0, 0) there is this annoying transformation going for y coordinate
	int height = Game::getInstance().getHUD().getHeight();
	if(!Game::getInstance().getHUD().flipUi())
	{
		m_bounds.y = height - m_bounds.y - m_bounds.height;
	}

	if(Game::getInstance().getHUD().flipUi())
	{
		Rectangle tempRect;
		tempRect.x = m_bounds.y;
		tempRect.y = m_bounds.x;
		tempRect.width = m_bounds.height;
		tempRect.height = m_bounds.width;

		m_bounds = tempRect;
	}

	prepareVertices();
}
Пример #2
0
	void prepare()
	{
		gl_base::prepare();
		prepareSynchronizationPrimitives();
		prepareVertices(USE_STAGING);
		prepareUniformBuffers();
		preparePipelines();
		prepared = true;
	}
Пример #3
0
	void prepare()
	{
		VulkanExampleBase::prepare();
		prepareVertices();
		setupDescriptorSetLayout();
		preparePipelines();
		setupDescriptorPool();
		setupDescriptorSets();
		updateUniformBuffers();
		buildCommandBuffers();
		prepared = true;
	}
Пример #4
0
void StretchableSprite2D::UpdateSourceBatches()
{
    /* The general idea is to subdivide the image in the following 9 patches

       *---*---*---*
     2 |   |   |   |
       *---*---*---*
     1 |   |   |   |
       *---*---*---*
     0 |   |   |   |
       *---*---*---*
         0   1   2

     X scaling works as follow: as long as the scale determines that the total
     width is larger than the sum of the widths of columns 0 and 2, only
     column 1 is scaled. Otherwise, column 1 is removed and columns 0 and 2 are
     scaled, maintaining their relative size. The same principle applies for
     Y scaling (but with lines rather than columns). */

    if (!sourceBatchesDirty_ || !sprite_ || (!useTextureRect_ && !sprite_->GetTextureRectangle(textureRect_, flipX_, flipY_)))
        return;

    Vector<Vertex2D>& vertices = sourceBatches_[0].vertices_;
    vertices.Clear();

    auto effectiveBorder = calcEffectiveBorder(border_, drawRect_.Size());

    float xs[4], ys[4], us[4], vs[4]; // prepare all coordinates
    const auto signedScale = node_->GetSignedWorldScale();

    prepareXYCoords(xs, drawRect_.min_.x_, drawRect_.max_.x_, effectiveBorder.min_.x_, effectiveBorder.max_.x_, signedScale.x_);
    prepareXYCoords(ys, drawRect_.min_.y_, drawRect_.max_.y_, effectiveBorder.min_.y_, effectiveBorder.max_.y_, signedScale.y_);

    prepareUVCoords(us, textureRect_.min_.x_, textureRect_.max_.x_, effectiveBorder.min_.x_, effectiveBorder.max_.x_,
        drawRect_.max_.x_ - drawRect_.min_.x_);
    prepareUVCoords(vs, textureRect_.min_.y_, textureRect_.max_.y_, -effectiveBorder.min_.y_,
        -effectiveBorder.max_.y_ /* texture y direction inverted*/, drawRect_.max_.y_ - drawRect_.min_.y_);

    Vertex2D vtx[4][4]; // prepare all vertices
    prepareVertices(vtx, xs, ys, us, vs, color_.ToUInt(), node_->GetWorldPosition(), node_->GetWorldRotation());

    pushVertices(vertices, vtx); // push the vertices that make up each patch

    sourceBatchesDirty_ = false;
}
Пример #5
0
    void initVulkan()
    {
        VulkanAndroidExampleBase::initVulkan();

        prepareVertices();
        prepareUniformBuffers();
        setupDescriptorSetLayout();
        preparePipelines();
        setupDescriptorPool();
        setupDescriptorSet();

        buildCommandBuffers();

        state.zoom = -5.0f;
        state.rotation = glm::vec3();

        prepared = true;
    }
Пример #6
0
	void initVulkan()
	{
		VulkanAndroidExampleBase::initVulkan();

		loadTexture(
			"textures/vulkan_android_robot.ktx", 
			VK_FORMAT_R8G8B8A8_UNORM, 
			false);

		prepareVertices();
		prepareUniformBuffers();
		setupDescriptorSetLayout();
		preparePipelines();
		setupDescriptorPool();
		setupDescriptorSet();

		buildCommandBuffers();

		state.zoom = -5.0f;
		state.rotation = glm::vec3();

		prepared = true;
	}
Пример #7
0
VulkanCube::VulkanCube(VkDevice mdevice, VulkanExampleBase *mexample,VkQueue queue, glm::vec3 halfSize, glm::mat4 startPos, SceneMaterial mater, uint32_t objectNumber, std::vector<BurningPoint>& points) : VulkanObject(mdevice,mexample,startPos,mater)
{
    prepareVertices(halfSize,points, objectNumber);
    prepareIdex(queue);
    prepareRigidBody(halfSize, startPos[3]);
}