Project

General

Profile

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

library / src / main / java / org / distorted / library / main / InternalSurface.java @ d58b50e7

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.GLES31;
23

    
24
///////////////////////////////////////////////////////////////////////////////////////////////////
25

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

    
33
///////////////////////////////////////////////////////////////////////////////////////////////////
34

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

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

    
43
    int total = mNumFBOs*mNumColors;
44

    
45
    if( total>0 )
46
      {
47
      mColorH = new int[total];
48
      for( int i=0; i<total; i++ )  mColorH[i] = 0;
49
      }
50
    }
51

    
52
///////////////////////////////////////////////////////////////////////////////////////////////////
53
// debugging only
54

    
55
  String printDetails()
56
    {
57
    return getClass().getSimpleName();
58
    }
59

    
60
///////////////////////////////////////////////////////////////////////////////////////////////////
61
// PUBLIC API
62
///////////////////////////////////////////////////////////////////////////////////////////////////
63
/**
64
 * Bind the underlying rectangle of pixels as a OpenGL Texture.
65
 *
66
 * @return <code>true</code> if successful.
67
 */
68
  public boolean setAsInput()
69
    {
70
    if( mColorH[0]>0 )
71
      {
72
      GLES31.glActiveTexture(GLES31.GL_TEXTURE0);
73
      GLES31.glBindTexture(GLES31.GL_TEXTURE_2D, mColorH[0]);
74
      return true;
75
      }
76

    
77
    return false;
78
    }
79
}
(14-14/14)