Exemplo n.º 1
0
void Texture::OnDraw(int x, int y) const
{
	glColor4f(1, 1, 1, 1); // Should be black?

	auto shader = _vid.GetShader(0);
	shader->Use();

	// Update parameters
	glUniform1i(shader->grad_shift_id, 0);
	float recols[] = {
		0.0, 1.0, 0.0,
		1.0, 0.0, 0.0,
	};
	glUniform3fv(shader->recolour, 2, recols);

	int *pos_id = &shader->pos_id;
	int *texcoord_id = &shader->tex_coord;

	// If there's no mask, maskid is bound to the 0 texture, so ends up being a no-op.
	glActiveTexture(GL_TEXTURE1);
	glBindTexture(GL_TEXTURE_2D, this->maskid);

	glActiveTexture(GL_TEXTURE0);
	glBindTexture(GL_TEXTURE_2D, this->texid);

	float left = x;
	float right = x + this->width;
	float top = y;
	float bottom = y + this->height;

	float vertices[] = {
	        left,  top,    0, 0, // top-left
	        right, top,    1, 0, // top-right
	        left,  bottom, 0, 1, // bottom-left
	        right, top,    1, 0, // top-right
	        left,  bottom, 0, 1, // bottom-left
	        right, bottom, 1, 1, // bottom-right
	};

	glBindBuffer(GL_ARRAY_BUFFER, this->vbo);
	glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_DYNAMIC_DRAW);
	glEnableVertexAttribArray(*pos_id);
	glEnableVertexAttribArray(*texcoord_id);
	glVertexAttribPointer(*pos_id,      2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (void *)(0));
	glVertexAttribPointer(*texcoord_id, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (void *)(2 * sizeof(float)));

	glDrawArrays(GL_TRIANGLES, 0, 6); // 2 triangles

	/* Clean up */
	glDisableVertexAttribArray(*pos_id);
	glDisableVertexAttribArray(*texcoord_id);
	glBindBuffer(GL_ARRAY_BUFFER, 0);
	shader->StopUsing();
}
Exemplo n.º 2
0
//------------------------------------------------------------------------
void CVehicleSeatActionAnimation::Reset()
{
	if (m_userId)
		StopUsing();
}
Exemplo n.º 3
0
 void RenderRectangle(const GG::Pt& ul, const GG::Pt& lr) {
     StartUsing();
     GG::FlatRectangle(ul, lr, GG::CLR_WHITE, GG::CLR_WHITE, 0u);
     StopUsing();
 }
Exemplo n.º 4
0
 void RenderCircle(const GG::Pt& ul, const GG::Pt& lr) {
     StartUsing();
     CircleArc(ul, lr, 0.0, TWO_PI, true);
     StopUsing();
 }