-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
582c0b7
commit a775a21
Showing
6 changed files
with
226 additions
and
94 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
vrlib/src/main/java/com/martin/ads/vrlib/filters/base/FBO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package com.martin.ads.vrlib.filters.base; | ||
|
||
import android.opengl.GLES20; | ||
|
||
public class FBO { | ||
private int frameBuffer; | ||
private int frameBufferTexture; | ||
|
||
private FBO(){} | ||
|
||
public static FBO newInstance(){ | ||
return new FBO(); | ||
} | ||
|
||
public FBO create(int width,int height){ | ||
int[] frameBuffers = new int[1]; | ||
int[] frameBufferTextures = new int[1]; | ||
GLES20.glGenFramebuffers(1, frameBuffers, 0); | ||
|
||
GLES20.glGenTextures(1, frameBufferTextures, 0); | ||
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, frameBufferTextures[0]); | ||
GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, | ||
width,height, 0, | ||
GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null); | ||
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, | ||
GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR); | ||
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, | ||
GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR); | ||
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, | ||
GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); | ||
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, | ||
GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); | ||
|
||
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, frameBuffers[0]); | ||
GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, | ||
GLES20.GL_TEXTURE_2D, frameBufferTextures[0], 0); | ||
|
||
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); | ||
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0); | ||
|
||
frameBuffer=frameBuffers[0]; | ||
frameBufferTexture=frameBufferTextures[0]; | ||
return this; | ||
} | ||
|
||
public void destroy(){ | ||
GLES20.glDeleteTextures(1, new int[]{frameBufferTexture}, 0); | ||
GLES20.glDeleteFramebuffers(1, new int[]{frameBuffer}, 0); | ||
} | ||
|
||
public void bind(){ | ||
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, frameBuffer); | ||
} | ||
|
||
public void unbind(){ | ||
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0); | ||
} | ||
|
||
public int getFrameBufferTextureId() { | ||
return frameBufferTexture; | ||
} | ||
|
||
public int getFrameBuffer() { | ||
return frameBuffer; | ||
} | ||
} |
Oops, something went wrong.