Project

General

Profile

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

library / src / main / java / org / distorted / library / main / DistortedSurface.java @ 8ebbc730

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
///////////////////////////////////////////////////////////////////////////////////////////////////
23

    
24
abstract class DistortedSurface extends DistortedObject
25
{
26
  int mColorCreated;
27
  int mNumColors;
28
  int mNumFBOs;
29
  int[] mColorH;
30
  int mWidth, mHeight;
31

    
32
///////////////////////////////////////////////////////////////////////////////////////////////////
33

    
34
  DistortedSurface(int width, int height, int create, int numfbos, int numcolors, int type)
35
    {
36
    super(create,type);
37

    
38
    mNumFBOs      = numfbos;
39
    mNumColors    = numcolors;
40
    mWidth        = width ;
41
    mHeight       = height;
42
    mColorCreated = create;
43

    
44
    int total = mNumFBOs*mNumColors;
45

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

    
53
///////////////////////////////////////////////////////////////////////////////////////////////////
54
// debugging only
55

    
56
  String printDetails()
57
    {
58
    return getClass().getSimpleName()+" "+mWidth+"x"+mHeight;
59
    }
60

    
61
///////////////////////////////////////////////////////////////////////////////////////////////////
62
// PUBLIC API
63
///////////////////////////////////////////////////////////////////////////////////////////////////
64
/**
65
 * Return the width of this Surface.
66
 *
67
 * @return width of the Object, in pixels.
68
 */
69
  public int getWidth()
70
    {
71
    return mWidth;
72
    }
73

    
74
///////////////////////////////////////////////////////////////////////////////////////////////////
75
/**
76
 * Return the height of this Surface.
77
 *
78
 * @return height of the Object, in pixels.
79
 */
80
  public int getHeight()
81
    {
82
    return mHeight;
83
    }
84

    
85
///////////////////////////////////////////////////////////////////////////////////////////////////
86
/**
87
 * Return the depth of this Surface.
88
 * <p>
89
 * Admittedly quite a strange method. Why do we need to pass a Mesh to it? Because one cannot determine
90
 * 'depth' of a Surface (bitmap really!) when rendered based only on the texture itself, that depends
91
 * on the Mesh it is rendered with.
92
 *
93
 * @return depth of the Object, in pixels.
94
 */
95
  public int getDepth(MeshObject mesh)
96
    {
97
    return mesh==null ? 0 : (int)(mWidth*mesh.zFactor);
98
    }
99
}
(11-11/21)