author | David Caabeiro <david.caabeiro@seqpoint.com> |
Fri, 25 Jun 2010 12:50:05 +0200 | |
changeset 0 | c316ab048e9d |
permissions | -rw-r--r-- |
0
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
1 |
/* |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
2 |
* Name : Object.cpp |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
3 |
* Description : |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
4 |
* Project : This file is part of OpenMAR, an Open Mobile Augmented Reality browser |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
5 |
* Website : http://OpenMAR.org |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
6 |
* |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
7 |
* Copyright (c) 2010 David Caabeiro |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
8 |
* |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
9 |
* All rights reserved. This program and the accompanying materials are made available |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
10 |
* under the terms of the Eclipse Public License v1.0 which accompanies this |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
11 |
* distribution, and is available at http://www.eclipse.org/legal/epl-v10.html |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
12 |
* |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
13 |
*/ |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
14 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
15 |
#include "Object.h" |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
16 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
17 |
#include "IconLoader.h" |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
18 |
#include "Vector3d.h" |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
19 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
20 |
#include <bitdev.h> |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
21 |
#include <bitstd.h> |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
22 |
#include <fbs.h> |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
23 |
#include <GulIcon.h> |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
24 |
#include <GLES/egl.h> |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
25 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
26 |
#include <Landmarks_0x2002E1AF.mbg> |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
27 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
28 |
#include "Logger.h" |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
29 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
30 |
CLMXObject* CLMXObject::NewL(OpenMAR::CPOIProvider* aProvider) |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
31 |
{ |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
32 |
CLMXObject* self = new(ELeave) CLMXObject(aProvider); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
33 |
CleanupStack::PushL(self); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
34 |
self->ConstructL(); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
35 |
CleanupStack::Pop(self); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
36 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
37 |
return self; |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
38 |
} |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
39 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
40 |
CLMXObject::~CLMXObject() |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
41 |
{ |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
42 |
::glDeleteTextures(1, &iTextureId); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
43 |
} |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
44 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
45 |
CLMXObject::CLMXObject(OpenMAR::CPOIProvider* aProvider) |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
46 |
: OpenMAR::CPOIObject(*aProvider) |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
47 |
{} |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
48 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
49 |
/* |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
50 |
* Landmark objects will make use of an SVG file for rendering (demo purposes) |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
51 |
*/ |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
52 |
void CLMXObject::ConstructL() |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
53 |
{ |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
54 |
_LIT(KIconFile, "\\resource\\apps\\Landmarks_0x2002E1AF.mif"); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
55 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
56 |
CGulIcon* icon = CreateIconL(KIconFile, EMbmLandmarks_0x2002e1afIcon, EMbmLandmarks_0x2002e1afIcon_mask); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
57 |
CleanupStack::PushL(icon); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
58 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
59 |
CFbsBitmap* bitmap = icon->Bitmap(); // Ownership NOT transferred |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
60 |
CFbsBitmap* mask = icon->Mask(); // Ownership NOT transferred |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
61 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
62 |
// Always expect 16M bitmap to make conversion to GL_RGBA easier |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
63 |
if (bitmap->DisplayMode() != EColor16M) |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
64 |
{ |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
65 |
bitmap = new(ELeave) CFbsBitmap; |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
66 |
CleanupStack::PushL(bitmap); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
67 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
68 |
User::LeaveIfError(bitmap->Create(icon->Bitmap()->SizeInPixels(), EColor16M)); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
69 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
70 |
CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(bitmap); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
71 |
CleanupStack::PushL(bitmapDevice); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
72 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
73 |
CFbsBitGc* bitmapContext = 0; |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
74 |
User::LeaveIfError(bitmapDevice->CreateContext(bitmapContext)); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
75 |
CleanupStack::PushL(bitmapContext); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
76 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
77 |
bitmapContext->BitBlt(TPoint(0, 0), icon->Bitmap()); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
78 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
79 |
CleanupStack::PopAndDestroy(2, bitmapDevice); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
80 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
81 |
icon->SetBitmap(bitmap); // Ownership transferred |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
82 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
83 |
CleanupStack::Pop(bitmap); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
84 |
} |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
85 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
86 |
// Always expect 256 mask to make conversion to GL_RGBA easier |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
87 |
if (mask->DisplayMode() != EGray256) |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
88 |
{ |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
89 |
mask = new(ELeave) CFbsBitmap; |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
90 |
CleanupStack::PushL(mask); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
91 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
92 |
User::LeaveIfError(mask->Create(icon->Mask()->SizeInPixels(), EGray256)); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
93 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
94 |
CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(mask); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
95 |
CleanupStack::PushL(bitmapDevice); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
96 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
97 |
CFbsBitGc* bitmapContext = 0; |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
98 |
User::LeaveIfError(bitmapDevice->CreateContext(bitmapContext)); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
99 |
CleanupStack::PushL(bitmapContext); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
100 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
101 |
bitmapContext->BitBlt(TPoint(0, 0), icon->Mask()); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
102 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
103 |
CleanupStack::PopAndDestroy(2, bitmapDevice); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
104 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
105 |
icon->SetMask(mask); // Ownership transferred |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
106 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
107 |
CleanupStack::Pop(mask); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
108 |
} |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
109 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
110 |
// Now bitmap and mask point to either original or converted bitmaps, |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
111 |
// and ownership belongs to icon |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
112 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
113 |
const TSize bitmapSize = bitmap->SizeInPixels(); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
114 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
115 |
// sizeof(TUint32) == sizeof(RGBA) |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
116 |
const TInt dataSize = bitmapSize.iWidth * bitmapSize.iHeight * sizeof(TUint32); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
117 |
TUint8* data = new(ELeave) TUint8[dataSize]; |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
118 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
119 |
// Perform copy and conversion from BGR(A) to RGB(A) |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
120 |
bitmap->LockHeap(); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
121 |
mask->LockHeap(); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
122 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
123 |
// TODO: Alpha component removed, as it seems to be corrupted from |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
124 |
// subsequent reads from SVG file |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
125 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
126 |
TUint8* rgb = reinterpret_cast<TUint8*>(bitmap->DataAddress()); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
127 |
// TUint8* alpha = reinterpret_cast<TUint8*>(mask->DataAddress()); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
128 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
129 |
for(TInt i = 0, j = 0; i < dataSize; i += 4, j += 3) |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
130 |
{ |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
131 |
data[i + 0] = rgb[j + 2]; |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
132 |
data[i + 1] = rgb[j + 1]; |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
133 |
data[i + 2] = rgb[j + 0]; |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
134 |
data[i + 3] = 0xc0; //alpha[i / 4]; |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
135 |
} |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
136 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
137 |
// Generate OpenGL texture |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
138 |
::glGenTextures(1, &iTextureId); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
139 |
::glBindTexture(GL_TEXTURE_2D, iTextureId); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
140 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
141 |
::glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
142 |
::glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
143 |
::glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
144 |
::glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
145 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
146 |
::glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, bitmapSize.iWidth, bitmapSize.iHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
147 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
148 |
mask->UnlockHeap(); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
149 |
bitmap->UnlockHeap(); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
150 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
151 |
delete data; |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
152 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
153 |
CleanupStack::PopAndDestroy(icon); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
154 |
} |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
155 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
156 |
void CLMXObject::Render() const |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
157 |
{ |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
158 |
/* |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
159 |
* This is a special case for points or planes in space. Given that a usual POI |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
160 |
* does not provide of any transformation to be applied on it, we determine the |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
161 |
* angle in the XY plane with respect to the observer and apply that rotation to |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
162 |
* the object. |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
163 |
* |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
164 |
* This way, all POIs will face the observer regardless their position. Other |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
165 |
* objects (3D Landmarks, etc) should provide their own transformations in some |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
166 |
* proper way. |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
167 |
*/ |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
168 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
169 |
TReal angle = 0; |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
170 |
Math::ATan(angle, iPosition.mX, iPosition.mY); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
171 |
angle *= -KRadToDeg; |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
172 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
173 |
/* |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
174 |
* We could also apply some scaling calculation to compensate the size of |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
175 |
* objects projected at a long distance from the camera. |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
176 |
* For now we just use a constant value |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
177 |
*/ |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
178 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
179 |
TReal scale = 64.0f; |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
180 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
181 |
// Apply transformations to the object and render it |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
182 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
183 |
const TInt unity = 1 << 16; |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
184 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
185 |
GLfixed vertices[] = { |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
186 |
-unity / 2, 0, 0, |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
187 |
unity / 2, 0, 0, |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
188 |
-unity / 2, 0, unity, |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
189 |
unity / 2, 0, unity, |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
190 |
}; |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
191 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
192 |
GLfixed texCoords[] = { |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
193 |
0, unity, |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
194 |
unity, unity, |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
195 |
0, 0, |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
196 |
unity, 0 |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
197 |
}; |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
198 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
199 |
::glPushMatrix(); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
200 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
201 |
::glTranslatef(iPosition.mX, iPosition.mY, iPosition.mZ); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
202 |
::glRotatef(angle, 0, 0, 1); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
203 |
::glScalef(scale, 1.0f, scale); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
204 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
205 |
::glEnable(GL_TEXTURE_2D); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
206 |
::glBindTexture(GL_TEXTURE_2D, iTextureId); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
207 |
::glVertexPointer(3, GL_FIXED, 0, vertices); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
208 |
::glTexCoordPointer(2, GL_FIXED, 0, texCoords); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
209 |
::glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
210 |
::glDisable(GL_TEXTURE_2D); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
211 |
|
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
212 |
::glPopMatrix(); |
c316ab048e9d
First public commit
David Caabeiro <david.caabeiro@seqpoint.com>
parents:
diff
changeset
|
213 |
} |