当前位置: 首页>>代码示例>>C++>>正文


C++ example_state_view类代码示例

本文整理汇总了C++中example_state_view的典型用法代码示例。如果您正苦于以下问题:C++ example_state_view类的具体用法?C++ example_state_view怎么用?C++ example_state_view使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了example_state_view类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: user_idle

	void user_idle(const example_state_view& state)
	override
	{
		if(state.user_idle_time() > seconds_(1))
		{
			const float t = value(state.frame_duration())*60;

			scale *= std::pow(1.f+0.05f*t, scale_dir);
			if(scale < min_scale)
			{
				scale_dir *= -1.f;
				ofs_x_dir *= -1.f;
				ofs_y_dir *= ofs_x_dir;
				scale = min_scale;
			}
			if(scale > max_scale)
			{
				scale_dir *= -1.f;
				ofs_y_dir *= -1.f;
				ofs_x_dir *= ofs_y_dir;
				scale = max_scale;
			}

			offset_x += ofs_x_dir*t*scale/30;
			offset_y += ofs_y_dir*t*scale/30;

			gl.uniform(prog.offset_loc, offset_x, offset_y);
			gl.uniform(prog.scale_loc, scale*aspect, scale);
		}
	}
开发者ID:matus-chochlik,项目名称:oglplu2,代码行数:30,代码来源:014_voronoi.cpp

示例2: resize

	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();
	}
开发者ID:matus-chochlik,项目名称:oglplu2,代码行数:8,代码来源:008_texgen.cpp

示例3: resize

	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);
	}
开发者ID:matus-chochlik,项目名称:oglplu2,代码行数:8,代码来源:014_voronoi.cpp

示例4: pointer_motion

	void pointer_motion(const example_state_view& state)
	override
	{
		if(state.pointer_dragging())
		{
			mod_cam_turns(-state.norm_delta_pointer_x()*0.5f);
			mod_cam_pitch(-state.norm_delta_pointer_y()*1.0f);
			set_projection(state);
		}
	}
开发者ID:matus-chochlik,项目名称:oglplu2,代码行数:10,代码来源:028_lighting.cpp

示例5: pointer_motion

	void pointer_motion(const example_state_view& state)
	override
	{
		if(state.pointer_dragging())
		{
			offset_x -= 2*state.norm_delta_pointer_x()*scale;
			offset_y -= 2*state.norm_delta_pointer_y()*scale;

			gl.uniform(prog.offset_loc, offset_x, offset_y);
		}
	}
开发者ID:matus-chochlik,项目名称:oglplu2,代码行数:11,代码来源:014_voronoi.cpp

示例6: render

	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);

	}
开发者ID:matus-chochlik,项目名称:oglplu2,代码行数:53,代码来源:030_recursive_cube.cpp

示例7: user_idle

	void user_idle(const example_state_view& state)
	override
	{
		if(state.user_idle_time() > seconds_(1))
		{
			const float s = state.frame_duration().value()/5;

			mod_cam_orbit(s*cam_dist_dir);
			mod_cam_turns(s*cam_turn_dir);
			mod_cam_pitch(s*cam_elev_dir);

			set_projection(state);
		}
	}
开发者ID:matus-chochlik,项目名称:oglplu2,代码行数:14,代码来源:028_lighting.cpp

示例8: user_idle

	void user_idle(const example_state_view& state)
	override
	{
		if(state.user_idle_time() > seconds_(1))
		{
			using namespace eagine::math;
			float new_sc = float(smooth_lerp(
				min_scale,
				max_scale,
				value(state.exec_time())*0.4f
			));

			scale = interpolate_linear(new_sc, scale, 0.9f);

			gl.uniform(erg.scale_loc, scale, scale);
		}
	}
开发者ID:matus-chochlik,项目名称:oglplu2,代码行数:17,代码来源:008_texgen.cpp

示例9: pointer_scrolling

	void pointer_scrolling(const example_state_view& state)
	override
	{
		scale *= float(std::pow(2,-state.norm_delta_pointer_z()));
		if(scale < min_scale) scale = min_scale;
		if(scale > max_scale) scale = max_scale;

		gl.uniform(erg.scale_loc, scale*aspect, scale);
	}
开发者ID:matus-chochlik,项目名称:oglplu2,代码行数:9,代码来源:008_texgen.cpp

示例10: user_idle

	void user_idle(const example_state_view& state)
	override
	{
		if(state.user_idle_time() > seconds_(1))
		{
			const float s = value(state.frame_duration())*60;
			const float dest_offset_x = -0.525929f;
			const float dest_offset_y = -0.668547f;
			const float c = 0.02f * s;

			offset_x = c*dest_offset_x + (1-c)*offset_x;
			offset_y = c*dest_offset_y + (1-c)*offset_y; 

			scale *= (1-0.01f*s);
			if(scale < min_scale) scale = min_scale;

			gl.uniform(offset_loc, offset_x, offset_y);
			gl.uniform(scale_loc, scale*aspect, scale);
		}
	}
开发者ID:deranen,项目名称:oglplu2,代码行数:20,代码来源:011_mandelbrot.cpp

示例11: set_projection

 void set_projection(const example_state_view& state)
 {
     gl.uniform(
         prog.projection,
         matrix_perspective::y(
             right_angle_(),
             state.aspect(),
             0.5f, 10.f
         )*matrix_orbiting_y_up(
             vec3(),
             smooth_lerp(1.5f, 5.0f, cam_orbit),
             turns_(cam_turns),
             smooth_oscillate(radians_(1.5f), cam_pitch)
         )
     );
 }
开发者ID:matus-chochlik,项目名称:oglplu2,代码行数:16,代码来源:010_cube.cpp

示例12: render

	void render(const example_state_view& state)
	override
	{
		gl.use(erase_prog);
		gl.disable(GL.depth_test);
		background.use();
		background.draw();

		shp_turns += 0.1f*state.frame_duration().value();

		gl.use(light_prog);
		gl.uniform(
			light_prog.modelview,
			matrix_rotation_x(turns_(shp_turns)/1)*
			matrix_rotation_y(turns_(shp_turns)/2)*
			matrix_rotation_z(turns_(shp_turns)/3)
		);

		gl.clear(GL.depth_buffer_bit);
		gl.enable(GL.depth_test);
		shape.use();
		shape.draw();
	}
开发者ID:matus-chochlik,项目名称:oglplu2,代码行数:23,代码来源:028_lighting.cpp

示例13: continue_running

	bool continue_running(const example_state_view& state)
	override
	{
		return state.user_idle_time() < seconds_(20);
	}
开发者ID:matus-chochlik,项目名称:oglplu2,代码行数:5,代码来源:030_recursive_cube.cpp

示例14: resize

	void resize(const example_state_view& state)
	override
	{
		gl.viewport(state.width(), state.height());
	}
开发者ID:matus-chochlik,项目名称:oglplu2,代码行数:5,代码来源:030_recursive_cube.cpp

示例15: pointer_scrolling

	void pointer_scrolling(const example_state_view& state)
	override
	{
		mod_cam_orbit(-state.norm_delta_pointer_z());
		set_projection(state);
	}
开发者ID:matus-chochlik,项目名称:oglplu2,代码行数:6,代码来源:028_lighting.cpp


注:本文中的example_state_view类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。