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


C++ TextureManager::loadTextureFromFileAsync方法代码示例

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


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

示例1: main

int main(int argc, char *argv[])
{
    device = CreateDevice(Vector2i(800, 600), "R3D Engine 2.0");

    char buf[128];
    int fps=0;
    double lastTime=device->getTime();
    
    TextureManager *tm = device->getTextureManager();

    RenderTarget *rt = BuildGBuffer(device, {800, 600});

    ShaderProgram *program = device->addShaderProgram();
    program->create(LoadFile("vs2.txt").c_str(), LoadFile("fs2.txt").c_str());


    GLuint id;
    glGenVertexArrays(1, &id);

    auto *camera = device->getSceneManager()->getCamera();

    while(device->isRunning()) {
        device->update();

        if(device->getInput()->isKeyDown(KeyCode::KEY_ESCAPE))
            device->stop();

        if(device->getInput()->isKeyDown(KeyCode::KEY_L))
            tm->loadTextureFromFileAsync("./water.png", "water.png", nullptr);
        if(device->getInput()->isKeyDown(KeyCode::KEY_M))
            device->getSceneManager()->loadWavefrontAsync("sponza/sponza.obj");

        //auto view = LookAt({100.f, 100.f, 100.f}, {0.f}, {0.f, 1.f, 0.f});
        program->setUniform("vp", camera->getProjectionMatrix()*camera->getViewMatrix());
        program->setUniform("v", Matrix4(Matrix3(camera->getViewMatrix())));

        device->getDefaultRenderTarget()->bind();
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glEnable(GL_DEPTH_TEST);

        program->use();
        device->getSceneManager()->drawAll();
/*
        glBindVertexArray(id);
        program->use();
        tm->fetchTexture("./water.png")->bind(0);
        glDrawArrays(GL_TRIANGLES, 0, 6);
*/
        device->swapBuffers();

        fps++;
        if(device->getTime() - lastTime>1.0) {
            sprintf(buf, "R3D Engine 2.0 - %.1f fps", device->getFrameRate());
            device->setWindowCaption(buf);
            fps=0;
            lastTime = device->getTime();
        }
    }
    
    DestroyDevice(device);
    return 0;
}
开发者ID:tim37021,项目名称:R3D2,代码行数:62,代码来源:main.cpp


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