Exemplo n.º 1
0
/**
@note The vertex buffer is 100x100 and should get scaled, rotated and transformed before drawTexture() is called.
*/
void Graphics::buildFastBuffer()
{
	HR(gd3dDevice->CreateVertexBuffer(4 * sizeof(TextureVertex), D3DUSAGE_WRITEONLY,
		0, D3DPOOL_MANAGED, &mVB_fast, 0));

	TextureVertex* v = NULL;
	HR(mVB_fast->Lock(0, 0, (void**)&v, 0));

	int width = 100;
	int height = 100;

	v[0] = TextureVertex(-width/2, -height/2, 0);
	v[1] = TextureVertex(-width/2, height/2, 0);
	v[2] = TextureVertex(width/2, height/2, 0);
	v[3] = TextureVertex(width/2, -height/2, 0);
	v[0].tex0.x = 0;
	v[0].tex0.y = 0;
	v[1].tex0.x = 0;
	v[1].tex0.y = 1;
	v[2].tex0.x = 1;
	v[2].tex0.y = 1;
	v[3].tex0.x = 1;
	v[3].tex0.y = 0;

	HR(mVB_fast->Unlock());
}
Exemplo n.º 2
0
 QuadBuilder(const glm::vec2& min, const glm::vec2& size,
             const glm::vec2& texMin, const glm::vec2& texSize) {
     // min = bottomLeft
     vertices[0] = TextureVertex(min,
                                 texMin + glm::vec2(0.0f, texSize.y));
     vertices[1] = TextureVertex(min + glm::vec2(size.x, 0.0f),
                                 texMin + texSize);
     vertices[2] = TextureVertex(min + size,
                                 texMin + glm::vec2(texSize.x, 0.0f));
     vertices[3] = TextureVertex(min + glm::vec2(0.0f, size.y),
                                 texMin);
 }
Exemplo n.º 3
0
 QuadBuilder(const rectf & r, const rectf & tr) {
   vertices[0] = TextureVertex(r.getLowerLeft(), tr.getUpperLeft());
   vertices[1] = TextureVertex(r.getLowerRight(), tr.getUpperRight());
   vertices[2] = TextureVertex(r.getUpperRight(), tr.getLowerRight());
   vertices[3] = TextureVertex(r.getUpperLeft(), tr.getLowerLeft());
 }