Display an image array

Hello,

I’m new in OpenGL, so I’m sorry if I ask you in an inappropiate way. I want to draw an image using opengl. My image is calculated and stored in an 1D float array and each position is a pixel and contains a value which determines the colour of this pixel. Once the image is calculated I need to draw it in the screen. Do you know what is the best way to put it in the screen? I don’t know if I need to use textures or vertex buffer objects or something else or just use the opengl primitives like glVertex, etc… , so I’m confused about it and I hope you can help me. If you need more details, here I am.
Thanks you very much.

Greetings

Do your 1D float array contain data of a 2d image? When you retrieve a pixel value you use something like that: color = array[x +y*image_width]. In this case you can generate a 2d texture. Look at this tutorial on nehe web site for more information. Beware that in this tutorial the type of the texture data is GL_UNSIGNED_BYTE so you will have to change that parameter for floating point numbers. After reading the tutorial,my advise here is try to put a custom made (GLubyte data format) 2x2 texture on a quad like this one:


glBegin(GL_TRIANGLE_STRIP);
glTexCoord2f(0.0,0.0);
glVertex3f(-1.0,-1.0,0.0);
glTexCoord2f(1.0,0.0);
glVertex3f(1.0,-1.0,0.0);
glTexCoord2f(0.0,1.0);
glVertex3f(-1.0,1.0,0.0);
glTexCoord2f(1.0,1.0);
glVertex3f(1.0,1.0,0.0);
glEnd();

Also take care that if you don’t use advanced technique like tone mapping your float array should contain number between zero and one or the values will be clamped.