1 |
c5369f1b
|
leszek
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
2e569ff6
|
Leszek Koltunski
|
// Copyright 2016 Leszek Koltunski leszek@koltunski.pl //
|
3 |
c5369f1b
|
leszek
|
// //
|
4 |
46b572b5
|
Leszek Koltunski
|
// This file is part of Distorted. //
|
5 |
c5369f1b
|
leszek
|
// //
|
6 |
2e569ff6
|
Leszek Koltunski
|
// 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 |
c5369f1b
|
leszek
|
// //
|
11 |
2e569ff6
|
Leszek Koltunski
|
// This library is distributed in the hope that it will be useful, //
|
12 |
c5369f1b
|
leszek
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
13 |
2e569ff6
|
Leszek Koltunski
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU //
|
14 |
|
|
// Lesser General Public License for more details. //
|
15 |
c5369f1b
|
leszek
|
// //
|
16 |
2e569ff6
|
Leszek Koltunski
|
// 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 |
c5369f1b
|
leszek
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
20 |
|
|
|
21 |
fe82a979
|
Leszek Koltunski
|
package org.distorted.library.main;
|
22 |
c5369f1b
|
leszek
|
|
23 |
b7074bc6
|
Leszek Koltunski
|
import android.opengl.GLES30;
|
24 |
af4cc5db
|
Leszek Koltunski
|
|
25 |
12f9e4bb
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
26 |
9c198dba
|
Leszek Koltunski
|
// common parent class of Texture & OutputSurface; so that we can store either in Nodes.
|
27 |
4bb94a7d
|
Leszek Koltunski
|
|
28 |
|
|
abstract class InternalSurface extends InternalObject
|
29 |
226144d0
|
leszek
|
{
|
30 |
c7da4e65
|
leszek
|
int mColorCreated;
|
31 |
9ed80185
|
Leszek Koltunski
|
int mNumColors;
|
32 |
9d845904
|
Leszek Koltunski
|
int mNumFBOs;
|
33 |
9ed80185
|
Leszek Koltunski
|
int[] mColorH;
|
34 |
af4cc5db
|
Leszek Koltunski
|
|
35 |
af27df87
|
leszek
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
36 |
|
|
|
37 |
9ec374e8
|
Leszek Koltunski
|
InternalSurface(int create, int numfbos, int numcolors, int type, int storage)
|
38 |
af4cc5db
|
Leszek Koltunski
|
{
|
39 |
9ec374e8
|
Leszek Koltunski
|
super(type,storage);
|
40 |
ccd98f1c
|
Leszek Koltunski
|
|
41 |
9d845904
|
Leszek Koltunski
|
mNumFBOs = numfbos;
|
42 |
9ed80185
|
Leszek Koltunski
|
mNumColors = numcolors;
|
43 |
c7da4e65
|
leszek
|
mColorCreated = create;
|
44 |
9ed80185
|
Leszek Koltunski
|
|
45 |
5f35f1cb
|
Leszek Koltunski
|
allocateColor();
|
46 |
|
|
}
|
47 |
|
|
|
48 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
49 |
|
|
|
50 |
|
|
void allocateColor()
|
51 |
|
|
{
|
52 |
9d845904
|
Leszek Koltunski
|
int total = mNumFBOs*mNumColors;
|
53 |
|
|
|
54 |
|
|
if( total>0 )
|
55 |
9ed80185
|
Leszek Koltunski
|
{
|
56 |
9d845904
|
Leszek Koltunski
|
mColorH = new int[total];
|
57 |
|
|
for( int i=0; i<total; i++ ) mColorH[i] = 0;
|
58 |
9ed80185
|
Leszek Koltunski
|
}
|
59 |
af4cc5db
|
Leszek Koltunski
|
}
|
60 |
|
|
|
61 |
f28fffc2
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
62 |
226144d0
|
leszek
|
// debugging only
|
63 |
f28fffc2
|
Leszek Koltunski
|
|
64 |
226144d0
|
leszek
|
String printDetails()
|
65 |
f28fffc2
|
Leszek Koltunski
|
{
|
66 |
d58b50e7
|
Leszek Koltunski
|
return getClass().getSimpleName();
|
67 |
f28fffc2
|
Leszek Koltunski
|
}
|
68 |
|
|
|
69 |
af4cc5db
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
70 |
9c198dba
|
Leszek Koltunski
|
|
71 |
|
|
boolean setAsInput()
|
72 |
12f9e4bb
|
Leszek Koltunski
|
{
|
73 |
|
|
if( mColorH[0]>0 )
|
74 |
|
|
{
|
75 |
b7074bc6
|
Leszek Koltunski
|
GLES30.glActiveTexture(GLES30.GL_TEXTURE0);
|
76 |
|
|
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, mColorH[0]);
|
77 |
12f9e4bb
|
Leszek Koltunski
|
return true;
|
78 |
|
|
}
|
79 |
|
|
|
80 |
|
|
return false;
|
81 |
|
|
}
|
82 |
226144d0
|
leszek
|
}
|