texture & screen mapping

Hello.

I’m new at this opengl stuff – so thanks for any help you can offer.

What I simply want to do is display an image using a texture. (Visual C) :slight_smile:
I have a data array (pixel data) (256x128).
I want to display this on the screen.
I want this texture to be displayed at the same 256x128 resolution. (1 to 1 relationship)

I am able to display the texture but I do not know how to get the exact 256x128 screen resolution - the 1 to 1 data pixel to screen pixel relationship.

How do I get a 1 to 1 data pixel to screen pixel relationship for a texture?

Thank you,

  • lisa

instead of a texture you could draw it with glDrawPixels

otherwise I don’t know but probably you have to to estimate a relationship between viewport width and width of your projection plane maybe to take a look into the manual helps here (projection section or something)

Thanks but…
I want to use textures because I will be redrawing the image many times & texture mapping will be faster than glDrawPixels.

  • lisa

I suppose you could create a view frustum (with glOrtho preferably) that has the same size as the window. e.g. if the window has wxh 256x128 then you’d create a glFrustum(0, 256, 0, 128, -1, 1);
Then you only need to create a rectangle that would fill the whole window and map the texture to it.
Unfortunately, the mapping still might not be exact. In a CRT for example you can resize the image in a given resolution and refresh rate to fit the whole screen. I hope I gave you an idea. Good luck!

You choose your viewport, projection, vertex locations and texture coordinates very carefully. OpenGL defines these accurately so it is possible to do this.

dvm is right it’s best to use an ortho projection unless you have an equally effective way of knowing exactly where you are in screenspace after projection.