Project

General

Profile

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

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

1
///////////////////////////////////////////////////////////////////////////////////////////////////
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.main;
21

    
22
import android.opengl.GLES30;
23

    
24
///////////////////////////////////////////////////////////////////////////////////////////////////
25
// common parent class of Texture & OutputSurface; so that we can store either in Nodes.
26

    
27
abstract class InternalSurface extends InternalObject
28
{
29
  int mColorCreated;
30
  int mNumColors;
31
  int mNumFBOs;
32
  int[] mColorH;
33

    
34
///////////////////////////////////////////////////////////////////////////////////////////////////
35

    
36
  InternalSurface(int create, int numfbos, int numcolors, int type)
37
    {
38
    super(type);
39

    
40
    mNumFBOs      = numfbos;
41
    mNumColors    = numcolors;
42
    mColorCreated = create;
43

    
44
    allocateColor();
45
    }
46

    
47
///////////////////////////////////////////////////////////////////////////////////////////////////
48

    
49
  void allocateColor()
50
    {
51
    int total = mNumFBOs*mNumColors;
52

    
53
    if( total>0 )
54
      {
55
      mColorH = new int[total];
56
      for( int i=0; i<total; i++ )  mColorH[i] = 0;
57
      }
58
    }
59

    
60
///////////////////////////////////////////////////////////////////////////////////////////////////
61
// debugging only
62

    
63
  String printDetails()
64
    {
65
    return getClass().getSimpleName();
66
    }
67

    
68
///////////////////////////////////////////////////////////////////////////////////////////////////
69

    
70
  boolean setAsInput()
71
    {
72
    if( mColorH[0]>0 )
73
      {
74
      GLES30.glActiveTexture(GLES30.GL_TEXTURE0);
75
      GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, mColorH[0]);
76
      return true;
77
      }
78

    
79
    return false;
80
    }
81
}
(14-14/14)