1 |
133cbb2b
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
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 |
|
|
package org.distorted.library;
|
21 |
|
|
|
22 |
|
|
import android.opengl.GLES30;
|
23 |
|
|
|
24 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
25 |
|
|
|
26 |
|
|
abstract class DistortedRenderable
|
27 |
|
|
{
|
28 |
|
|
static final int FAILED_TO_CREATE = -1;
|
29 |
|
|
static final int NOT_CREATED_YET = -2;
|
30 |
|
|
static final int DONT_CREATE = -3;
|
31 |
|
|
|
32 |
|
|
int[] mColorH = new int[1];
|
33 |
|
|
int mSizeX, mSizeY; // in screen space
|
34 |
|
|
|
35 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
36 |
|
|
|
37 |
|
|
long getID()
|
38 |
|
|
{
|
39 |
|
|
return mColorH[0];
|
40 |
|
|
}
|
41 |
|
|
|
42 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
43 |
|
|
|
44 |
|
|
boolean setAsInput()
|
45 |
|
|
{
|
46 |
|
|
if( mColorH[0]>0 )
|
47 |
|
|
{
|
48 |
|
|
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, mColorH[0]);
|
49 |
|
|
return true;
|
50 |
|
|
}
|
51 |
|
|
|
52 |
|
|
return false;
|
53 |
|
|
}
|
54 |
|
|
|
55 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
56 |
|
|
// PUBLIC API
|
57 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
58 |
|
|
/**
|
59 |
|
|
* Returns the height of the Renderable.
|
60 |
|
|
*
|
61 |
|
|
* @return height of the object, in pixels.
|
62 |
|
|
*/
|
63 |
|
|
public int getWidth()
|
64 |
|
|
{
|
65 |
|
|
return mSizeX;
|
66 |
|
|
}
|
67 |
|
|
|
68 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
69 |
|
|
/**
|
70 |
|
|
* Returns the width of the Renderable.
|
71 |
|
|
*
|
72 |
|
|
* @return width of the Object, in pixels.
|
73 |
|
|
*/
|
74 |
|
|
public int getHeight()
|
75 |
|
|
{
|
76 |
|
|
return mSizeY;
|
77 |
|
|
}
|
78 |
|
|
|
79 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
80 |
|
|
/**
|
81 |
|
|
* Returns the depth of the Renderable.
|
82 |
|
|
* <p>
|
83 |
|
|
* Admittedly quite a strange method. Why do we need to pass a Mesh to it? Because one cannot determine
|
84 |
|
|
* 'depth' of a Renderable (bitmap really!) when rendered based only on the texture itself, that depends
|
85 |
|
|
* on the Mesh it is rendered with.
|
86 |
|
|
*
|
87 |
|
|
* @return depth of the Object, in pixels.
|
88 |
|
|
*/
|
89 |
|
|
public int getDepth(MeshObject mesh)
|
90 |
|
|
{
|
91 |
|
|
return mesh==null ? 0 : (int)(mSizeX*mesh.zFactor);
|
92 |
|
|
}
|
93 |
|
|
}
|