Log in or register to post comments

Fatal signal 11 (SIGSEGV) at 0x00000018 (code=1) when array called

August 9, 2012 - 1:12pm #1

I am trying to add two button on trackable. I want to run buttons when they are touched on screen, not like virtualbutton. I have following code. The Fatal signal 11 error is thrown when I tried to call an element of "modelViewMatrix.data[0]" or "transform" in renderPlane function. I cannot draw anything due to that problem. Help please, I hope that I explained well my problem.

 

JNIEXPORT void JNICALL
Java_us_mron_Postocam_vp_ObjectRenderer_renderFrame(JNIEnv *env, jobject obj)
{
    //LOG("Java_us_mron_Postocam_vp_ObjectRenderer_renderFrame");

    // Clear color and depth buffer
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    // Get the state from QCAR and mark the beginning of a rendering section
    QCAR::State state = QCAR::Renderer::getInstance().begin();
   
    // Explicitly render the Video Background
    QCAR::Renderer::getInstance().drawVideoBackground();
      
   
    // Did we find any trackables this frame?
    for(int tIdx = 0; tIdx < state.getNumActiveTrackables(); tIdx++)
    {
        // Get the trackable:
        const QCAR::Trackable* trackable = state.getActiveTrackable(tIdx);
        modelViewMatrix = QCAR::Tool::convertPose2GLMatrix(trackable->getPose());  
       
        // Render the augmentation
        renderAugmentation(trackable);

    }

    QCAR::Renderer::getInstance().end();
}

void
renderAugmentation(const QCAR::Trackable* trackable)
{
    const Texture* const btnTexture = textures[0];

#ifdef USE_OPENGL_ES_1_1
    // Set GL11 flags
    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_NORMAL_ARRAY);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);

    glTexCoordPointer(2, GL_FLOAT, 0, (const GLvoid*) &shapeTexCoords[0]);
    glVertexPointer(3, GL_FLOAT, 0, (const GLvoid*) &shapeVertices[0]);
    glNormalPointer(GL_FLOAT, 0,  (const GLvoid*) &shapeNormals[0]);

    glEnable(GL_TEXTURE_2D);
    glDisable(GL_LIGHTING);

    // Load projection matrix
    glMatrixMode(GL_PROJECTION);
    glLoadMatrixf(projectionMatrix.data);

    // Load model view matrix
    glMatrixMode(GL_MODELVIEW);
    glLoadMatrixf(modelViewMatrix.data);
#else
    // Bind shader program
    glUseProgram(shaderProgramID);

    // Set GL20 flags
    glEnableVertexAttribArray(vertexHandle);
    glEnableVertexAttribArray(normalHandle);
    glEnableVertexAttribArray(textureCoordHandle);

    glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &shapeVertices[0]);
    glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &shapeNormals[0]);
    glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &shapeTexCoords[0]);
#endif

    glEnable(GL_DEPTH_TEST);

    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    glActiveTexture(GL_TEXTURE0);

    // Render the dominoes
    glBindTexture(GL_TEXTURE_2D, btnTexture->mTextureID);

    renderPlane(&btnMagnifier->transform.data[0]);

    SampleUtils::checkGlError("ImageTargets renderFrame");

    glDisable(GL_BLEND);
    glDisable(GL_DEPTH_TEST);

#ifdef USE_OPENGL_ES_1_1
    glDisable(GL_TEXTURE_2D);
    glDisableClientState(GL_VERTEX_ARRAY);
    glDisableClientState(GL_NORMAL_ARRAY);
    glDisableClientState(GL_TEXTURE_COORD_ARRAY);
#else
    glDisableVertexAttribArray(vertexHandle);
    glDisableVertexAttribArray(normalHandle);
    glDisableVertexAttribArray(textureCoordHandle);
#endif
}

void
renderPlane(float* transform)
{
    // Render a cube with the given transform
    // Assumes prior GL setup

#ifdef USE_OPENGL_ES_1_1
    glPushMatrix();
    glMultMatrixf(transform);
    glDrawElements(GL_TRIANGLES, NUM_SHAPE_OBJECT_INDEX, GL_UNSIGNED_SHORT, (const GLvoid*) &shapeIndices[0]);
    glPopMatrix();

#else

    QCAR::Matrix44F modelViewProjection, objectMatrix;
    SampleUtils::multiplyMatrix(&modelViewMatrix.data[0], transform, &objectMatrix.data[0]);
    SampleUtils::multiplyMatrix(&projectionMatrix.data[0], &objectMatrix.data[0], &modelViewProjection.data[0]);
    glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE, (GLfloat*)&modelViewProjection.data[0]);
    glDrawElements(GL_TRIANGLES, NUM_SHAPE_OBJECT_INDEX, GL_UNSIGNED_SHORT, (const GLvoid*) &shapeIndices[0]);

#endif
}

Fatal signal 11 (SIGSEGV) at 0x00000018 (code=1) when array call

August 10, 2012 - 6:30pm #3

Actually this way is a little bit complicated for me. I am trying a new way to check intersection. Can you check topic: https://ar.qualcomm.at/content/how-check-object-intersection ?

Fatal signal 11 (SIGSEGV)

August 10, 2012 - 9:45am #2

What type is transform declared as, and have you tried passing this to multiplyMatrix by reference?

Log in or register to post comments