TextureControlFileJPG.cc 1.15 KB
Newer Older
Robert Menzel's avatar
Robert Menzel committed
1
2
3
4
5
////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2011, Computer Graphics Group RWTH Aachen University         //
// All rights reserved.                                                       //
////////////////////////////////////////////////////////////////////////////////

Robert Menzel's avatar
Robert Menzel committed
6
#include <ACGL/OpenGL/Controller/TextureControlFileJPG.hh>
Robert Menzel's avatar
Robert Menzel committed
7

Robert Menzel's avatar
Robert Menzel committed
8
using namespace ACGL::OpenGL;
Robert Menzel's avatar
Robert Menzel committed
9
10
11
12
13

SharedTexture TextureControlFileJPG::create(void)
{
    updateFileModificationTime();

14
15
16
17
18
    SharedTexture texture(new Texture(GL_TEXTURE_2D));

    texture->bind();
    texture->setMinFilter(mMinFilter == 0 ? GL_LINEAR_MIPMAP_LINEAR : mMinFilter);
    texture->setMagFilter(mMagFilter == 0 ? GL_LINEAR : mMagFilter);
19
    if(mWrapS > 0) texture->setWrap(mWrapS, mWrapT, mWrapR);
Robert Menzel's avatar
Robert Menzel committed
20

Robert Menzel's avatar
Robert Menzel committed
21
    if(mAnisotropicFilter > 0.0f)
22
23
        texture->setAnisotropicFilter(mAnisotropicFilter);

Robert Menzel's avatar
Robert Menzel committed
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
    if(loadJPG(texture))
        return texture;

    return SharedTexture();
}

bool TextureControlFileJPG::update(SharedTexture& texture)
{
    if(fileIsUpToDate())
        return false;

    if(!loadJPG(texture))
        return false;

    updateFileModificationTime();
    return true;
}