Пример #1
0
void DebugShapes::initialize()
{
	Neumont::ShapeData cube = Neumont::ShapeGenerator::makeCube();		
	Neumont::ShapeData arrow = Neumont::ShapeGenerator::makeArrow();	
	Neumont::ShapeData plane = Neumont::ShapeGenerator::makePlane(15,15);
	Neumont::ShapeData sphere = Neumont::ShapeGenerator::makeSphere(20);
	Neumont::ShapeData teapot = Neumont::ShapeGenerator::makeTeapot(15, glm::mat4());

	Neumont::ShapeData* table;
	unsigned int numberShapes;
	Neumont::FbxLoader::loadFbxFile("table.fbx", table, numberShapes);

	cubeGeometryIndex = renderer->AddGeometry(cube.verts,cube.vertexBufferSize(),
		cube.indices,cube.numIndices,GL_TRIANGLES);	

	arrowGeometryIndex = renderer->AddGeometry(arrow.verts, arrow.vertexBufferSize(),
		arrow.indices, arrow.numIndices, GL_TRIANGLES);

	planeGeometryIndex = renderer->AddGeometry(plane.verts, plane.vertexBufferSize(),
		plane.indices, plane.numIndices, GL_TRIANGLES);

	sphereGeometryIndex = renderer->AddGeometry(sphere.verts, sphere.vertexBufferSize(),
		sphere.indices, sphere.numIndices, GL_TRIANGLES);

	teapotGeometryIndex = renderer->AddGeometry(teapot.verts, teapot.vertexBufferSize(),
		teapot.indices, teapot.numIndices, GL_TRIANGLES);

	for(unsigned int i = 0; i < numberShapes; i++)
	{
		tableGeometryIndex = renderer->AddGeometry(table[i].verts, table[i].vertexBufferSize(),
			table[i].indices, table[i].numIndices, GL_TRIANGLES);
	}
		
	shaderProgramID = renderer->AddShader("VertexShader.hlsl","FragmentShader.hlsl");
	NormalShaderProgramID = renderer->AddShader("NormalVertexShader.hlsl","NormalFragmentShader.hlsl");
	ReflectionProgramID = renderer->AddShader("VertexShader.hlsl","ReflectionFragmentShader.hlsl");
	VertexDisplacementShaderProgramID = renderer->AddShader("VertexDisplacementShader.hlsl","FragmentShader.hlsl");
	
	cube.cleanUp();
	arrow.cleanUp();
	plane.cleanUp();
	sphere.cleanUp();
	teapot.cleanUp();
}
Пример #2
0
void MyGLWidget::fillBuffer()
{

// arrow
	Neumont::ShapeData data = Neumont::ShapeGenerator::makeArrow();
	arrow_numIndices = data.numIndices;
	arrow_shapeData = data;

	glGenBuffers(1, &arrow_vertexBufferID);
	glGenBuffers(1, &arrow_indexBufferID);

	glBindBuffer(GL_ARRAY_BUFFER, arrow_vertexBufferID);
	glBufferData(GL_ARRAY_BUFFER, data.vertexBufferSize(), data.verts, GL_STATIC_DRAW);
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, arrow_indexBufferID);
	glBufferData(GL_ELEMENT_ARRAY_BUFFER, data.indexBufferSize(), data.indices, GL_STATIC_DRAW);

	data.cleanUp();

// torus
	data = Neumont::ShapeGenerator::makeTorus(50);
	torus_numIndices = data.numIndices;
	torus_shapeData = data;

	glGenBuffers(1, &torus_vertexBufferID);
	glGenBuffers(1, &torus_indexBufferID);

	glBindBuffer(GL_ARRAY_BUFFER, torus_vertexBufferID);
	glBufferData(GL_ARRAY_BUFFER, data.vertexBufferSize(), data.verts, GL_STATIC_DRAW);
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, torus_indexBufferID);
	glBufferData(GL_ELEMENT_ARRAY_BUFFER, data.indexBufferSize(), data.indices, GL_STATIC_DRAW);

	data.cleanUp();

// Tell GL how to read the bits (3 for the position, 4 for the color)
	glEnableVertexAttribArray(0);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, Neumont::Vertex::STRIDE, 0);

	glEnableVertexAttribArray(1);
	glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, Neumont::Vertex::STRIDE, BUFFER_OFFSET(Neumont::Vertex::COLOR_OFFSET));
}