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


C++ Renderable::saveTexture方法代码示例

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


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

示例1: init

void Shadows::init(WidgetRenderer * renderer, Camera& myCam, DebugMenuManager * menu) {
    myCam.lookAt(glm::vec3(-30,20,0),glm::vec3());
    viewCamera = &myCam;
    sceneCam = *viewCamera;
    depthPower = 50;
    specPower = 100;
    thres = .0005f;
    lightColor = glm::vec3(.5,.5,.5);

    biasMatrix = glm::mat4 (
                     0.5, 0.0, 0.0, 0.0,
                     0.0, 0.5, 0.0, 0.0,
                     0.0, 0.0, 0.5, 0.0,
                     0.5, 0.5, 0.5, 1.0
                 );

    ShaderProgram * shadowShader = renderer->addShader("./../shaders/Shadow_V.glsl","./../shaders/Shadow_F.glsl");
    renderer->saveViewTransform(shadowShader,"viewTransform");


    //setup scene
    GeometryInfo * planeGeo = renderer->addGeometry(Neumont::ShapeGenerator::makePlane(2));
    GeometryInfo * objectGeo = renderer->addGeometry(NUShapeEditor::setRandomColor(NUShapeEditor::overrideColorWithTanNormals(Neumont::ShapeGenerator::makeTeapot(20,glm::mat4())),3));

    Renderable * mePlane = setupRenderable(renderer->addRenderable(planeGeo,shadowShader));
    mePlane->transformData.scale = glm::vec3(50,50,50);
    mePlane->transformData.position = glm::vec3(25,0,25);

    Renderable * meObject = setupRenderable(renderer->addRenderable(objectGeo,shadowShader));
    meObject->transformData.position.y = 1;
    meObject->transformData.position.z = -4;
    meObject->transformData.setScale(4);
    meObject->transformData.rotation.x = -90;

    //save into passInfo
    shadowMap = renderer->addPassInfo(true);
    shadowMap->initTextures(renderer->width(),renderer->height());
    shadowMap->cam.enabled = true;
    shadowMap->cam.lookAt(glm::vec3(0,20,-40),glm::vec3());

    shadowShader->saveUniform("shadowMap",ParameterType::PT_TEXTURE, &shadowMap->depthTexture);
    shadowShader->saveUniform("lightColor", lightColor);
    shadowShader->saveUniform("diffusePos", shadowMap->cam.getPos());
    shadowShader->saveUniform("specPower",  specPower);
    shadowShader->saveUniform("camPos",     myCam.getPos());
    shadowShader->saveUniform("camLookAt",  shadowMap->cam.getWorld2View());
    shadowShader->saveUniform("biasMatrix", biasMatrix);
    shadowShader->saveUniform("thres", thres);
    renderer->savePerspectiveMat(shadowShader,"perspectiveMat");


    lightRenderable = renderer->addRenderable(renderer->addGeometry(Neumont::ShapeGenerator::makeSphere(20)),renderer->defaultShaders.passThroughColor);
    lightRenderable->saveMatrixInfo("model2WorldTransform");

    //setting up debugScreen

    ShaderProgram * screenSpaceHeros = renderer->addShader("./../shaders/ScreenSpace_V.glsl","./../shaders/ScreenSpace_F.glsl");
    renderer->saveViewTransform(screenSpaceHeros,"viewTransform");

    GeometryInfo * displayPlaneGeo = renderer->addGeometry(NUShapeEditor::rotate(NUShapeEditor::scaleToRange(Neumont::ShapeGenerator::makePlane(2),.3,.3,.3),90,0,0));
    Renderable * depthPlane = renderer->addRenderable(displayPlaneGeo,screenSpaceHeros, shadowMap->depthTexture);

    depthPlane->transformData.position = glm::vec3(1,.7,-1);
    depthPlane->saveMatrixInfo("meTransform");
    depthPlane->saveTexture("myTexture");
    depthPlane->addUniformParameter("power",depthPower);

    menu->setSliderGranularity(100000);
    menu->edit("Set Cam As Light",camIsLight);
    menu->edit("thres",thres,0,.001);
    menu->edit("nearPlane",renderer->nearPlane,0,.1);
    menu->edit("farPlane",renderer->farPlane,10,100);
}
开发者ID:dragon1672,项目名称:Game-Dev-Class-Repo,代码行数:73,代码来源:Shadows.cpp


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