コード例 #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 );
}
コード例 #2
0
void AmbientOcclusionScene::initialise()
{
    // Load the model mesh
    ObjLoader loader;
    loader.setTangentGenerationEnabled( false );
#if !defined(Q_OS_MAC)
    loader.load( "../../../opengl/assets/meshes/ogrehead/ogrehead.obj" );
#else
    loader.load( "../../../../../../opengl/assets/meshes/ogrehead/ogrehead.obj" );
#endif

    // Create an ambient occlusion material that uses a diffuse texture
    // and an ambient occlusion (accessibility factors) texture
#if !defined(Q_OS_MAC)
    MaterialPtr material =
        createAmbientOcclusionMaterial(
                "../../../opengl/assets/meshes/ogrehead/ogrehead_diffuse.png",
                "../../../opengl/assets/meshes/ogrehead/ogrehead_ambientocclusion.png" );
#else
    MaterialPtr material =
        createAmbientOcclusionMaterial(
                "../../../../../../opengl/assets/meshes/ogrehead/ogrehead_diffuse.png",
                "../../../../../../opengl/assets/meshes/ogrehead/ogrehead_ambientocclusion.png" );
#endif

    // Create a renderable object
    m_mesh = new Mesh;
    m_mesh->setMaterial( material );
    m_mesh->setMeshData( loader );

    // Enable depth testing
    glEnable( GL_DEPTH_TEST );

    glClearColor( 0.9f, 0.9f, 0.9f, 1.0f );
}
コード例 #3
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();
}
コード例 #4
0
void CubeMapRefractionScene::initialise()
{
    // Set the clear color to black
    glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );

    // Create a material to be shared by the skybox and reflective object
    MaterialPtr material( new Material );
    material->setShaders( ":/shaders/skyboxrefraction.vert",
                          ":/shaders/skyboxrefraction.frag" );

    // Create the skybox
    m_skyBox->setMaterial( material );
    m_skyBox->create();
#if !defined(Q_OS_MAC)
    m_skyBox->setCubeMapBaseName( "../../../opengl/assets/textures/cubemap_miramar/miramar" );
#else
    m_skyBox->setCubeMapBaseName( "../../../../../../opengl/assets/textures/cubemap_miramar/miramar" );
#endif

    // Create a renderable object
    // Load the model mesh
    ObjLoader loader;
    loader.setTangentGenerationEnabled( false );
#if !defined(Q_OS_MAC)
    loader.load( "../../../opengl/assets/meshes/toyplane.obj" );
#else
    loader.load( "../../../../../../opengl/assets/meshes/toyplane.obj" );
#endif

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

    // Enable depth testing
    glEnable( GL_DEPTH_TEST );
}