forked from OpenMW/openmw
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmyguitexture.hpp
78 lines (57 loc) · 2.29 KB
/
myguitexture.hpp
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
#ifndef OPENMW_COMPONENTS_MYGUIPLATFORM_MYGUITEXTURE_H
#define OPENMW_COMPONENTS_MYGUIPLATFORM_MYGUITEXTURE_H
#include <MyGUI_ITexture.h>
#include <osg/ref_ptr>
#if MYGUI_VERSION > MYGUI_DEFINE_VERSION(3, 4, 0)
#define OPENMW_MYGUI_CONST_GETTER_3_4_1 const
#else
#define OPENMW_MYGUI_CONST_GETTER_3_4_1
#endif
namespace osg
{
class Image;
class Texture2D;
}
namespace Resource
{
class ImageManager;
}
namespace osgMyGUI
{
class OSGTexture : public MyGUI::ITexture {
std::string mName;
Resource::ImageManager* mImageManager;
osg::ref_ptr<osg::Image> mLockedImage;
osg::ref_ptr<osg::Texture2D> mTexture;
MyGUI::PixelFormat mFormat;
MyGUI::TextureUsage mUsage;
size_t mNumElemBytes;
int mWidth;
int mHeight;
public:
OSGTexture(const std::string &name, Resource::ImageManager* imageManager);
OSGTexture(osg::Texture2D* texture);
virtual ~OSGTexture();
const std::string& getName() const override { return mName; }
void createManual(int width, int height, MyGUI::TextureUsage usage, MyGUI::PixelFormat format) override;
void loadFromFile(const std::string &fname) override;
void saveToFile(const std::string &fname) override;
void destroy() override;
void* lock(MyGUI::TextureUsage access) override;
void unlock() override;
bool isLocked() OPENMW_MYGUI_CONST_GETTER_3_4_1 override { return mLockedImage.valid(); }
int getWidth() OPENMW_MYGUI_CONST_GETTER_3_4_1 override { return mWidth; }
int getHeight() OPENMW_MYGUI_CONST_GETTER_3_4_1 override { return mHeight; }
MyGUI::PixelFormat getFormat() OPENMW_MYGUI_CONST_GETTER_3_4_1 override { return mFormat; }
MyGUI::TextureUsage getUsage() OPENMW_MYGUI_CONST_GETTER_3_4_1 override { return mUsage; }
size_t getNumElemBytes() OPENMW_MYGUI_CONST_GETTER_3_4_1 override { return mNumElemBytes; }
MyGUI::IRenderTarget *getRenderTarget() override;
// setShader() is a part of MyGUI::RenderManager interface since 3.4.1 release
#if MYGUI_VERSION > MYGUI_DEFINE_VERSION(3, 4, 0)
void setShader(const std::string& _shaderName) override;
#endif
/*internal:*/
osg::Texture2D *getTexture() const { return mTexture.get(); }
};
}
#endif