Exemplo n.º 1
0
//------------------------------------------------------------------------------
void Example::UpdateView(void)
{
	float tx = view_center_x;
	float ty = view_center_y;
	float sa = oglplus::Sin(oglplus::Degrees(view_angle));
	float ca = oglplus::Cos(oglplus::Degrees(view_angle));
	float sx = view_width;
	float sy = view_width/view_aspect;

	oglplus::Mat3f t(
		1.0f, 0.0f,   tx,
		0.0f, 1.0f,   ty,
		0.0f, 0.0f, 1.0f
	);
	oglplus::Mat3f r(
		 ca,  sa, 0.0f,
		-sa,  ca, 0.0f,
		0.0, 0.0, 1.0f
	);
	oglplus::Mat3f s(
		  sx, 0.0f, 0.0f,
		0.0f,   sy, 0.0f,
		0.0f, 0.0f, 1.0f
	);
	view_matrix.Set(t*r*s);
}
Exemplo n.º 2
0
	void Render(void)
	{
		using namespace oglplus;

		gl.Clear().ColorBuffer().DepthBuffer();

		camera_matrix.Set(
			CamMatrixf::Orbiting(
				Vec3f(),
				9.5 - SineWave(FrameTime() / 6.0) * 7.0,
				FullCircles(FrameTime() / 9.0),
				Degrees(SineWave(FrameTime() / 30.0) * 90)
			)
		);

		model_matrix.Set(ModelMatrixf::RotationX(FullCircles(FrameTime() * 0.1)));

		textured_cube.Draw();
	}
Exemplo n.º 3
0
void SpectraDefaultGPUMatrixTransf::BeginBatch() {
    using namespace oglplus;
    gl_canvas->SetCurrent(*gl_context);
    transf_prog.Use();

    Texture::Active(0);
    matrix_tex.Bind(Texture::Target::Buffer);
    prog_matrix_data.Set(0);

    Texture::Active(1);
    input_tex.Bind(Texture::Target::Buffer);
    prog_input_data.Set(1);

    prog_input_size.Set(int(in_size));

    vao.Bind();

    Context gl;
    gl.Enable(Capability::RasterizerDiscard);
}
Exemplo n.º 4
0
	void Reshape(void)
	{
		using namespace oglplus;

		gl.Viewport(Width(), Height());

		projection_matrix.Set(
			CamMatrixf::PerspectiveX(
				Degrees(60),
				Aspect(),
				1, 50
			)
		);
	}
Exemplo n.º 5
0
unsigned SpectraDefaultGPUMatrixTransf::BeginTransform(
	const float* input,
	std::size_t inbufsize,
	float* /*output*/,
	std::size_t /*outbufsize*/
)
{
	using namespace oglplus;

	assert(inbufsize >= in_size);

	if(current_transform >= max_transforms)
		current_transform = 0;

	input_buf.Bind(Buffer::Target::Texture);
	Buffer::SubData(
		Buffer::Target::Texture,
		current_transform*in_size,
		in_size,
		input
	);

	prog_input_offs.Set(current_transform*in_size);

	xfbs[current_transform].Bind();

	Query::Activator qrya(
		queries[current_transform],
		Query::Target::TransformFeedbackPrimitivesWritten
	);
	TransformFeedback::Activator xfba(
		TransformFeedbackPrimitiveType::Points
	);

	Context gl;
	gl.DrawArrays(PrimitiveType::Points, 0, out_size);

	xfba.Finish();
	qrya.Finish();

	TransformFeedback::BindDefault();

	return current_transform++;
}