1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2016 Leszek Koltunski leszek@koltunski.pl //
|
3
|
// //
|
4
|
// This file is part of Distorted. //
|
5
|
// //
|
6
|
// This library is free software; you can redistribute it and/or //
|
7
|
// modify it under the terms of the GNU Lesser General Public //
|
8
|
// License as published by the Free Software Foundation; either //
|
9
|
// version 2.1 of the License, or (at your option) any later version. //
|
10
|
// //
|
11
|
// This library 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 GNU //
|
14
|
// Lesser General Public License for more details. //
|
15
|
// //
|
16
|
// You should have received a copy of the GNU Lesser General Public //
|
17
|
// License along with this library; if not, write to the Free Software //
|
18
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA //
|
19
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
20
|
|
21
|
package org.distorted.library.main;
|
22
|
|
23
|
import android.opengl.GLES30;
|
24
|
|
25
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
26
|
// common parent class of Texture & OutputSurface; so that we can store either in Nodes.
|
27
|
|
28
|
abstract class InternalSurface extends InternalObject
|
29
|
{
|
30
|
int mColorCreated;
|
31
|
int mNumColors;
|
32
|
int mNumFBOs;
|
33
|
int[] mColorH;
|
34
|
|
35
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
36
|
|
37
|
InternalSurface(int create, int numfbos, int numcolors, int type, int storage)
|
38
|
{
|
39
|
super(type,storage);
|
40
|
|
41
|
mNumFBOs = numfbos;
|
42
|
mNumColors = numcolors;
|
43
|
mColorCreated = create;
|
44
|
|
45
|
allocateColor();
|
46
|
}
|
47
|
|
48
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
49
|
|
50
|
void allocateColor()
|
51
|
{
|
52
|
int total = mNumFBOs*mNumColors;
|
53
|
|
54
|
if( total>0 )
|
55
|
{
|
56
|
mColorH = new int[total];
|
57
|
for( int i=0; i<total; i++ ) mColorH[i] = 0;
|
58
|
}
|
59
|
}
|
60
|
|
61
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
62
|
// debugging only
|
63
|
|
64
|
String printDetails()
|
65
|
{
|
66
|
return getClass().getSimpleName();
|
67
|
}
|
68
|
|
69
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
70
|
|
71
|
boolean setAsInput()
|
72
|
{
|
73
|
if( mColorH[0]>0 )
|
74
|
{
|
75
|
GLES30.glActiveTexture(GLES30.GL_TEXTURE0);
|
76
|
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, mColorH[0]);
|
77
|
return true;
|
78
|
}
|
79
|
|
80
|
return false;
|
81
|
}
|
82
|
}
|