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


C++ TextureLoader::LoadTexture方法代码示例

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


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

示例1: TextureLoader

void MS3D::reloadTextures()
{
    for ( int i = 0; i < m_numMaterials; i++ )
    {
        if ( strlen( m_pMaterials[i].m_pTextureFilename ) > 0 )
        {
            std::stringstream fn;
            std::string file = m_pMaterials[i].m_pTextureFilename;
            file = file.substr(0, file.length() - 4);
            fn << _path << file << ".png";
            TextureLoader *tload = new TextureLoader();
            m_pMaterials[i].m_texture = tload->LoadTexture( fn.str().c_str() );
            delete tload;
        }
        else
        {
            m_pMaterials[i].m_texture = 0;
        }
    }
}
开发者ID:GiR-Zippo,项目名称:GWAN-Engine,代码行数:20,代码来源:MS3D.cpp

示例2: main

int main() {

    DisplayManager displayManager(WINDOW_WIDTH, WINDOW_HEIGHT, "Neptune Physics Simulator");
    displayManager.Enable(GL_DEPTH_TEST);
    //displayManager.Enable(GL_CULL_FACE);
    glCullFace(GL_BACK);

    //Input handling
    glfwSetInputMode(displayManager.getWindow(), GLFW_CURSOR, GLFW_CURSOR_DISABLED);
    glfwSetKeyCallback(displayManager.getWindow(), key_callback);
    glfwSetCursorPosCallback(displayManager.getWindow(), mouse_callback);

    //TODO: Add to camera setup
    glm::mat4 model;
    glm::mat4 view;
    glm::mat4 projection;
    projection = glm::perspective(45.0f, WINDOW_WIDTH / (float)WINDOW_HEIGHT, 0.1f, 100.0f);

    Renderer objRenderer;
    ObjectLoader objLoader;

    //Load Texture
    TextureLoader textLoader;
    GLuint textureId = textLoader.LoadTexture("..\\..\\external\\resources\\textures\\container.png");

    //Loading OBJ mesh
    auto meshRawModel = objLoader.LoadMesh("..\\..\\external\\resources\\objects\\suzanneSmall.obj");

    //Init physics system
    npDiscreteDynamicsWorld* world = new npDiscreteDynamicsWorld();
    initializeObjects(world, meshRawModel.minVector, meshRawModel.maxVector);

    Light staticLight;
    staticLight.position = glm::vec3(0.0f, 1.0f, 10.0f);
    staticLight.color = glm::vec3(1.0f, 1.0f, 1.0f);

    //Init Shaders
    ModelShader meshShader("shaders\\vertexShader.vert", "shaders\\fragmentShader.frag");
    ModelShader BVShader("shaders\\BVvertexShader.vert", "shaders\\BVfragmentShader.frag");

    while (!glfwWindowShouldClose(displayManager.getWindow()))
    {
        GLdouble currentFrame = glfwGetTime();
        deltaTime = currentFrame - lastFrame;
        lastFrame = currentFrame;

        glfwPollEvents();
        gameCamera.ProcessKeyboard(keys, deltaTime);

        objRenderer.PrepareForRendering();

        if (!pauseSimulation) {
            world->stepSimulation(deltaTime);
        }
        
        for (size_t i = 0; i < 2; i++)
        {
            auto rigidBdy = world->getRigidBody(i);

            #ifdef _DEBUG
            if (!pauseSimulation) {
                Log_DEBUG("main.cpp - 197", "Body position:", rigidBdy.getPosition());
            }
            #endif

            npMatrix4 resultingModelMatrix = create4x4Matrix(rigidBdy.getTransformMatrix()).transpose();

            //drawableBV has VBOs (vertex, color)
            BVShader.Use();
            BVShader.LoadViewMatrix(gameCamera.GetViewMatrix());
            BVShader.LoadProjectionMatrix(projection);
            BVShader.LoadModelMatrix(resultingModelMatrix);
            objRenderer.Render(drawableModelList.at(i));
            BVShader.Stop();

            //meshRawModel has other VBOs (vertex, normal, texCoords)
            meshShader.Use();
            meshShader.LoadViewMatrix(gameCamera.GetViewMatrix());
            meshShader.LoadProjectionMatrix(projection);
            meshShader.LoadModelMatrix(resultingModelMatrix);
            meshShader.LoadLightPosition(staticLight.position);
            meshShader.LoadLightColor(staticLight.color);
            meshShader.LoadShineVariables(0.0f, 0.0f);
            textLoader.UseTexture(textureId, meshShader.getProgramID(), "ourTexture");
            objRenderer.Render(meshRawModel, wireFrameMode);
            meshShader.Stop();
        }

        displayManager.UpdateDisplay();
    }

    objLoader.CleanUp();
    textLoader.CleanUp();
    displayManager.CloseDisplay();

    return 1;
    
}
开发者ID:cdrofenik,项目名称:neptunePhysics,代码行数:98,代码来源:main.cpp


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