Esempio n. 1
0
void NormalMapScene::initialise()
{
    // Create a material that performs multi-texturing
#if !defined(Q_OS_MAC)
    MaterialPtr material = createTextureMaterial(
                               "../../../opengl/assets/meshes/ogrehead/ogrehead_diffuse.png",
                               "../../../opengl/assets/meshes/ogrehead/ogre_normalmap.png" );
#else
    MaterialPtr material = createTextureMaterial(
                               "../../../../../../opengl/assets/meshes/ogrehead/ogrehead_diffuse.png",
                               "../../../../../../opengl/assets/meshes/ogrehead/ogre_normalmap.png" );
#endif

    // Load the model mesh
    ObjLoader loader;
    loader.setLoadTextureCoordinatesEnabled( true );
    loader.setTangentGenerationEnabled( true );
#if !defined(Q_OS_MAC)
    loader.load( "../../../opengl/assets/meshes/ogrehead/ogrehead.obj" );
#else
    loader.load( "../../../../../../opengl/assets/meshes/ogrehead/ogrehead.obj" );
#endif

    m_mesh = new Mesh( this );
    m_mesh->setMaterial( material );
    m_mesh->setMeshData( loader );

    // Enable depth testing
    glEnable( GL_DEPTH_TEST );

    // Set the clear color to white
    glClearColor( 1.0f, 1.0f, 1.0f, 1.0f );
}
Esempio n. 2
0
void NormalMapScene::initialise()
{
    //dumpTextureUnitConfiguration();

#if !defined(Q_OS_MAC)
    m_funcs = m_context->versionFunctions<QOpenGLFunctions_3_3_Compatibility>();
#else
    m_funcs = m_context->versionFunctions<QOpenGLFunctions_2_1>();
#endif
    if ( !m_funcs )
        qFatal( "Could not obtain functions object" );
    m_funcs->initializeOpenGLFunctions();

    // Create a material that performs multi-texturing
#if !defined(Q_OS_MAC)
    MaterialPtr material = createTextureMaterial( "../../assets/meshes/ogrehead/ogrehead_diffuse.png",
                                                  "../../assets/meshes/ogrehead/ogre_normalmap.png" );
#else
    MaterialPtr material = createTextureMaterial(
                               "../../../opengl/assets/meshes/ogrehead/ogrehead_diffuse.png",
                               "../../../opengl/assets/meshes/ogrehead/ogre_normalmap.png" );
#endif

    // Load the model mesh
    ObjLoader loader;
    loader.setLoadTextureCoordinatesEnabled( true );
    loader.setTangentGenerationEnabled( true );
#if !defined(Q_OS_MAC)
    loader.load( "../../assets/meshes/ogrehead/ogrehead.obj" );
#else
    loader.load( "../../../opengl/assets/meshes/ogrehead/ogrehead.obj" );
#endif

    m_mesh = new Mesh;
    m_mesh->setMaterial( material );
    m_mesh->setMeshData( loader );

    // Enable depth testing
    glEnable( GL_DEPTH_TEST );

    // Set the clear color to (almost) white
    glClearColor( 0.9f, 0.9f, 0.9f, 1.0f );

    m_funcs->glActiveTexture( GL_TEXTURE1 );
    m_funcs->glBindTexture( GL_TEXTURE_2D, 0 );
    m_funcs->glActiveTexture( GL_TEXTURE0 );
    m_funcs->glBindTexture( GL_TEXTURE_2D, 0 );

    //dumpTextureUnitConfiguration();
}