-
Notifications
You must be signed in to change notification settings - Fork 1
/
texturereceiver.cpp
65 lines (60 loc) · 1.46 KB
/
texturereceiver.cpp
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
#include "texturereceiver.h"
TextureReceiver::TextureReceiver():
m_textureId(0),
m_textureSize(-1, -1),
m_orientation(0)
{
}
QMatrix4x4 TextureReceiver::getRotationImageMatrix(int orientation)
{
orientation = ((orientation / 90) % 4) * 90;
QMatrix4x4 rotation;
switch (orientation) {
case 90:
rotation(0, 0) = 0.0f;
rotation(0, 1) = -1.0f;
rotation(0, 3) = 1.0f;
rotation(1, 0) = 1.0f;
rotation(1, 1) = 0.0f;
rotation(1, 3) = 0.0f;
break;
case 180:
rotation(0, 0) = -1.0f;
rotation(0, 1) = 0.0f;
rotation(0, 3) = 1.0f;
rotation(1, 0) = 0.0f;
rotation(1, 1) = -1.0f;
rotation(1, 3) = 1.0f;
break;
case 270:
rotation(0, 0) = 0.0f;
rotation(0, 1) = 1.0f;
rotation(0, 3) = 0.0f;
rotation(1, 0) = -1.0f;
rotation(1, 1) = 0.0f;
rotation(1, 3) = 1.0f;
break;
}
return rotation;
}
GLuint TextureReceiver::textureId() const
{
return m_textureId;
}
QSize TextureReceiver::textureSize() const
{
return m_textureSize;
}
int TextureReceiver::orientation() const
{
return m_orientation;
}
void TextureReceiver::setTextureId(GLuint textureId, const QSize & textureSize, int orientation)
{
if (m_textureId == textureId)
return;
m_textureId = textureId;
m_textureSize = textureSize;
m_orientation = ((orientation / 90) % 4) * 90;
emit textureChanged();
}