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


C++ VertexArray::create方法代码示例

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


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

示例1: init

void init(Renderer &gfx, Context &ctx)
{
	vao.create();
	vao.bind();

	//int tex_res_x = ctx.getWidth();
	//int tex_res_y = ctx.getHeight();

	velocity.Ping.init(GRID_RES, GRID_RES);
	velocity.Pong.init(GRID_RES, GRID_RES);
	pressure.Ping.init(GRID_RES, GRID_RES);
	pressure.Pong.init(GRID_RES, GRID_RES);
	div_field.init(GRID_RES, GRID_RES);
	
	tex_velocity.create(0, GL_RGB32F, GRID_RES, GRID_RES, GL_RG, GL_FLOAT, NULL);
	tex_pressure.create(0, GL_RGB32F, GRID_RES, GRID_RES, GL_RG, GL_FLOAT, NULL);

	tex_velocity.setTexParameteri(GL_NEAREST, GL_NEAREST, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE);
	tex_pressure.setTexParameteri(GL_NEAREST, GL_NEAREST, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE);

	screen_quad.create(Mesh::genScreenSpaceTexQuad());

	pressure.Ping.set(7, 5, vec2(10.0f, 0.0));
	pressure.Ping.set(6, 5, vec2(10.0f, 0.0));
	pressure.Ping.set(5, 5, vec2(10.0f, 0.0));
	pressure.Pong.set(7, 5, vec2(10.0f, 0.0));
	pressure.Pong.set(6, 5, vec2(10.0f, 0.0));
	pressure.Pong.set(5, 5, vec2(10.0f, 0.0));
}
开发者ID:lightbits,项目名称:glterrain,代码行数:29,代码来源:app_old.cpp

示例2: init

void init(Renderer &gfx, Context &ctx)
{
	// Use the compute shader to work magic on the texture
	gfx.beginCustomShader(shader_compute);
	gfx.setUniform("inTex", 0);
	gfx.setUniform("outTex", 1);
	glBindImageTexture(0, tex.getHandle(), 0, GL_FALSE, 0, GL_READ_ONLY, GL_RGBA16F);
	glBindImageTexture(1, tex_blurred.getHandle(), 0, GL_FALSE, 0, GL_READ_WRITE, GL_RGBA16F);
	glDispatchCompute(
		tex.getWidth() / NUM_GROUPS_X,
		tex.getHeight() / NUM_GROUPS_Y,
		1);

	const float vertices[] = {	
		-1.0f, -1.0f,
		+1.0f, -1.0f,
		+1.0f, +1.0f,
		+1.0f, +1.0f,
		-1.0f, +1.0f,
		-1.0f, -1.0f
	};

	vbo.create(GL_ARRAY_BUFFER, GL_STATIC_DRAW);
	vbo.bind();
	vbo.bufferData(sizeof(vertices), vertices);

	vao.create();
	vao.bind();
}
开发者ID:lightbits,项目名称:glterrain,代码行数:29,代码来源:blurcompute.cpp

示例3: init

void init(Renderer &gfx, Context &ctx)
{	
	vao.create();
	vao.bind();

	cube_buffer.create(Mesh::genUnitCube(false, true, true));
	cube = Model(cube_buffer);

	skybox_buffer.create(Mesh::genUnitCube(false, false, true));
	skybox = Model(skybox_buffer);

	mat_view = mat4(1.0f);
	mat_projection = glm::perspective(PI / 5.0f, ctx.getWidth() / (float)ctx.getHeight(), 0.05f, 15.0f);

	camera.reset(0.0f, 0.0f, vec3(0.0f, 0.2f, 1.0f));
}
开发者ID:lightbits,项目名称:glterrain,代码行数:16,代码来源:app.cpp

示例4: run

void run()
{
	if(!initialize())
		shutdown("Failed to initialize");

	if(!loadContent())
		shutdown("Failed to load resources");	

	Mesh cubeMesh = Mesh::genUnitColoredCube();
	MeshBuffer cubeBuffer(cubeMesh);
	Model cube(cubeBuffer);

	Mesh waterMesh = Mesh::genUnitColoredPlane(Color(0.57f, 0.63f, 0.98f));
	MeshBuffer waterBuffer(waterMesh);
	Model water(waterBuffer);

	BufferObject quadVbo;
	float quadVertices[] = {
		-1.0f, -1.0f, 0.0f, 0.0f,
		+1.0f, -1.0f, 1.0f, 0.0f,
		+1.0f, +1.0f, 1.0f, 1.0f,
		+1.0f, +1.0f, 1.0f, 1.0f,
		-1.0f, +1.0f, 0.0f, 1.0f,
		-1.0f, -1.0f, 0.0f, 0.0f
	};
	quadVbo.create(GL_ARRAY_BUFFER, GL_STATIC_DRAW, sizeof(quadVertices), quadVertices);

	Mesh gridMesh;
	for(int i = 0; i <= 8; ++i)
	{
		float f = (i / 8.0) * 2.0f - 1.0f;
		int j = gridMesh.getPositionCount();
		gridMesh.addPosition(f * 3.0f, 0.0f, -3.0f);
		gridMesh.addPosition(f * 3.0f, 0.0f, +3.0f);
		gridMesh.addPosition(-3.0f, 0.0f, f * 3.0f);
		gridMesh.addPosition(+3.0f, 0.0f, f * 3.0f);
		gridMesh.addColor(Colors::White);
		gridMesh.addColor(Colors::White);
		gridMesh.addColor(Colors::White);
		gridMesh.addColor(Colors::White);
		gridMesh.addIndex(j + 0); gridMesh.addIndex(j + 1);
		gridMesh.addIndex(j + 2); gridMesh.addIndex(j + 3);
	}
	MeshBuffer gridBuffer(gridMesh);
	Model grid(gridBuffer);

	VertexArray vao;
	vao.create();
	vao.bind();

	mat4 perspectiveMatrix = glm::perspective(45.0f, windowWidth / float(windowHeight), 0.05f, 50.0f);
	
	// The geometry to be refracted and reflected are stored in these
	// In addition to RGB values, the world-space height is stored in the alpha-channel
	// of the refraction texture.
	// Fresnel equations is used to blend between the two textures
	RenderTexture refractionRT(windowWidth, windowHeight);
	RenderTexture reflectionRT(windowWidth, windowHeight);

	renderer.setClearColor(0.55f, 0.45f, 0.45f, 1.0f);
	renderer.setClearDepth(1.0);

	Timer timer;
	timer.start();
	double renderTime = 0.0;

	while(context.isOpen())
	{
		timer.step();
		double time = timer.getElapsedTime();
		update(time, timer.getDelta());
		double renderStart = timer.getElapsedTime();

		MatrixStack viewMatrix;
		viewMatrix.push();
		viewMatrix.translate(0.0f, 0.0f, -3.0f);
		viewMatrix.rotateX(xAxisRotation);
		viewMatrix.rotateY(yAxisRotation);

		renderer.setCullState(CullStates::CullNone);
		renderer.setDepthTestState(DepthTestStates::LessThanOrEqual);
		
		colorShader.begin();
		colorShader.setUniform("projection", perspectiveMatrix);
		cube.pushTransform();
		cube.translate(0.0f, 0.0f, 0.0f);
		cube.scale(0.5f);

		// Render the geometry to be refracted, store result in rt
		refractionRT.begin();
		renderer.clearColorAndDepth();
		colorShader.setUniform("view", viewMatrix.top());
		cube.draw(GL_TRIANGLES);
		grid.draw(GL_LINES);
		refractionRT.end();

		// Render the geometry to be reflected, store result in rt
		reflectionRT.begin();
		renderer.clearColorAndDepth();
		viewMatrix.push();
//.........这里部分代码省略.........
开发者ID:lightbits,项目名称:glterrain,代码行数:101,代码来源:17water.cpp


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