Hello, I need to write a OpenGL code for an accademic project, to overlay cartography information over a video coming from a plane.
The cartography is available as a DXF and can be easily loaded in a GL 3D world.
The camera position and orientation should be derivable from GPS information mounted on the plane.
I just want an advice to set up the project in order to make something working possibly real time and usable.
Unfortunately I have to use Winforms, but I found a good example showing how to integrate OpenGL with .NET managed Winforms
http://www.codeproject.com/KB/miscctrl/OpenGLViewWinForms.aspx
I have also integrated dxflib to load the DXF and libVLC to receive the video stream.
In particular libVLC is offering a media player instance whose initialization takes a callback address to a function libVLC will call after the decoding of each frame, and a buffer address where libVLC will store the pixel data in 32 bit BGRA.
So in this callback I call
glDrawPixels(VIDEO_WIDTH, VIDEO_HEIGHT, GL_BGRA,
GL_UNSIGNED_INT_8_8_8_8, (void*)pixelData);
This is working fine, the video playing is working fine and real time, the CPU usage is very low… yet the video is vertically flipped.
So before glDrawPixels I tried to call
glRasterPos2i(0, VIDEO_HEIGHT); // also tried glRasterPos2i(0, 0);
glPixelZoom(1, -1);
but it does not work. With these two lines before glDrawPixels I see just the first video frame, again vertically flipped, and then the video does not change, but the CPU usage is still very low.
Another problem I encountered is that, flipped or not flipped, I want OpenGL to draw over my video, so immediately after glDrawPixels I call
glLoadIdentity();
glTranslatef(...);
glRotatef(...);
glBegin(GL_TRIANGLES);
. . .
glEnd();
but I see only the video frame.
Yet, if I replace glDrawPixels with glClear I see polygons on black background.
Can you help me or advice me some better solution for my project?
What I need is drawing polygons on a video stream instead of drawing polygons on a black background.