Project

General

Profile

Download (3.24 KB) Statistics
| Branch: | Revision:

library / src / main / java / org / distorted / library / main / InternalSurface.java @ 5f35f1cb

1 c5369f1b leszek
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2016 Leszek Koltunski                                                               //
3
//                                                                                               //
4 46b572b5 Leszek Koltunski
// This file is part of Distorted.                                                               //
5 c5369f1b leszek
//                                                                                               //
6 46b572b5 Leszek Koltunski
// Distorted is free software: you can redistribute it and/or modify                             //
7 c5369f1b leszek
// 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 46b572b5 Leszek Koltunski
// Distorted is distributed in the hope that it will be useful,                                  //
12 c5369f1b leszek
// 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 46b572b5 Leszek Koltunski
// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
18 c5369f1b leszek
///////////////////////////////////////////////////////////////////////////////////////////////////
19
20 fe82a979 Leszek Koltunski
package org.distorted.library.main;
21 c5369f1b leszek
22 b7074bc6 Leszek Koltunski
import android.opengl.GLES30;
23 af4cc5db Leszek Koltunski
24 12f9e4bb Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
25 9c198dba Leszek Koltunski
// common parent class of Texture & OutputSurface; so that we can store either in Nodes.
26 4bb94a7d Leszek Koltunski
27
abstract class InternalSurface extends InternalObject
28 226144d0 leszek
{
29 c7da4e65 leszek
  int mColorCreated;
30 9ed80185 Leszek Koltunski
  int mNumColors;
31 9d845904 Leszek Koltunski
  int mNumFBOs;
32 9ed80185 Leszek Koltunski
  int[] mColorH;
33 af4cc5db Leszek Koltunski
34 af27df87 leszek
///////////////////////////////////////////////////////////////////////////////////////////////////
35
36 d58b50e7 Leszek Koltunski
  InternalSurface(int create, int numfbos, int numcolors, int type)
37 af4cc5db Leszek Koltunski
    {
38 ccd98f1c Leszek Koltunski
    super(type);
39
40 9d845904 Leszek Koltunski
    mNumFBOs      = numfbos;
41 9ed80185 Leszek Koltunski
    mNumColors    = numcolors;
42 c7da4e65 leszek
    mColorCreated = create;
43 9ed80185 Leszek Koltunski
44 5f35f1cb Leszek Koltunski
    allocateColor();
45
    }
46
47
///////////////////////////////////////////////////////////////////////////////////////////////////
48
49
  void allocateColor()
50
    {
51 9d845904 Leszek Koltunski
    int total = mNumFBOs*mNumColors;
52
53
    if( total>0 )
54 9ed80185 Leszek Koltunski
      {
55 9d845904 Leszek Koltunski
      mColorH = new int[total];
56
      for( int i=0; i<total; i++ )  mColorH[i] = 0;
57 9ed80185 Leszek Koltunski
      }
58 af4cc5db Leszek Koltunski
    }
59
60 f28fffc2 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
61 226144d0 leszek
// debugging only
62 f28fffc2 Leszek Koltunski
63 226144d0 leszek
  String printDetails()
64 f28fffc2 Leszek Koltunski
    {
65 d58b50e7 Leszek Koltunski
    return getClass().getSimpleName();
66 f28fffc2 Leszek Koltunski
    }
67
68 af4cc5db Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
69 9c198dba Leszek Koltunski
70
  boolean setAsInput()
71 12f9e4bb Leszek Koltunski
    {
72
    if( mColorH[0]>0 )
73
      {
74 b7074bc6 Leszek Koltunski
      GLES30.glActiveTexture(GLES30.GL_TEXTURE0);
75
      GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, mColorH[0]);
76 12f9e4bb Leszek Koltunski
      return true;
77
      }
78
79
    return false;
80
    }
81 226144d0 leszek
}