Exemplo n.º 1
0
	void render(const example_state_view& state)
	override
	{
		rad += radians_(0.5f*state.frame_duration().value());

		current_buf = (current_buf+1)%2;

		gl.uniform(
			prog.light_pos,
			vec3(cos(rad)*4, sin(rad)*4, 8)
		);

		gl.uniform(
			prog.modelview,
			matrix_rotation_x(rad*1)*
			matrix_rotation_y(rad*2)*
			matrix_rotation_z(rad*3)
		);

		// draw into the texture
		gl.bind(GL.draw_framebuffer, rnd_tex.fbos[current_buf]);
		gl.viewport(tex_side, tex_side);

		GLfloat s = 0.5f;

		gl.uniform(
			prog.projection,
			oglplus::matrix_perspective(-s,+s, -s,+s, 1.0f, 5)*
			oglplus::matrix_translation(0,0,-2)
		);

		gl.clear(GL.color_buffer_bit|GL.depth_buffer_bit);
		gl.draw_arrays(GL.triangles, 0, 6 * 2 * 3);

		// draw on screen
		gl.bind(GL.draw_framebuffer, default_framebuffer);
		gl.viewport(state.width(), state.height());

		gl.uniform(prog.cube_tex, GLint(current_buf));

		GLfloat h = 0.55f;
		GLfloat w = h*state.aspect();

		gl.uniform(
			prog.projection,
			oglplus::matrix_perspective(-w,+w, -h,+h, 1, 3)*
			oglplus::matrix_translation(0,0,-2)
		);

		gl.clear(GL.color_buffer_bit|GL.depth_buffer_bit);
		gl.draw_arrays(GL.triangles, 0, 6 * 2 * 3);

	}
Exemplo n.º 2
0
	void resize(const example_state_view& state)
	override
	{
		gl.viewport(0, 0, state.width(), state.height());
		erg.set_dimensions(state.width(), state.height());

		aspect = state.aspect();
	}
Exemplo n.º 3
0
	void resize(const example_state_view& state)
	override
	{
		gl.viewport(state.width(), state.height());

		aspect = state.aspect();
		gl.uniform(prog.scale_loc, scale*aspect, scale);
	}
Exemplo n.º 4
0
	rendered_textures(GLsizei tex_side)
	{

		for(GLuint i=0; i<2u; ++i)
		{
			texture_name tex = texs[i];

			gl.active_texture(GL.texture0+i);
			gl.bind(GL.texture_2d, tex);
			gl.texture_min_filter(GL.texture_2d, GL.linear);
			gl.texture_mag_filter(GL.texture_2d, GL.linear);
			gl.texture_image_2d(
				GL.texture_2d,
				0,
				GL.rgb, 
				tex_side, tex_side,
				0,
				GL.rgb,
				GL.unsigned_byte,
				const_memory_block()
			);

			renderbuffer_name rbo = rbos[i];

			gl.bind(GL.renderbuffer, rbo);
			gl.renderbuffer_storage(
				GL.renderbuffer,
				GL.depth_component,
				tex_side, tex_side
			);

			framebuffer_name fbo = fbos[i];

			gl.bind(GL.draw_framebuffer, fbo);
			gl.framebuffer_texture_2d(
				GL.draw_framebuffer,
				GL.color_attachment0,
				GL.texture_2d,
				tex, 0
			);
			gl.framebuffer_renderbuffer(
				GL.draw_framebuffer,
				GL.depth_attachment,
				GL.renderbuffer,
				rbo
			);

			gl.viewport(tex_side, tex_side);
			gl.clear(GL.color_buffer_bit);
		}

		gl.bind(GL.draw_framebuffer, default_framebuffer);
		gl.bind(GL.renderbuffer, no_renderbuffer);
	}
Exemplo n.º 5
0
	void resize(const example_state_view& state)
	override
	{
		gl.viewport(state.width(), state.height());
	}