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


C++ operations::query_location方法代码示例

本文整理汇总了C++中operations::query_location方法的典型用法代码示例。如果您正苦于以下问题:C++ operations::query_location方法的具体用法?C++ operations::query_location怎么用?C++ operations::query_location使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在operations的用法示例。


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

示例1:

	voronoi_program(const example_params& params)
	{
		std::string path = params.get_resource_file_path(
			example_resource_type::program_source,
			cstr_ref("014_voronoi.oglpprog")
		);
		_init(program_source_file(cstr_ref(path)));

		gl.use(*this);

		gl.query_location(offset_loc, *this, "Offset");
		gl.query_location(scale_loc, *this, "Scale");
	}
开发者ID:matus-chochlik,项目名称:oglplu2,代码行数:13,代码来源:014_voronoi.cpp

示例2:

	lighting_program(const example_params& params)
	{
		std::string path = params.get_resource_file_path(
			example_resource_type::program_source,
			cstr_ref("028_lighting-lt.oglpprog")
		);
		build_program(*this, program_source_file(cstr_ref(path)));

		gl.use(*this);

		gl.query_location(projection, *this, "Projection");
		gl.query_location(modelview, *this, "Modelview");
	}
开发者ID:matus-chochlik,项目名称:oglplu2,代码行数:13,代码来源:028_lighting.cpp

示例3: vs

    example_program(void)
    {
        shader vs(GL.vertex_shader);
        vs.source(glsl_literal(
                      "#version 140\n"

                      "uniform mat4 Projection;\n"

                      "in vec4 Position;\n"
                      "in vec3 Normal;\n"
                      "in vec3 BoxCoord;\n"
                      "in vec3 TexCoord;\n"
                      "out vec2 vertCoord;\n"
                      "out vec3 vertColor1;\n"
                      "out vec3 vertColor2;\n"

                      "void main(void)\n"
                      "{\n"
                      "	gl_Position = Projection*Position;\n"
                      "	vertColor1 = mix(BoxCoord,abs(Normal),0.5);\n"
                      "	vertColor2 = vertColor1 * 0.3;\n"
                      "	vertCoord = TexCoord.xy*(2+TexCoord.z);\n"
                      "}\n"
                  ));
        vs.compile();

        shader fs(GL.fragment_shader);
        fs.source(glsl_literal(
                      "#version 140\n"

                      "in  vec2 vertCoord;\n"
                      "in  vec3 vertColor1;\n"
                      "in  vec3 vertColor2;\n"
                      "out vec3 fragColor;\n"

                      "float pattern(vec2 tc)\n"
                      "{\n"
                      "	return float((int(tc.x)%2+int(tc.y)%2)%2);\n"
                      "}\n"

                      "void main(void)\n"
                      "{\n"
                      "	float c = pattern(vertCoord);\n"
                      "	fragColor = mix(vertColor1, vertColor2, c);\n"
                      "}\n"
                  ));
        fs.compile();

        attach(vs);
        attach(fs);
        link();
        report_link_error();

        gl.use(*this);

        gl.query_location(projection, *this, "Projection");
    }
开发者ID:matus-chochlik,项目名称:oglplu2,代码行数:57,代码来源:010_cube.cpp

示例4: vs

	example_program(void)
	{
		shader vs(GL.vertex_shader);

		vs.source(glsl_literal(
		"#version 140\n"

		"uniform mat4 Projection;"
		"uniform mat4 Modelview;"
		"uniform vec3 LightPos;"

		"in vec4 Position;\n"
		"in vec3 Normal;\n"
		"in vec2 TexCoord;\n"

		"out vec3 vertNormal;\n"
		"out vec3 vertLightDir;\n"
		"out vec2 vertTexCoord;\n"

		"void main(void)\n"
		"{\n"
		"	gl_Position = Modelview*Position;\n"
		"	vertNormal = mat3(Modelview)*Normal;\n"
		"	vertLightDir = LightPos - gl_Position.xyz;\n"
		"	vertTexCoord = TexCoord;\n"
		"	gl_Position = Projection*gl_Position;\n"
		"}\n"
		));
		vs.compile();
		vs.report_compile_error();

		shader fs(GL.fragment_shader);

		fs.source(glsl_literal(
		"#version 140\n"

		"uniform sampler2D CubeTex;"
		"in vec3 vertNormal;\n"
		"in vec3 vertLightDir;\n"
		"in vec2 vertTexCoord;\n"
		"out vec4 fragColor;\n"

		"void main(void)\n"
		"{\n"
		"	float d=0.3*dot(vertNormal, normalize(vertLightDir));\n"
		"	float i=0.6 + max(d, 0.0);\n"
		"	fragColor = texture(CubeTex, vertTexCoord)*i;\n"
		"}\n"
		));
		fs.compile();
		fs.report_compile_error();

		attach(vs);
		attach(fs);
		link();
		report_link_error();

		gl.use(*this);

		gl.query_location(projection, *this, "Projection");
		gl.query_location(modelview, *this, "Modelview");
		gl.query_location(light_pos, *this, "LightPos");
		gl.query_location(cube_tex, *this, "CubeTex");
	}
开发者ID:matus-chochlik,项目名称:oglplu2,代码行数:64,代码来源:030_recursive_cube.cpp

示例5:

	cube_model(const program& prog)
	{
		const GLfloat v[8][3] = {
			{-0.5f, -0.5f, -0.5f},
			{+0.5f, -0.5f, -0.5f},
			{-0.5f, +0.5f, -0.5f},
			{+0.5f, +0.5f, -0.5f},
			{-0.5f, -0.5f, +0.5f},
			{+0.5f, -0.5f, +0.5f},
			{-0.5f, +0.5f, +0.5f},
			{+0.5f, +0.5f, +0.5f}
		};

		const GLint f[6][2][3] = {
			{{0, 4, 2}, {2, 4, 6}},
			{{5, 1, 7}, {7, 1, 3}},
			{{0, 1, 4}, {4, 1, 5}},
			{{6, 7, 2}, {2, 7, 3}},
			{{1, 0, 3}, {3, 0, 2}},
			{{4, 5, 6}, {6, 5, 7}}
		};

		gl.bind(vao);
	
		const GLuint vertex_count = 6 * 2 * 3;

		// positions
		GLfloat vertex_data[vertex_count * 3];

		for(GLuint fi=0;fi!=6;++fi)
		for(GLuint ti=0;ti!=2;++ti)
		for(GLuint vi=0;vi!=3;++vi)
		{
			for(GLuint ci=0;ci!=3;++ci)
			{
				vertex_data[fi*2*3*3+ti*3*3+vi*3+ci] =
					v[f[fi][ti][vi]][ci];
			}
		}

		gl.bind(GL.array_buffer, positions);
		gl.buffer_data(GL.array_buffer, vertex_data, GL.static_draw);

		gl.vertex_array_attrib_pointer(
			vertex_attrib_location(0),
			3, GL.float_,
			false, 0, nullptr
		);
		gl.enable_vertex_array_attrib(vertex_attrib_location(0));

		vertex_attrib_location va_p;
		gl.query_location(va_p, prog, "Position");
		gl.vertex_array_attrib_pointer(
			va_p, 3, GL.float_,
			false, 0, nullptr
		);
		gl.enable_vertex_array_attrib(va_p);

		// normals
		const GLfloat n[6][3] = {
			{-1.0f,  0.0f,  0.0f},
			{ 1.0f,  0.0f,  0.0f},
			{ 0.0f, -1.0f,  0.0f},
			{ 0.0f,  1.0f,  0.0f},
			{ 0.0f,  0.0f, -1.0f},
			{ 0.0f,  0.0f,  1.0f}
		};
		for(GLuint fi=0;fi!=6;++fi)
		for(GLuint vi=0;vi!=6;++vi)
		{
			for(GLuint ci=0;ci!=3;++ci)
			{
				vertex_data[(fi*6+vi)*3+ci] = n[fi][ci];
			}
		}

		gl.bind(GL.array_buffer, normals);
		gl.buffer_data(GL.array_buffer, vertex_data, GL.static_draw);

		vertex_attrib_location va_n;
		gl.query_location(va_n, prog, "Normal");
		gl.vertex_array_attrib_pointer(
			va_n, 3, GL.float_,
			false, 0, nullptr
		);
		gl.enable_vertex_array_attrib(va_n);

		// tex-coords
		const GLfloat c[6][2] = {
			{0.0f, 0.0f},
			{1.0f, 0.0f},
			{0.0f, 1.0f},
			{0.0f, 1.0f},
			{1.0f, 0.0f},
			{1.0f, 1.0f}
		};

		for(GLuint fi=0;fi!=6;++fi)
		{
			for(GLuint vi=0;vi!=6;++vi)
//.........这里部分代码省略.........
开发者ID:matus-chochlik,项目名称:oglplu2,代码行数:101,代码来源:030_recursive_cube.cpp

示例6: vs

	example_mandelbrot(void)
	 : offset_x(-0.5f)
	 , offset_y(0.0f)
	 , scale(1.0f)
	 , aspect(1.0f)
	{
		shader vs(GL.vertex_shader);
		vs.source(glsl_literal(
			"#version 130\n"
			"uniform vec2 Offset;\n"
			"uniform vec2 Scale;\n"
			"in vec2 Position;\n"
			"in vec2 Coord;\n"
			"out vec2 vertCoord;\n"
			"void main(void)\n"
			"{\n"
			"	vertCoord = Coord*Scale+Offset;\n"
			"	gl_Position = vec4(Position, 0.0, 1.0);\n"
			"}\n"
		));
		vs.compile();

		shader fs(GL.fragment_shader);
		fs.source(glsl_literal(
		"#version 130\n"
		"uniform sampler1D gradient;\n"
		"in vec2 vertCoord;\n"
		"out vec4 fragColor;\n"
		"void main(void)\n"
		"{\n"
		"	vec2 z = vec2(0.0, 0.0);\n"
		"	vec2 c = vertCoord;\n"
		"	int i = 0, max = 256;\n"
		"	while((i != max) && (distance(z, c) < 2.0))\n"
		"	{\n"
		"		vec2 zn = vec2(\n"
		"			z.x * z.x - z.y * z.y + c.x,\n"
		"			2.0 * z.x * z.y + c.y\n"
		"		);\n"
		"		z = zn;\n"
		"		++i;\n"
		"	}\n"
		"	float a = float(i)/float(max);\n"
		"	fragColor = texture(gradient, a+sqrt(length(c))*0.1);\n"
		"} \n"
		));
		fs.compile();

		prog.attach(vs);
		prog.attach(fs);
		prog.link();

		gl.use(prog);

		gl.query_location(offset_loc, prog, "Offset");
		gl.query_location(scale_loc, prog, "Scale");
		gl.uniform(offset_loc, offset_x, offset_y);


		gl.bind(vao);

		GLfloat position_data[4*2] = {
			-1.0f, -1.0f,
			-1.0f,  1.0f,
			 1.0f, -1.0f,
			 1.0f,  1.0f
		};

		gl.bind(GL.array_buffer, positions);
		gl.buffer_data(GL.array_buffer, position_data, GL.static_draw);

		vertex_attrib_location va_p;
		gl.query_location(va_p, prog, "Position");
		gl.vertex_array_attrib_pointer(
			va_p,
			2, GL.float_,
			false, 0, nullptr
		);
		gl.enable_vertex_array_attrib(va_p);


		GLfloat coord_data[4*2] = {
			-1.0f, -1.0f,
			-1.0f,  1.0f,
			 1.0f, -1.0f,
			 1.0f,  1.0f
		};

		gl.bind(GL.array_buffer, coords);
		gl.buffer_data(GL.array_buffer, coord_data, GL.static_draw);

		vertex_attrib_location va_c;
		gl.query_location(va_c, prog, "Coord");
		gl.vertex_array_attrib_pointer(
			va_c,
			2, GL.float_,
			false, 0, nullptr
		);
		gl.enable_vertex_array_attrib(va_c);

//.........这里部分代码省略.........
开发者ID:deranen,项目名称:oglplu2,代码行数:101,代码来源:011_mandelbrot.cpp

示例7: program

	erase_program(const example_params& params)
	 : program(build_program(_get_source(params)))
	{
		gl.use(*this);
		gl.query_location(projection, *this, "Projection");
	}
开发者ID:matus-chochlik,项目名称:oglplu2,代码行数:6,代码来源:028_lighting.cpp


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