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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
   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 _UTILITY_IMAGETOOLS_H
#define _UTILITY_IMAGETOOLS_H

#include "Utility/Headers/String.h"
#include "Core/Math/Headers/MathVectors.h"
#include "Platform/Threading/Headers/SharedMutex.h"

namespace Divide {
    enum GFXImageFormat;
    namespace ImageTools {

    class ImageData {
        public:
            ImageData()  : _flip(false),
                           _alpha(false),
                           _bpp(0),
                           _ilTexture(0),
                           _compressed(false),
                           _data(nullptr)
            {
                _dimensions.set(0,0);
            }

            ~ImageData()
            {
                destroy();
            }

            /// creates this image instance from the specified data
            bool create(const stringImpl& fileName);
            /// creates this image by reading a portion of memory from sistem RAM defined by a starting position and a size
            bool create(const void* ptr, U32 size);
            /// destroy the image data allocated by the create call
            void destroy();
            /// change a image's width and height
            void resize(U16 width, U16 height);
            /// image origin information
            inline void flip(bool state)               {_flip = state;}
            inline bool flip()                   const {return _flip;}
            /// set and get the image's actual data
            inline const U8* const data()        const {return _data;}
            /// width * height * bpp
            inline const U32       imageSize()   const {return _imageSize;}
            /// set and get the image's compression state
            inline bool compressed()             const {return _compressed;}
            /// image transparency information
            inline bool alpha()                  const {return _alpha;}
            /// image depth information
            inline U8   bpp()                    const {return _bpp;}
            /// image width and height
            inline const vec2<U16>& dimensions() const {return _dimensions;}
            /// the filename from which the image is created
            inline const stringImpl& name()     const {return _name;}
            /// the image handle as given by DevIL
            inline U32  handle()                 const {return _ilTexture;}
            /// the image format as given by DevIL
            inline GFXImageFormat  format()      const {return _format;}
            /// get the texel color at the specified offset from the origin
            vec4<U8> getColor(U16 x, U16 y)   const;

        private:
            /// this is called by either of the create functions to prepare DevIL for loading
            bool prepareInternalData();
            /// this is called by either of the create functions to set the image info (depth, resolution, pixel data, etc)
            bool setInternalData();
            /// outputs a generic error and sets DevIL's image handle back to 0 so it can be reused on the next "create" call
            void throwLoadError(const stringImpl& fileName);

        private:
            /// the image data as it was read from the file / memory
            U8*	 _data;
            /// is the image stored as a regular image or in a compressed format? (eg. DXT1 / DXT3 / DXT5)
            bool _compressed;
            /// should we flip the image's origin on load?
            bool _flip;
            /// does the image have transparency?
            bool _alpha;
            /// with and height
            vec2<U16> _dimensions;
            /// image's bits per pixel
            U8  _bpp;
            /// number of data elements (w * h * bpp)
            U32 _imageSize;
            /// the image format
            GFXImageFormat _format;
            /// the DevIL texture handle
            U32 _ilTexture;
            /// the actual image filename
            stringImpl _name;
    };

    /// prepares the image loading system
    void initialize();
    /// open an image file and save it's contents in the ImageData object
    inline void OpenImage(const stringImpl& filename, ImageData& img) {img.create(filename);}
    /// read an image file from a block of memory and save it's contents in the ImageData object
    inline void OpenImage(const void* ptr, U32 size, ImageData& img)   { img.create(ptr, size); }
    /// save a single file to TGA
    I8   SaveToTGA(char *filename,  const vec2<U16>& dimensions, U8 pixelDepth, U8 *imageData);
    /// save a single file to tga using a sequential naming pattern
    I8   SaveSeries(char *filename, const vec2<U16>& dimensions, U8 pixelDepth, U8 *imageData);

    /// used to lock DevIL in a sequential operating mode in a multithreaded environment
    static SharedLock _loadingMutex;

    }; //namespace ImageTools
}; //namespace Divide

#endif

Commits for Divide-Framework/trunk/Source Code/Utility/Headers/ImageTools.h

Diff revisions: vs.
Revision Author Commited Message
334 Diff Diff IonutCava picture IonutCava Wed 10 Dec, 2014 17:21:22 +0000

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

333 Diff Diff IonutCava picture IonutCava Tue 09 Dec, 2014 16:15:44 +0000

[Ionut]
- Removed “core.h” and moved everything to their appropriate header files
- Renamed MathClasses to MathMatrices (finally)
- Renamed “-Inl.h” files to ".inl"
- Some String wrapper refactoring
- Update “InstallLibraries.bat” so that it still offers valid options

321 Diff Diff IonutCava picture IonutCava Wed 03 Sep, 2014 22:05:15 +0000

[Ionut]
- Added support (and enabled by default) for the EASTL library (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2271.html / https://github.com/paulhodge/EASTL)
— Strings, vectors and hash_maps can be combined from EASTL, STL and Boost (not all combinations work. e.g. EASTL strings with STL/Boost containers due to the lack of a proper hash function)

318 Diff Diff IonutCava picture IonutCava Sat 30 Aug, 2014 17:35:53 +0000

[Ionut]
- Wrapped the entire code in a “Divide” namespace
- VertexBuffers now call “shrink_to_fit” on all internal data storage
- Improved some vector performance by preferring “emplace_back” instead of “push_back” + proepr usage of reserve / resize
- Wrapped OIS specific types and classes in Divide::Input namespace
- Added the messageBox.layout file (forgot it in the previous few commits)

268 Diff Diff IonutCava picture IonutCava Wed 04 Jun, 2014 10:20:27 +0000

[IonutCava] [[BR]]
- Terrain and vegetation updates: [[BR]]
— Use standard phong lighting model [[BR]]
— Separate grass patches per chunk [[BR]]
— Reduce number of required texture bind points for terrain by adding both textures and normal maps in a single texture array [[BR]]
— Draw terrain with 2 drawcalls (using glMultiDrawElements twice, once for LoD == 0 and once for LoD > 0) [[BR]]
[[BR]]
- Buffer management updates: [[BR]]
— Unified buffer binding system [[BR]]
— Made Uniform buffer objects visible to all classes and moved lightUBO to LightManager, matricesUBO to GFXDevice etc [[BR]]
— Added initial support for Shader Buffer Objects [[BR]]
— Moved viewport management to GFXDevice class [[BR]]
[[BR]]
- Rendering improvements: [[BR]]
— Added Hi-Z occlusion culling to instanceCull shader (using Hi-Z depth buffer constructed in GFXDevice class) [[BR]]
— Resolved issues with shadow maps overriding texture bind locations [[[BR]]
— Improved shader and shader program loading [[BR]]
— Improved material transparency support [[BR]]
— Added buffer lock manager class from “Approaching Zero Driver Overhead in OpenGL (Presented by NVIDIA)” speech at GDC14 [[BR]]

264 Diff Diff k1ngp1n picture k1ngp1n Tue 27 May, 2014 13:04:38 +0000

[Ionut] [[BR]]
- New camera system: [[BR]]
— Stack based (push/pop active camera) [[BR]]
— Per camera frustum [[BR]]
— Per camera projection [[BR]]
— Shadow mapping now uses the new camera system (each light has a shadow camera) [[BR]]
[[BR]]
- New terrain, water and vegetation system: [[BR]]
— Direct import of terrain from L3DT both as 8-bit grayscale and 16-bit raw formats [[BR]]
— Multiple alpha maps for texture splatting support [[BR]]
— Per texture detail map support [[BR]]
— Transform feedback based visibility culling for vegetation [[BR]]
— Alpha-map based vegetation placing on terrain [[BR]]
— Water now uses a refraction map instead of alpha blending for better refraction effects [[BR]]
[[BR]]
- SceneGraph improvements: [[BR]]
— Better bounding box updates from child to parent [[BR]]
— Better onDraw / postDraw implementation [[BR]]
[[BR]]
- Performance improvements: [[BR]]
— Batch 2D rendering tasks together as much as possible[[BR]]
— Improve renderStateBlock hash generation for better sorting [[BR]]
— Move most state related gfx changes from API implementation to the GFXDevice class [[BR]]
— Move viewport stack to the GFXDevice class [[BR]]
— Added various performance counters (frame duration with round-robin query system, draw call count, etc) [[BR]]
— Fixed and improved clip plane management [[BR]]
— Delete client-side texture data after GPU upload [[BR]]
[[BR]]
- New features: [[BR]]
— Added callback support to the Task class so that a specific task may call a function in the main thread upon completion [[BR]]
— Added mouse-wheel zoom support to Orbit/ThirdPerson cameras [[BR]]
— Added 2D Texture Array support (e.g. used for terrain textures) [[BR]]

249 Diff Diff k1ngp1n picture k1ngp1n Mon 31 Mar, 2014 20:42:31 +0000

[Ionut] [[BR]]
- Migrated to platform toolset v100 [[BR]]
- Updated boost to 1.55 [[BR]]
- Moved from “NULL” to “nullptr” [[BR]]
- DevIL is now linked dynamically [[BR]]

221 Diff Diff k1ngp1n picture k1ngp1n Wed 08 Jan, 2014 18:50:02 +0000

[Ionut] [[BR]]
- Merged branch “Shadows And Animations” back into trunk [[BR]]
- Added DoxygenGUI project file [[BR]]

  • Buggy *
171 Diff Diff k1ngp1n picture k1ngp1n Sun 03 Nov, 2013 18:15:06 +0000

-Replaced all tabs with spaces [[BR]]

170 k1ngp1n picture k1ngp1n Sun 03 Nov, 2013 17:24:57 +0000

-Moved hardware related code to a separate project [[BR]]
-More work on post-processing: [[BR]]
— HDR rendering is working, but final tonemapping needs more work [[BR]]
-Important changes in BloomPreRenderOperator.cpp, PostFX.cpp and glFrameBufferObject.cpp [[BR]]
-Trailing and leading whitespace cleanups [[BR]]