fred's picture

OTK for viewing camera pictures frequently?

Good morning everyone,

i was wondering about the abilities and advantages
in viewing camera pictures at high framerates of the OTK.

I'm currently viewing pictures on the PictureBox and
sometimes by blitting them on my form.
This is well done while that program has nothing else
to do.

With BitBlt it is necessary resizing bitmaps in before
and the speed advantage is gone.

So my question is, would it be possible at all with OGL
to only view pictures frequently and do a little drawing like lines
faster than .Net stuff and P/Invoke does?

ps. I was fiddeling around a bit and what I'm not succeeded in
was creating textures fast and viewing them just like pictures
on the screen.

Thanks in advance.

fred


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

OpenGL will help you maintain high framerates when resizing, zooming or panning a picture. However, It will not help you load a picture faster from disk.

I have written a book page explaining how to load a texture: http://www.opentk.com/doc/graphics/textures/loading

To learn how to render the texture, use the code from the texturing sample (included in OpenTK under Source/Examples/OpenGL/1.1/Textures.cs). This snippet in your Paint handler should do the trick:

            GL.Viewport(0, 0, Width, Height);
 
            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadIdentity();
            GL.Ortho(-1.0, 1.0, -1.0, 1.0, 0.0, 4.0);
 
            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity();
 
            GL.Enable(EnableCap.Texture2D);
            GL.Hint(HintTarget.PerspectiveCorrectionHint, HintMode.Nicest);
 
            GL.BindTexture(TextureTarget.Texture2D, texture);
 
            GL.Clear(ClearBufferMask.ColorBufferBit);
 
            GL.Begin(BeginMode.Quads);
            GL.TexCoord2(0.0f, 1.0f); GL.Vertex2(-0.6f, -0.4f);
            GL.TexCoord2(1.0f, 1.0f); GL.Vertex2(0.6f, -0.4f);
            GL.TexCoord2(1.0f, 0.0f); GL.Vertex2(0.6f, 0.4f);
            GL.TexCoord2(0.0f, 0.0f); GL.Vertex2(-0.6f, 0.4f);
            GL.End();
 
            glControl.SwapBuffers();
fred's picture

Thank you very much for your fast response.

I will have a look at it .

iliak's picture

To speed up texture loading you may have a look at PBO.

fred's picture

Hi,

at first I had to disable the TransparencyKey of the main Window.
But then I got it to work.
Thanks again...

But one question remains.
The pictures from the camera are in 8bppxlIndexed color format.
Would it probably be better setting the whole process to 8bit?
I haven't found a way by setting "PixelInternalFormat" aso. to another
value but unfortunately got a lot of blue screens thereby...

the Fiddler's picture

For best compatibility and speed, I'd recommend always using 32bit textures nowadays. 8bit palleted textures stopped being supported natively many years ago (around the Geforce FX era) and they might even cause problems on less robust OpenGL drivers like Intel's.

fred's picture

You're great...