1 |
c5369f1b
|
leszek
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
// Copyright 2016 Leszek Koltunski //
|
3 |
|
|
// //
|
4 |
|
|
// This file is part of Distorted. //
|
5 |
|
|
// //
|
6 |
|
|
// Distorted is free software: you can redistribute it and/or modify //
|
7 |
|
|
// it under the terms of the GNU General Public License as published by //
|
8 |
|
|
// the Free Software Foundation, either version 2 of the License, or //
|
9 |
|
|
// (at your option) any later version. //
|
10 |
|
|
// //
|
11 |
|
|
// Distorted is distributed in the hope that it will be useful, //
|
12 |
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
13 |
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
14 |
|
|
// GNU General Public License for more details. //
|
15 |
|
|
// //
|
16 |
|
|
// You should have received a copy of the GNU General Public License //
|
17 |
|
|
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. //
|
18 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
19 |
|
|
|
20 |
fe82a979
|
Leszek Koltunski
|
package org.distorted.library.main;
|
21 |
c5369f1b
|
leszek
|
|
22 |
af4cc5db
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
23 |
|
|
|
24 |
226144d0
|
leszek
|
abstract class DistortedSurface extends DistortedObject
|
25 |
|
|
{
|
26 |
c7da4e65
|
leszek
|
int mColorCreated;
|
27 |
9ed80185
|
Leszek Koltunski
|
int mNumColors;
|
28 |
9d845904
|
Leszek Koltunski
|
int mNumFBOs;
|
29 |
9ed80185
|
Leszek Koltunski
|
int[] mColorH;
|
30 |
6e7c8721
|
Leszek Koltunski
|
int mWidth, mHeight;
|
31 |
af4cc5db
|
Leszek Koltunski
|
|
32 |
af27df87
|
leszek
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
33 |
|
|
|
34 |
9d845904
|
Leszek Koltunski
|
DistortedSurface(int width, int height, int create, int numfbos, int numcolors, int type)
|
35 |
af4cc5db
|
Leszek Koltunski
|
{
|
36 |
226144d0
|
leszek
|
super(create,type);
|
37 |
|
|
|
38 |
9d845904
|
Leszek Koltunski
|
mNumFBOs = numfbos;
|
39 |
9ed80185
|
Leszek Koltunski
|
mNumColors = numcolors;
|
40 |
6e7c8721
|
Leszek Koltunski
|
mWidth = width ;
|
41 |
|
|
mHeight = height;
|
42 |
c7da4e65
|
leszek
|
mColorCreated = create;
|
43 |
9ed80185
|
Leszek Koltunski
|
|
44 |
9d845904
|
Leszek Koltunski
|
int total = mNumFBOs*mNumColors;
|
45 |
|
|
|
46 |
|
|
if( total>0 )
|
47 |
9ed80185
|
Leszek Koltunski
|
{
|
48 |
9d845904
|
Leszek Koltunski
|
mColorH = new int[total];
|
49 |
|
|
for( int i=0; i<total; i++ ) mColorH[i] = 0;
|
50 |
9ed80185
|
Leszek Koltunski
|
}
|
51 |
af4cc5db
|
Leszek Koltunski
|
}
|
52 |
|
|
|
53 |
f28fffc2
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
54 |
226144d0
|
leszek
|
// debugging only
|
55 |
f28fffc2
|
Leszek Koltunski
|
|
56 |
226144d0
|
leszek
|
String printDetails()
|
57 |
f28fffc2
|
Leszek Koltunski
|
{
|
58 |
226144d0
|
leszek
|
return getClass().getSimpleName()+" "+mWidth+"x"+mHeight;
|
59 |
f28fffc2
|
Leszek Koltunski
|
}
|
60 |
|
|
|
61 |
af4cc5db
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
62 |
|
|
// PUBLIC API
|
63 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
64 |
c5369f1b
|
leszek
|
/**
|
65 |
3a70bd6d
|
leszek
|
* Return the width of this Surface.
|
66 |
af4cc5db
|
Leszek Koltunski
|
*
|
67 |
3a70bd6d
|
leszek
|
* @return width of the Object, in pixels.
|
68 |
c5369f1b
|
leszek
|
*/
|
69 |
af4cc5db
|
Leszek Koltunski
|
public int getWidth()
|
70 |
|
|
{
|
71 |
6e7c8721
|
Leszek Koltunski
|
return mWidth;
|
72 |
af4cc5db
|
Leszek Koltunski
|
}
|
73 |
|
|
|
74 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
75 |
c5369f1b
|
leszek
|
/**
|
76 |
3a70bd6d
|
leszek
|
* Return the height of this Surface.
|
77 |
af4cc5db
|
Leszek Koltunski
|
*
|
78 |
3a70bd6d
|
leszek
|
* @return height of the Object, in pixels.
|
79 |
c5369f1b
|
leszek
|
*/
|
80 |
af4cc5db
|
Leszek Koltunski
|
public int getHeight()
|
81 |
|
|
{
|
82 |
6e7c8721
|
Leszek Koltunski
|
return mHeight;
|
83 |
af4cc5db
|
Leszek Koltunski
|
}
|
84 |
|
|
|
85 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
86 |
c5369f1b
|
leszek
|
/**
|
87 |
8d52a49c
|
Leszek Koltunski
|
* Return the depth of this Surface.
|
88 |
af4cc5db
|
Leszek Koltunski
|
* <p>
|
89 |
|
|
* Admittedly quite a strange method. Why do we need to pass a Mesh to it? Because one cannot determine
|
90 |
|
|
* 'depth' of a Surface (bitmap really!) when rendered based only on the texture itself, that depends
|
91 |
|
|
* on the Mesh it is rendered with.
|
92 |
|
|
*
|
93 |
|
|
* @return depth of the Object, in pixels.
|
94 |
c5369f1b
|
leszek
|
*/
|
95 |
af4cc5db
|
Leszek Koltunski
|
public int getDepth(MeshObject mesh)
|
96 |
|
|
{
|
97 |
6e7c8721
|
Leszek Koltunski
|
return mesh==null ? 0 : (int)(mWidth*mesh.zFactor);
|
98 |
af4cc5db
|
Leszek Koltunski
|
}
|
99 |
226144d0
|
leszek
|
}
|