My Project
Client
trunk
ParaEngineClient
renderer
OpenGL
GLImage.h
1
#pragma once
2
#include "GLType.h"
3
#include "GLTexture2D.h"
4
5
namespace
ParaEngine
6
{
7
8
typedef
struct
_MipmapInfo
9
{
10
unsigned
char
* address;
11
int
len;
12
_MipmapInfo
() :address(NULL), len(0) {}
13
}
MipmapInfo
;
14
15
16
class
Image
:
public
CRefCountedOne
17
{
18
public
:
19
20
Image
();
21
22
// config
23
static
bool
supportsS3TC;
24
static
bool
PNG_PREMULTIPLIED_ALPHA_ENABLED;
25
static
int
MaxTextureSize;
26
27
public
:
29
enum class
Format
30
{
32
JPG,
34
PNG,
36
TIFF,
38
WEBP,
40
PVR,
42
ETC,
44
S3TC,
46
ATITC,
48
TGA,
50
RAW_DATA,
52
UNKNOWN
53
};
54
55
public
:
56
57
bool
initWithImageData(
const
unsigned
char
* data,
size_t
dataLen);
58
bool
initWithRawData(
const
unsigned
char
* data,
size_t
dataLen,
int
width,
int
height,
int
bitsPerComponent,
bool
preMulti =
false
);
59
bool
saveToFile(
const
std::string &filename,
bool
isToRGB =
true
);
60
61
62
float
getWidth() {
return
_width; }
63
float
getHeight() {
return
_height; }
64
65
Texture2D::PixelFormat
getRenderFormat() {
return
_renderFormat; }
66
67
int
getNumberOfMipmaps() {
return
_numberOfMipmaps; }
68
69
70
const
char
* getFilePath()
const
{
return
""
; }
71
unsigned
char
* getData()
const
{
return
_data; }
72
int
getDataLen()
const
{
return
_dataLen; }
73
MipmapInfo
* getMipmaps() {
return
_mipmaps; }
74
bool
isCompressed()
const
{
return
false
; }
75
bool
hasPremultipliedAlpha()
const
{
return
Texture2D::getPixelFormatInfoMap().at(_renderFormat).compressed; }
76
77
protected
:
78
static
const
int
MIPMAP_MAX = 16;
79
80
Texture2D::PixelFormat
_renderFormat;
81
82
float
_width;
83
float
_height;
84
85
bool
_hasPremultipliedAlpha;
86
int
_dataLen;
87
unsigned
char
* _data;
88
89
Format
_fileType;
90
91
int
_numberOfMipmaps;
92
MipmapInfo
_mipmaps[MIPMAP_MAX];
// pointer to mipmap images
93
94
95
96
bool
isPng(
const
unsigned
char
* data,
size_t
dataLen);
97
bool
isEtc(
const
unsigned
char
* data,
size_t
dataLen);
98
bool
isS3TC(
const
unsigned
char
* data,
size_t
dataLen);
99
bool
isATITC(
const
unsigned
char
*data,
size_t
dataLen);
100
bool
isJpg(
const
unsigned
char
* data,
size_t
dataLen);
101
bool
isTiff(
const
unsigned
char
* data,
size_t
dataLen);
102
bool
isWebp(
const
unsigned
char
* data,
size_t
dataLen);
103
bool
isPvr(
const
unsigned
char
* data,
size_t
dataLen);
104
Format
detectFormat(
const
unsigned
char
*,
size_t
unpackedLen);
105
106
bool
initWithJpgData(
const
unsigned
char
* unpackedData,
size_t
unpackedLen);
107
bool
initWithPngData(
const
unsigned
char
* unpackedData,
size_t
unpackedLen);
108
bool
initWithS3TCData(
const
unsigned
char
* unpackedData,
size_t
unpackedLen);
109
110
111
void
premultipliedAlpha();
112
113
114
};
115
}
ParaEngine::Image
Definition:
GLImage.h:16
ParaEngine::CRefCountedOne
Base class for a reference counted asset.
Definition:
PERef.h:55
ParaEngine
different physics engine has different winding order.
Definition:
EventBinding.h:32
ParaEngine::Texture2D::PixelFormat
PixelFormat
Definition:
GLTexture2D.h:15
ParaEngine::Image::Format
Format
Supported formats for Image.
Definition:
GLImage.h:29
ParaEngine::_MipmapInfo
Definition:
GLImage.h:8
Generated by
1.8.12