// display the final image on the screen
void renderBufferToScreen(void){
    glClear( GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT );
    glLoadIdentity();
    glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D,finalImage);
    //use next line instead of previous to illustrate one-pass rendering
    //glBindTexture(GL_TEXTURE_2D,backFaceBuffer);
    reshapeOrtho(WINDOW_WIDTH, WINDOW_HEIGHT);
    drawUnitQuad();
    glDisable(GL_TEXTURE_2D);
}
示例#2
0
// --------------------------------------------------------
void TouchWidgetRenderer::drawTexturedUnitQuad( GLuint tex_id, float alpha ) const
{
	glActiveTexture(GL_TEXTURE0);
	//if(_current_texture_id != tex_id)
	//{
		glBindTexture(GL_TEXTURE_2D, tex_id);
		//_current_texture_id = tex_id;
		//glBindTexture(GL_TEXTURE_2D, 0);
	//}
	drawUnitQuad(alpha);
}
示例#3
0
// --------------------------------------------------------
void TouchWidgetRenderer::drawQuad( const QPointF & pos, const QSizeF & size, float rotation, float alpha ) const
{

	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();
	glLoadIdentity();
	glTranslatef(pos.x(), pos.y(), 0);
	glRotatef(rotation, 0, 0, 1);
	glScalef(size.width(), size.height(), 0);
	drawUnitQuad(alpha);
	glPopMatrix();
}
示例#4
0
void EndScene::_draw(float time)
{
	std::vector<vec3> path;

	skrand(625734);
	for (int i = 0; i < 10; i++)
		path.push_back(endCamPos + vec3(rand(-1.f, 1.f), rand(-1.f, 1.f), rand(-1.f, 1.f)));

	mat4 mPersp = perspective(45.0f, demo.aspect, 0.5f, 1000.0f);
	mat4 mCamera = lookAt(interpolatePath(path, time / Duration()) * 0.1f, endLookAt * 0.1f, vec3(0, 1, 0));

	setDepthMode(DEPTH_FULL);
	for (int i = 0; i < ARRAY_SIZE(tPark); i++) {
		GlslShader *sDraw = sPark[i];
		sDraw->bind();
		sDraw->uniform("u_matrix", mPersp * mCamera);
		sDraw->uniform("u_modelview", mCamera);
		sDraw->uniform("u_projection", mPersp);
		sDraw->uniform("u_alpha", 1.0f);
		sDraw->bindTexture("tex", tPark[i], 0);
		oPark->draw(i);
		sDraw->unbind();
	}

	sDrawFlat->bind();
	sDrawFlat->bindTexture("tex", tSmoke, 0);
	setBlendMode(BLEND_ALPHA);
	sDrawFlat->uniform("u_alpha", smokeAlpha);
	mat4 sm(1);
	sm = translate(sm, smokeCenter * 0.1f);
	sm = rotate(sm, smokeRot, vec3(0, 1, 0));
	sm = scale(sm, vec3(smokeSize, 1));
	sDrawFlat->uniform("u_matrix", mPersp * mCamera * sm);

	int animStep = int(floor(time * 24.0f));
	int animX = animStep & 7;
	int animY = (animStep >> 3) & 3;
	float l = float(animX) / 8, r = float(animX + 1) / 8;
	float b = float(animY) / 4, t = float(animY + 1) / 4;

	drawRect(vec2(-0.5, -0.5), vec2(0.5, 0.5), vec2(l, t), vec2(r, b));
	sDrawFlat->unbind();

	setDepthMode(NO_DEPTH);

	float logoFade = clamp((time - logoFadeStart) / (logoFadeEnd - logoFadeStart), 0.f, 1.f);

	setBlendMode(BLEND_ALPHA);
	sDrawFlat->bind();
	sDrawFlat->bindTexture("tex", tLogo, 0);
	sDrawFlat->uniform("u_alpha", logoFade);
	mat4 lm(demo.fix_aspect(mat4(1)));
	lm = translate(lm, logoCenter + vec3(sin(time) * 2, cos(2 * time), 0) * .01f);
	lm = scale(lm, vec3(tLogo->aspect, 1, 1) * logoSize);
	sDrawFlat->uniform("u_matrix", lm);
	drawUnitQuad();
	lm = demo.fix_aspect(mat4(1));
	lm = translate(lm, textCenter + vec3(cos(time + .6135), sin(-2 * time - .6135), 0) * .003f);
	lm = scale(lm, vec3(tText->aspect, 1, 1) * textSize);
	sDrawFlat->uniform("u_matrix", lm);
	sDrawFlat->bindTexture("tex", tText, 0);
	drawUnitQuad();
	sDrawFlat->unbind();
	setBlendMode(NO_BLEND);
}