I create a x11 window with opengl functionality, i need to load a image(jpeg | png) on its background where size of window be bigger than image, it doesn't matter. I surfed to get resylts like use DevIL or free image. I dont know which one to use. I set up the opengl window with the sample code given in a link to sample code and i there i want to write code in void renderGL() so as to make the image as background. Can you tell me which image library to use and provode the code if possible.
And also what is to be done to plot color pixels in opengl. i need a function to draw a pixel in a window , for which i have to provide the x,y pixel position and rgb color alone(unsigned int).....
I'm not much of a opengl programmer, but somehow i did this and its workinh
ilInit(); /* Initialization of DevIL */
ilGenImages(1, &texid); /* Generation of one image name */
ilBindImage(texid); /* Binding of image name */
success = ilLoadImage(backgroundimage); /* Loading of image "image.jpg" */
iWidth = ilGetInteger(IL_IMAGE_WIDTH);
iHeight = ilGetInteger(IL_IMAGE_HEIGHT);
if (success){
success = ilConvertImage(IL_RGBA, IL_UNSIGNED_BYTE); // Convert every colour component into unsigned byte,replace IL_RGB with IL_RGBA for alpha channel
}
glGenTextures(1, &image); /* Texture name generation */
glBindTexture(GL_TEXTURE_2D, image); /* Binding of texture name */
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, ilGetInteger(IL_IMAGE_BPP), ilGetInteger(IL_IMAGE_WIDTH),
ilGetInteger(IL_IMAGE_HEIGHT), 0, ilGetInteger(IL_IMAGE_FORMAT), GL_UNSIGNED_BYTE,
ilGetData()); /* Texture specification */
glRotatef(roll, 0.0f,0.0f, 10.0f);
glOrtho(0.0, float(width), float(height), 0.0, 0.0, 100.0);
glMatrixMode(GL_MODELVIEW);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClearDepth(0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity(); // Reset The Modelview Matrix
glBindTexture(GL_TEXTURE_2D, image); // Select The First Image Texture
glBegin(GL_QUADS);// Start Drawing A Textured Quad
glTexCoord2i(0, 0); glVertex2f(width/2-iWidth/2,height/2-iHeight/2);
glTexCoord2i(0, 1); glVertex2f(width/2-iWidth/2,height/2+iHeight/2);
glTexCoord2i(1, 1); glVertex2f(width/2+iWidth/2,height/2+iHeight/2);
glTexCoord2i(1, 0); glVertex2f(width/2+iWidth/2,height/2-iHeight/2);
glEnd();