Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
   Copyright (c) 2014 DIVIDE-Studio
   Copyright (c) 2009 Ionut Cava

   This file is part of DIVIDE Framework.

   Permission is hereby granted, free of charge, to any person obtaining a copy of this software
   and associated documentation files (the "Software"), to deal in the Software without restriction,
   including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
   and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
   subject to the following conditions:

   The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
   INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

 */

#ifndef _TEXTURE_H
#define _TEXTURE_H

#include "TextureDescriptor.h"
#include "Core/Resources/Headers/HardwareResource.h"

namespace Divide {

/// An API-independent representation of a texture
class Texture : public HardwareResource {
    friend class ResourceCache;
    friend class ResourceLoader;
    template<typename T>
    friend class ImplResourceLoader;

public:
    /// Bind the texture to the specified texture unit
    virtual void Bind(U16 slot) = 0;
    /// Change the texture's mip levels. This can be called at any time
    virtual void setMipMapRange(U16 base = 0, U16 max = 1000) = 0;
    // API-dependent loading function that uploads ptr data to the GPU using the specified parameters
    virtual void loadData(U32 target, const U8* const ptr, const vec2<U16>& dimensions, const vec2<U16>& mipLevels, 
                          GFXImageFormat format, GFXImageFormat internalFormat, bool usePOW2 = false) = 0;

    /// Specify the sampler descriptor used to sample from this texture in the shaders
    inline void setCurrentSampler(const SamplerDescriptor& descriptor) {
        // This can be called at any time
        _samplerDescriptor = descriptor;
        // The sampler will be updated before the next bind call and used in that bind
        _samplerDirty = true;
    }
    /// Get the sampler descriptor used by this texture
    inline const SamplerDescriptor& getCurrentSampler() const {
        return _samplerDescriptor;
    }
    /// Set/Get the number of layers (used by texture arrays)
    inline void        setNumLayers(U8 numLayers)       { _numLayers  = numLayers; }
    inline U8          getNumLayers()             const { return _numLayers; }
    /// Texture bit depth as returned by DevIL
    inline U8          getBitDepth()              const { return _bitDepth; }
    /// Texture width as returned by DevIL
    inline U16         getWidth()                 const { return _width; }
    /// Texture height depth as returned by DevIL
    inline U16         getHeight()                const { return _height; }
    /// A rendering API level handle used to uniquely identify this texture (e.g. for OpenGL, it's the texture object)
    inline U32         getHandle()                const { return _handle; }
    /// Simple flag to check if the texture was flipped vertically
    inline bool        isVerticallyFlipped()      const { return _flipped; }
    /// If the texture has an alpha channel and at least one pixel is translucent, return true
    inline bool        hasTransparency()          const { return _hasTransparency; }
    /// Get the type of the texture
    inline TextureType getTextureType()           const { return _textureType; }
    /// Force a full refresh of the mip chain on the next texture bind
    inline void refreshMipMaps() { _mipMapsDirty = true; }

protected:
    SET_DELETE_FRIEND

    /// Use DevIL to load a file into a Texture Object
    bool LoadFile(U32 target, const stringImpl& name);
    /// Load texture data using the specified file name
    virtual bool generateHWResource(const stringImpl& name);
    /// Force a refresh of the entire mipmap chain
    virtual void updateMipMaps() = 0;

    explicit Texture( TextureType type, const bool flipped = false );
    virtual ~Texture();
protected:
    U8 _bitDepth;
    U8 _numLayers;
    U16 _width;
    U16 _height;
    bool _flipped;
    bool _mipMapsDirty;
    bool _samplerDirty;
    bool _hasTransparency;
    TextureType _textureType;
    mat4<F32> _transformMatrix;
    std::atomic<U32>    _handle;
    SamplerDescriptor _samplerDescriptor;
};

}; //namespace Divide
#endif

Commits for Divide-Framework/trunk/Source Code/Platform/Video/Textures/Headers/Texture.h

Diff revisions: vs.
Revision Author Commited Message
337 Diff Diff IonutCava picture IonutCava Wed 17 Dec, 2014 17:25:16 +0000

[Ionut]
- Replaced all tabs with 4 spaces (some spacing may be off now. no way to check all the files.)
- Moved implementation details for ParamHandler, BoundingBox, BoundingSphere and ProfileTimer to proper .inl and .cpp files. (more to follow)
- Update all forward declared enums with the required storage type (as requested by the C++11 standard)

334 IonutCava picture IonutCava Wed 10 Dec, 2014 17:21:22 +0000

[Ionut]
- Reorganized the Hardware project and renamed to "Platform"
- Reorganized the Server project