Combining OpenGL and Cocos2dx gives off-center origin for OpenGL calls

I’m doing a multi-platform (iOs and Android) project and super-sampling to a CCRenderTexture. Idea is to use one resource set and scale to fit different resolutions.

Everything works drawing backgrounds and CCSprites to the CCRenderTexture with visit(), however I also need to do some direct openGL calls to draw extruded textures as well with glDrawArrays. I should say I’m very new to cocos2d and not hugely experienced with openGL either.

My problem is that the origin for the openGL calls seems to be off-center. Hopefully the attached images helps explain this. At 1) is the origin 0,0 at the bottom left for placing sprites via cocos2dx, that’s all fine and works great. But 2) shows where the origin 0,0 for the openGl calls is, just off-center whereas I’d expected it to be dead center screen. I can almost put in a frig to pull it back to the center but it doesn’t quite work on all resolutions. I’d rather find what the problem is and fix it properly.

I’m presuming cocos handles setting up the viewport/frustrum and that’s a step I’m missing in my our opengl calls. Can anyone suggest how to combine the two in a way that won’t break Android?

I’m happy to post bits of code that may help get an answer, but don’t want to spam the whole lot.

EDIT: I’m using cocos2d-2.0-x-2.0.4 with a minor change in CCDirector.h

    /// Default projection is 3D projection
    kCCDirectorProjectionDefault = kCCDirectorProjection2D


cocosopengl.png (16.1 KB)