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


C++ SkyBox::loadShader方法代码示例

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


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

示例1: createSkyBox

//Sets up the appropriate vertice positions for the cube, selects the appropriate indices to form the cube,
//then intiailizes the mesh so we can copy the mesh related data(indices/triangledata) to the mesh so we are ready
//for setting the material. We set up the position, intialize the material and load in the cube texture then set
//the material/mesh and transform then check to make sure no errors occur.
void SplashScreen::createSkyBox()
{
	Vertex triangleData[] = {
			{ vec3(-50.0f, 50.0f, 50.0f) },// Top Left
			{ vec3(-50.0f, -50.0f, 50.0f) },// Bottom Left
			{ vec3(50.0f, -50.0f, 50.0f) }, //Bottom Right
			{ vec3(50.0f, 50.0f, 50.0f) },// Top Right

			{ vec3(-50.0f, 50.0f, -50.0f) },// Top Left
			{ vec3(-50.0f, -50.0f, -50.0f) },// Bottom Left
			{ vec3(50.0, -50.0f, -50.0f) }, //Bottom Right
			{ vec3(50.0f, 50.0f, -50.0f) }// Top Right
	};

	GLuint indices[] = {
		//front
		0, 1, 2,
		3, 2, 0,

		//left
		3, 2, 6,
		6, 7, 3,

		//right
		7, 6, 5,
		5, 4, 7,

		//bottom
		4, 5, 1,
		1, 0, 4,

		//top
		4, 0, 3,
		3, 7, 4,

		//back
		1, 5, 6,
		6, 2, 1
	};

	////creat mesh and copy in
	Mesh * pMesh = new Mesh();
	pMesh->init();

	pMesh->copyVertexData(8, sizeof(Vertex), (void**)triangleData);
	pMesh->copyIndexData(36, sizeof(int), (void**)indices);

	Transform *t = new Transform();
	t->setPosition(0.0f, 0.0f, 0.0f);
	//load textures and skybox material + Shaders
	SkyBox *material = new SkyBox();
	material->init();

	std::string vsPath = ASSET_PATH + SHADER_PATH + "/skyVS.glsl";
	std::string fsPath = ASSET_PATH + SHADER_PATH + "/skyFS.glsl";
	material->loadShader(vsPath, fsPath);

	std::string posZTexturename = ASSET_PATH + TEXTURE_PATH + "CloudyLightRaysFront2048.png";
	std::string negZTexturename = ASSET_PATH + TEXTURE_PATH + "CloudyLightRaysBack2048.png";
	std::string posXTexturename = ASSET_PATH + TEXTURE_PATH + "CloudyLightRaysLeft2048.png";
	std::string negXTexturename = ASSET_PATH + TEXTURE_PATH + "CloudyLightRaysRight2048.png";
	std::string posYTexturename = ASSET_PATH + TEXTURE_PATH + "CloudyLightRaysUp2048.png";
	std::string negYTexturename = ASSET_PATH + TEXTURE_PATH + "CloudyLightRaysDown2048.png";

	material->loadCubeTexture(posZTexturename, negZTexturename, posXTexturename, negXTexturename, posYTexturename, negYTexturename);
	//create gameobject but don't add to queue!
	skyBoxObject = new GameObject();
	skyBoxObject->setMaterial(material);
	skyBoxObject->setTransform(t);
	skyBoxObject->setMesh(pMesh);

	GLenum error;
	do{
		error = glGetError();
	} while (error != GL_NO_ERROR);
}
开发者ID:CallumF15,项目名称:GP2_E-MC-Coursework,代码行数:80,代码来源:SplashScreen.cpp


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