Skip to content

Commit 2dc6f26

Browse files
committed
fix RTE during framebuffers creation
Signed-off-by: Umair Khan <[email protected]>
1 parent 0bd0f9f commit 2dc6f26

File tree

2 files changed

+31
-40
lines changed

2 files changed

+31
-40
lines changed

src/in/omerjerk/processing/video/android/Capture.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public Capture(PApplet parent) {
3333
}
3434

3535
public Capture(final PApplet parent, int width, int height) {
36-
super(parent);
36+
super(parent, width, height);
3737

3838
activity.runOnUiThread(new Runnable() {
3939
@Override

src/in/omerjerk/processing/video/android/VideoBase.java

Lines changed: 30 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public static void log(String log) {
5050
public abstract void onResume();
5151
public abstract void onPause();
5252

53-
public VideoBase(PApplet parent) {
53+
public VideoBase(PApplet parent, int width, int height) {
5454
super();
5555
this.parent = parent;
5656
if (width == -1 || height == -1) {
@@ -91,67 +91,58 @@ protected void createSurfaceTexture() {
9191
}
9292

9393
protected void prepareFrameBuffers() {
94-
9594
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
96-
97-
// Generate frame buffer
95+
96+
//Generate frame buffer
9897
GLES20.glGenFramebuffers(1, frameBuffers);
9998
GlUtil.checkGlError("glGenFramebuffers");
100-
// Bind frame buffer
99+
//Bind frame buffer
101100
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, frameBuffers.get(0));
102101
GlUtil.checkGlError("glBindFramebuffer");
103-
104-
// Generate render buffers
102+
103+
//Generate render buffers
105104
GLES20.glGenRenderbuffers(1, renderBuffers);
106105
GlUtil.checkGlError("glGenRenderbuffers");
107-
// Bind render buffers
106+
//Bind render buffers
108107
GLES20.glBindRenderbuffer(GLES20.GL_RENDERBUFFER, renderBuffers.get(0));
109108
GlUtil.checkGlError("glBindRenderbuffer");
110-
// Allocate memory to render buffers
111-
GLES20.glRenderbufferStorage(GLES20.GL_RENDERBUFFER,
112-
GLES20.GL_DEPTH_COMPONENT16, width, height);
109+
//Allocate memory to render buffers
110+
GLES20.glRenderbufferStorage(GLES20.GL_RENDERBUFFER, GLES20.GL_DEPTH_COMPONENT16, width, height);
113111
GlUtil.checkGlError("glRenderbufferStorage");
114-
115-
// Attach render buffer to frame buffer
116-
GLES20.glFramebufferRenderbuffer(GLES20.GL_FRAMEBUFFER,
117-
GLES20.GL_DEPTH_ATTACHMENT, GLES20.GL_RENDERBUFFER,
118-
renderBuffers.get(0));
112+
113+
//Attach render buffer to frame buffer
114+
GLES20.glFramebufferRenderbuffer(GLES20.GL_FRAMEBUFFER, GLES20.GL_DEPTH_ATTACHMENT,
115+
GLES20.GL_RENDERBUFFER, renderBuffers.get(0));
119116
GlUtil.checkGlError("glFramebufferRenderbuffer");
120-
117+
121118
GLES20.glGenTextures(1, customTexture);
122119
GlUtil.checkGlError("glGenTextures");
123120

124121
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, customTexture.get(0));
125122
GlUtil.checkGlError("glBindTexture");
126-
127-
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,
128-
GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
129-
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,
130-
GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
131-
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S,
132-
GLES20.GL_CLAMP_TO_EDGE);
133-
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T,
134-
GLES20.GL_CLAMP_TO_EDGE);
135-
GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, width,
136-
height, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null);
123+
124+
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
125+
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
126+
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
127+
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
128+
GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, width, height, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null);
137129
GlUtil.checkGlError("glTexImage2D");
138130

139-
GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER,
140-
GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D,
141-
customTexture.get(0), 0);
131+
GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0,
132+
GLES20.GL_TEXTURE_2D, customTexture.get(0), 0);
142133
GlUtil.checkGlError("glFramebufferTexture2D");
143-
134+
144135
/*
145-
* //No sure if this is required in opengl es 2. Ignoring as of now.
146-
* IntBuffer drawBuffers = IntBuffer.allocate(1); drawBuffers.put(0,
147-
* GLES20.GL_COLOR_ATTACHMENT0); GLES30.glDrawBuffers(1, drawBuffers);
148-
*/
149-
136+
//No sure if this is required in opengl es 2. Ignoring as of now.
137+
IntBuffer drawBuffers = IntBuffer.allocate(1);
138+
drawBuffers.put(0, GLES20.GL_COLOR_ATTACHMENT0);
139+
GLES30.glDrawBuffers(1, drawBuffers);
140+
*/
141+
150142
// See if GLES is happy with all this.
151143
int status = GLES20.glCheckFramebufferStatus(GLES20.GL_FRAMEBUFFER);
152144
if (status != GLES20.GL_FRAMEBUFFER_COMPLETE) {
153-
throw new RuntimeException("Framebuffer not complete, status="
154-
+ status);
145+
throw new RuntimeException("Framebuffer not complete, status=" + status);
155146
}
156147
}
157148

0 commit comments

Comments
 (0)