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


C++ LightSource::setDiffuse方法代码示例

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


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

示例1: init

void init() {

    camera.position[2] = 15;

    libpng_version();

    light0.slot = GL_LIGHT0;
    light0.setDiffuse(1.0, 1.0, 1.0, 1.0);
    light0.setPosition(0.0, 0.0, 1.0, 0.0);
    light0.load();
    light0.enable();

    glewInit();

    loadObj((char*) "models/350z.obj", &mesh);
    VBOfromMesh(vbo, mesh);

    vbo.generate();

    int w, h;
    test_texture = texture_bank.findOrReg((char*) "textures/350z/vinyls.png");
    //test_texture = PNG_load((const char*) "textures/vinyls.png", &w, &h);

    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, test_texture);

    programID = loadShaders("shaders/vertex.glsl", "shaders/fragment.glsl");
    glUseProgram(programID);

    uTex = glGetUniformLocation(programID, "texDiff");
    glUniform1i(uTex, 0);

    uProjection = glGetUniformLocation(programID, "projection");
    uView = glGetUniformLocation(programID, "view");
    uModel = glGetUniformLocation(programID, "model");

    uLightPos = glGetUniformLocation(programID, "lightPos");
    uLightDiff = glGetUniformLocation(programID, "lightDiff");
    uLightSpec = glGetUniformLocation(programID, "lightSpec");

    uCameraPosition = glGetUniformLocation(programID, "cameraPosition");

    glEnable(GL_LIGHTING);
    glEnable(GL_COLOR_MATERIAL);
    glEnable(GL_ALPHA_TEST);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);

    glEnable(GL_DEPTH_TEST);
}
开发者ID:Starkus,项目名称:NewHorizon,代码行数:51,代码来源:NewHorizon.cpp

示例2: init


//.........这里部分代码省略.........
		CAR_CAMERA_DISTANCE);
	_carCamera->setCenter(_car->getPosition()->getX(), _car->getPosition()->getY(), _car->getPosition()->getZ());
	//_carCamera->setUp(_car->getSpeed()->getX(), _car->getSpeed()->getY(), _car->getSpeed()->getZ());
	_carCamera->setUp(0, 0, 1);
	_carCamera->update(60, 1, 0.01, 150);


	//Constructing light sources

	Vela* vela1 = new Vela();
	vela1->setPosition(-6, 6, 1.6);
	_gameObjects.push_back(vela1);

	Vela* vela2 = new Vela();
	vela2->setPosition(6, 6, 1.6);
	_gameObjects.push_back(vela2);

	Vela* vela3 = new Vela();
	vela3->setPosition(0, -6, 1.6);
	_gameObjects.push_back(vela3);

	Vela* vela4 = new Vela();
	vela4->setPosition(-10, -10, 1.6);
	_gameObjects.push_back(vela4);

	Vela* vela5 = new Vela();
	vela5->setPosition(10, -10, 1.6);
	_gameObjects.push_back(vela5);

	Vela* vela6 = new Vela();
	vela6->setPosition(0, 14, 1.6);
	_gameObjects.push_back(vela6);


	LightSource* daylight = new LightSource(0);
	daylight->setPosition(0, 0, 10, 0);
	daylight->setAmbient(0.5, 0.5, 0.5, 1);
	daylight->setDiffuse(1, 1, 1, 1);
	daylight->setSpecular(1, 1, 1, 1);
	_lightSources.push_back(daylight);

	LightSource* candle1 = new LightSource(1);
	candle1->setPosition(-6, 6, 1, 1);
	candle1->setAmbient(0.7, 0.7, 0.7, 1);
	candle1->setDiffuse(1, 1, 1, 1);
	candle1->setSpecular(1, 1, 1, 1);
	candle1->setAttenuation(1, 0, 0.1);
	_lightSources.push_back(candle1);

	LightSource* candle2 = new LightSource(2);
	candle2->setPosition(6, 6, 1, 1);
	candle2->setAmbient(0.7, 0.7, 0.7, 1);
	candle2->setDiffuse(1, 1, 1, 1);
	candle2->setSpecular(1, 1, 1, 1);
	candle2->setAttenuation(1, 0, 0.1);
	_lightSources.push_back(candle2);

	LightSource* candle3 = new LightSource(3);
	candle3->setPosition(0, -6, 1, 1);
	candle3->setAmbient(0.7, 0.7, 0.7, 1);
	candle3->setDiffuse(1, 1, 1, 1);
	candle3->setSpecular(1, 1, 1, 1);
	candle3->setAttenuation(1, 0, 0.1);
	_lightSources.push_back(candle3);

	LightSource* candle4 = new LightSource(4);
	candle4->setPosition(-10, -10, 1, 1);
	candle4->setAmbient(0.7, 0.7, 0.7, 1);
	candle4->setDiffuse(1, 1, 1, 1);
	candle4->setSpecular(1, 1, 1, 1);
	candle4->setAttenuation(1, 0, 0.1);
	_lightSources.push_back(candle4);

	LightSource* candle5 = new LightSource(5);
	candle5->setPosition(10, -10, 1, 1);
	candle5->setAmbient(0.7, 0.7, 0.7, 1);
	candle5->setDiffuse(1, 1, 1, 1);
	candle5->setSpecular(1, 1, 1, 1);
	candle5->setAttenuation(1, 0, 0.1);
	_lightSources.push_back(candle5);

	LightSource* candle6 = new LightSource(6);
	candle6->setPosition(0, 15, 1, 1);
	candle6->setAmbient(0.7, 0.7, 0.7, 1);
	candle6->setDiffuse(1, 1, 1, 1);
	candle6->setSpecular(1, 1, 1, 1);
	candle6->setAttenuation(1.0, 0, 0.1);
	_lightSources.push_back(candle6);

	LightSource* spotlight = new LightSource(7);
	spotlight->setAmbient(0.8, 0.8, 0.8, 1);
	spotlight->setDiffuse(1, 1, 1, 1);
	spotlight->setSpecular(1, 1, 1, 1);
	spotlight->setExponent(new GLfloat(5));
	spotlight->setCutOff(new GLfloat(40));
	spotlight->setAttenuation(0, 0.6, 0.3);
	_lightSources.push_back(spotlight);

	initIsDone = true;
}
开发者ID:Danisodu,项目名称:Computer-Graphics,代码行数:101,代码来源:GameManager.cpp


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