Jump to content
  • Advertisement
Sign in to follow this  
alireza.pir

OpenGL Opengl Create FBO- fatal signal 11 error

This topic is 1173 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

in my android game, i want to render My scene in the FBO and a texture attached to it, and use that texture later, But When i use glGenFramebuffers i get this error:

07-30 06:17:27.839: A/libc(1338): Fatal signal 11 (SIGSEGV), code 1, fault addr 0xd0 in tid 1353 (GLThread 157)

here is my codes if needed:

 

createTexture Function:

public int CreateTexture(int w, int h){
Log.d("StartCreateTexture", "StartCreateTexture");
//GLES20.glGetError() ;
int[] textureId = new int[1];
int i;
//ijad mikonim 1 Adad texturte ro rooye textureID 

i = GLES20.glGetError();
GLES20.glGenTextures(1, textureId,0);
//BindTexture miad texturo ro baraaye call shodan amaade mikone
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureId[0]);
//texture nahaE ro ijaad mikonim
GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, w, h, 0, GLES20.GL_RGBA, GLES20.GL_FLOAT, null);
//in null tooye voroodie akharie bala, mige ke fazaa ro baraye texture ijad kon vali ba hichi poresh nakon hanooz
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST);
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);

if(i!=0){
Log.d("ERROR", "ERROR Happend"+i+"");
return i;
}

GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);
return textureId[0];
}

and onDrawFrame:

public synchronized void onDrawFrame(GL10 gl) {
if(first){
int renderTexture;
renderTexture = CreateTexture(128,128 );
GLES20.glGenFramebuffers(1, FBO,0);
GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, renderTexture, 0);
first = false;
}
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, FBO[0]);
// Some 'global' settings.
//gl.glEnableClientState(GLES20.GL_VERTEX_ATTRIB_ARRAY_ENABLED);
gl.glEnableClientState(GLES10.GL_VERTEX_ARRAY);

gl.glVertexPointer(3, GLES20.GL_FLOAT, 0, mBufVertices);
// Enable color array.
gl.glEnableClientState(GLES10.GL_COLOR_ARRAY);
gl.glColorPointer(4, GLES20.GL_FLOAT, 0, mBufColors);
//inja khasiate transparent ro faAl mikonim ke betoonim too CurlPage be kaaghaz alpha bedim
gl.glEnable(GLES20.GL_BLEND);
gl.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);
gl.glDisable(GLES10.GL_LIGHTING);
gl.glDisable(GLES20.GL_TEXTURE_2D);
gl.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, mVerticesCountFront);
int backStartIdx = Math.max(0, mVerticesCountFront - 2);
//Log.d("mVerticesCountFront", ""+mVerticesCountFront+"");
int backCount = mVerticesCountFront + mVerticesCountBack - backStartIdx;

// Draw back facing blank vertices.
//gl.glColor4f(1.0f, 0.0f, 0.0f, 0.5f);
gl.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, backStartIdx, backCount);

// Disable textures and color array.
gl.glDisableClientState(GLES10.GL_TEXTURE_COORD_ARRAY);
gl.glDisableClientState(GLES10.GL_COLOR_ARRAY);

GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
gl.glDisableClientState(GLES10.GL_VERTEX_ARRAY);
}

any idea of Why i get such error?

Edited by alireza.pir

Share this post


Link to post
Share on other sites
Advertisement

first of all textures in opengl are unsigned int not int

 

second thing you mess es 1.0 with es 2.0

 

 

es 1.0 may support GL_VERTEX_ARRAY,GL_COLOR_ARRAY etc

 

but ES 2.0 doesnt!

 

 

you have to create a vertex buffer like:

glGenBuffers(1, &arrow_buff);
	glBindBuffer(GL_ARRAY_BUFFER, arrow_buff);
	glBufferData(GL_ARRAY_BUFFER, sizeof(THUDItem) * 4, WIND_ARROW, GL_STATIC_DRAW);

	glBindBuffer(GL_ARRAY_BUFFER, 0);

where arrow_buff is unsigned int (or GLuint)

struct THUDItem
{
vec3 v;
vec3 c;
vec3 n;
vec2 t;
};

THUDItem WIND_ARROW[4]; //the array

 

 

 

 

===

i believe error occurs when you call glDrawArrays, btw i am surprised even that compiles i have no idea how can you mess two versions of ogl es.

additionally you cant call

gl.glDisable(GLES10.GL_LIGHTING);
gl.glDisable(GLES20.GL_TEXTURE_2D);

 

using es 2.0 so either way use es 1 or es 2, i recommed at least 2.0 and forget about 1.0

 

 

es 2.0 doesnt support such functions like

glEnableClientState(GLES10.GL_VERTEX_ARRAY);

you need to write shaders you dont call gl lighting or gl_texture_2d

 

seriously learn more modern ogl dud

 

 

http://www.learnopengles.com/

Edited by WiredCat

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!