Hi,
I'm new in openGL, I'm trying to draw a rectangle over my Frame Marker. I'm using the Frame Marker sample and I'm able to draw my rectangle without showing the video but when I uncomment the line which render the video background, I have an EXC_BAD_ACCESS error on the glDrawElements line.
In the renderFrameQCAR method I have added the lines :
CC3GLMatrix *projection = [CC3GLMatrix matrix]; float h = 4.0f * self.frame.size.height / self.frame.size.width; [projection populateFromFrustumLeft:-2 andRight:2 andBottom:-h/2 andTop:h/2 andNear:4 andFar:10]; glUniformMatrix4fv(_projectionUniform, 1, 0, projection.glMatrix); CC3GLMatrix *modelView = [CC3GLMatrix matrix]; [modelView populateFromTranslation:CC3VectorMake(sin(CACurrentMediaTime()), 0, -7)]; glUniformMatrix4fv(_modelViewUniform, 1, 0, modelView.glMatrix); glViewport(0, 0, self.frame.size.width, self.frame.size.height); glVertexAttribPointer(_positionSlot, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), 0); glVertexAttribPointer(_colorSlot, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), (GLvoid*) (sizeof(float) * 3)); glDrawElements(GL_TRIANGLES, sizeof(Indices)/sizeof(Indices[0]), GL_UNSIGNED_BYTE, 0);
With the following line commented it's working, but not when I uncomment it to render the video :QCAR::State state = QCAR::Renderer::getInstance().begin();
Any idea ? If you need more of my code to help me, don't hesitate.
- DaProd
glVertexPointer isn't implemented in OpenGL ES 2.0. Instead, you should be using glVertexAttribPointer, as the samples show.
I suggest taking a look at the VirtualButtons sample. It traces the button rectangles using GL_LINES. You should be able to do something quite similar for frame markers.
- Kim