Project

General

Profile

« Previous | Next » 

Revision 64a642c1

Added by Leszek Koltunski almost 8 years ago

Cleanup

View differences:

src/main/java/org/distorted/library/DistortedFramebuffer.java
80 80

  
81 81
  private boolean createFBO()
82 82
    {
83
    int[] textureIds = new int[1];
84
    GLES20.glGenTextures(1, textureIds, 0);
85
    mTextureID = textureIds[0];
86
    int[] mFBORenderToTexture = new int[1];
83
    int[] texIds = new int[1];
84
    int[] fboIds = new int[1];
85

  
86
    GLES20.glGenTextures(1, texIds, 0);
87
    mTextureID = texIds[0];
87 88

  
88 89
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureID);
89 90
    GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST);
......
92 93
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_REPEAT);
93 94
    GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, mWidth, mHeight, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null);
94 95

  
95
    GLES20.glGenFramebuffers(1, mFBORenderToTexture, 0);
96
    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, mFBORenderToTexture[0]);
96
    GLES20.glGenFramebuffers(1, fboIds, 0);
97
    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, fboIds[0]);
97 98
    GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, mTextureID, 0);
98 99
    int status = GLES20.glCheckFramebufferStatus(GLES20.GL_FRAMEBUFFER);
99 100

  
100 101
    if(status != GLES20.GL_FRAMEBUFFER_COMPLETE)
101 102
      {
102
      android.util.Log.e("RenderTarget", "failed to create framebuffer, error="+status);
103
      android.util.Log.e("DistortedFramebuffer", "failed to create framebuffer, error="+status);
103 104

  
104
      GLES20.glDeleteTextures(1, textureIds, 0);
105
      GLES20.glDeleteFramebuffers(1, mFBORenderToTexture, 0);
105
      GLES20.glDeleteTextures(1, texIds, 0);
106
      GLES20.glDeleteFramebuffers(1, fboIds, 0);
106 107
      mFramebufferID = 0;
107 108
      mTextureID = TEXTURE_FAILED_TO_CREATE;
108 109
      return false;
109 110
      }
110 111

  
111
    mFramebufferID = mFBORenderToTexture[0];
112
    mFramebufferID = fboIds[0];
112 113

  
113 114
    android.util.Log.e("FBO", "creating ("+mWidth+","+mHeight+") "+mFramebufferID);
114 115

  
......
122 123
    {
123 124
    android.util.Log.e("FBO", "deleting ("+mWidth+","+mHeight+") "+mFramebufferID);
124 125

  
125
    int[] textureIds = new int[1];
126
    int[] mFBORenderToTexture = new int[1];
126
    int[] texIds = new int[1];
127
    int[] fboIds = new int[1];
127 128

  
128
    textureIds[0] = mTextureID;
129
    mFBORenderToTexture[0] = mFramebufferID;
129
    texIds[0] = mTextureID;
130
    fboIds[0] = mFramebufferID;
130 131

  
131
    GLES20.glDeleteTextures(1, textureIds, 0);
132
    GLES20.glDeleteFramebuffers(1, mFBORenderToTexture, 0);
132
    GLES20.glDeleteTextures(1, texIds, 0);
133
    GLES20.glDeleteFramebuffers(1, fboIds, 0);
133 134

  
134 135
    mFramebufferID = 0;
135 136
    mTextureID = TEXTURE_NOT_CREATED_YET;

Also available in: Unified diff