Update
In case anyone wants to do something similar I solved it by making a transparent background and setting an image for the container ViewController.
To make the transparent background y just used:
glClear(GL_COLOR_BUFFER_BIT);
glClearColor(0, 0, 0, 0);
Thanks AlessandroB for your help and insights,
:)
----------------------------------------
AlessandroB wrote:
Yes, that's possible. The best way would be to create an OpenGL texture for the background image (the code to do that can be derived from the code used to create the teapot textures in the ImageTargets sample, for instance...)
Then you could render the texture on a screen aligned quad; this should occur right after the call to glClear() which I was mentioning before.
Hi AlessandroB,
I think something like the code I copied from te frameMarker example could work, but unfortunately I'm not familiar with openGL and I don't know how to populate the following variables: numVerts, verts, normals, textCoords and anotherMatrix in order to create a plane that I can apply the texture to.
glClear(GL_COLOR_BUFFER_BIT);
[self add3DObjectWith:numVerts ofVertices:verts normals:normals texcoords:textCoords with:0 ofIndices:0 usingTextureIndex:0];
Object3D *obj3D = [objects3D objectAtIndex:0];
// Render with OpenGL 2
QCAR::Matrix44F modelViewProjection;
ShaderUtils::multiplyMatrix(&qUtils.projectionMatrix.data[0], &anotherMatrix.data[0], &modelViewProjection.data[0]);
glUseProgram(shaderProgramID);
glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0, obj3D.vertices);
glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0, obj3D.normals);
glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0, obj3D.texCoords);
glEnableVertexAttribArray(vertexHandle);
glEnableVertexAttribArray(normalHandle);
glEnableVertexAttribArray(textureCoordHandle);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, [obj3D.texture textureID]);
glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE, (GLfloat*)&modelViewProjection.data[0]);
glUniform1i(texSampler2DHandle, 0);
glDrawArrays(GL_TRIANGLES, 0, obj3D.numVertices);
It would be really helpful if you can provide me with some hints or examples about how can I initialize those variables.
As always, thank you for your time,
For new visitors, please, refer to this thread, which describes a much simpler way to achieve this.
Aernarion.