Log in or register to post comments

Integration between vuforia's EAGLview and other opengl view

October 18, 2013 - 7:50am #1

Hello,

i basically have an OpenGL standalone application that works (let's say a simple shader). I would like to compile it as a library and call it from within the xcode image targets sample: this way, i can easily change the library behaviour and deploy it much faster in both ios and android.

That said, the first thing i did was to try to wrap my working code (so no library yet) and see if thing worked. So i'm trying to glue this ios sample ( http://www.ignaciosanchezgines.com/2009/08/27/iphone-and-c-opengl-programming/ ) with the imagetarget sample

void openglWrapper::Init(EAGLContext* pContext, GLuint renderBuffer, GLuint frameBuffer, GLuint depthBuffer)
{
    m_pContext = pContext;
    m_uiViewRenderbuffer = renderBuffer;
    m_uiViewFramebuffer = frameBuffer;
    m_uiDepthRenderbuffer = depthBuffer;
}

- (void) postInitQCAR
{
    openglWrapper::Instance().Init(context, colorRenderbuffer, defaultFramebuffer, depthRenderbuffer);
}

so far, it seems so good. I then have a few functions taken from that sample, that basically draws on screen

void openglWrapper::Update(void)
{
    BeginRender();
    DrawSomething();
    EndRender();
}

void openglWrapper::BeginRender(void)
{
    [EAGLContext setCurrentContext:m_pContext];
    glBindFramebufferOES(GL_FRAMEBUFFER_OES, m_uiViewFramebuffer);
   // glViewport(0, 0, 320, 480);
}

void openglWrapper::EndRender(void)
{
    glBindRenderbufferOES(GL_RENDERBUFFER_OES, m_uiViewRenderbuffer);
    [m_pContext presentRenderbuffer:GL_RENDERBUFFER_OES];
}

void openglWrapper::DrawSomething(void)
{
    const GLfloat squareVertices[] = {
        -0.5f, -0.5f,
        0.5f,  -0.5f,
        -0.5f,  0.5f,
        0.5f,   0.5f,
    };
    const GLubyte squareColors[] = {
        255, 255,   0, 255,
        0,   255, 255, 255,
        0,     0,   0,   0,
        255,   0, 255, 255,
    };   
   
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrthof(-1.0f, 1.0f, -1.5f, 1.5f, -1.0f, 1.0f);
    glMatrixMode(GL_MODELVIEW);
    glRotatef(3.0f, 0.0f, 0.0f, 1.0f);
    
    glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT);
    
    glVertexPointer(2, GL_FLOAT, 0, squareVertices);
    glEnableClientState(GL_VERTEX_ARRAY);
    glColorPointer(4, GL_UNSIGNED_BYTE, 0, squareColors);
    glEnableClientState(GL_COLOR_ARRAY);
    
    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
    
    
}

However, when i call the instance.Update() function (after the QCar Render)

    QCAR::Renderer::getInstance().end();
    [self presentFramebuffer];
    
    openglWrapper::Instance().Update();

All i get is a white screen. It seems that the only function that is doing something is the glClear(). If i try to remove it (i don't wan't to clear the buffer, after all) all i get is a black screen, even just after the first glMatrixMode().

I need some guidance in how to glue these two projects togheter.

Thanks in advance!

 

Integration between vuforia's EAGLview and other opengl view

January 3, 2016 - 2:46am #6

aa1984 wrote:

a little update, for future users passing by:

i'm trying out http://www.openframeworks.cc/ with the Qcar extension ( https://github.com/julapy/ofxQCAR ). It works beautifully with Xcode5 and latest(ish) sdk (i'm on 2.6.8) . There's no qcar extension for android but shouldn't be to much of a hassle to wrap it up.

I can finally bring in my C++ code and shaders and merge them pretty easily with the qcar openGL view (screen attached)

Hope this helps!

 

No its not easy. you have to completely change the whole library code and have a deep knowledge about NDK & JNI.

 

Integration between vuforia's EAGLview and other opengl view

October 22, 2013 - 3:11am #5

Thanks for the update!

Keep us posted.

 

N

Integration between vuforia's EAGLview and other opengl view

October 22, 2013 - 2:59am #4

a little update, for future users passing by:

i'm trying out http://www.openframeworks.cc/ with the Qcar extension ( https://github.com/julapy/ofxQCAR ). It works beautifully with Xcode5 and latest(ish) sdk (i'm on 2.6.8) . There's no qcar extension for android but shouldn't be to much of a hassle to wrap it up.

I can finally bring in my C++ code and shaders and merge them pretty easily with the qcar openGL view (screen attached)

Hope this helps!

AttachmentSize
Image icon ofx.jpg96.11 KB

Integration between vuforia's EAGLview and other opengl view

October 21, 2013 - 12:57am #3

thanks, but using a third party engine is not really a viable solution for what i have to do.

as feedback, i'd say it would be nice to have an official sample that shows how to use another opengl view, in the meantime this documentation will have to do, thanks!

Integration between vuforia's EAGLview and other opengl view

October 18, 2013 - 8:59am #2

You need to think carefully before you try to link togetherother OpenGL code with Vuforia because traditionally it has not been an easy task.

Some have struggled and some have succeeded, but the way most people go is to try and integrate a 3rd party 3D engine that can facilitate the loading of 3D models.

It is worth searching the forums for relevant keywords here (may take some time), but here is an example:

https://developer.vuforia.com/forum/ios/cocos2d-and-qcar-project-integration

 

Among other things you would need to deal with state changes:

https://developer.vuforia.com/search/apachesolr_search/OpenGL#per-page=50&ft=dev_guide

 

Also, RenderFrameQCAR gets called on a background thread at present which is something you may need to factor in.

The simplest, easiest thing you can do ... is to use Unity if you can as it will save you bundles of time.

 

N

Log in or register to post comments