   Loading images in OpenGL
  I am a beginner to OpenGL.I have read several posts to load images in OpenGL, but they are complicated (at least to me :) ) So, please help.Say I want to display the pictures car1.bmp, car2.bmp and car2.bmp in the three boxes in the following program, how do I do it?Quote:#include<GL/glut.h>void display();void myReshape(int w,int h);void main(int argc,char **argv){   glutInit(&argc,argv);   glutInitWindowSize(800,600);   glutInitWindowPosition(0,0);   glutCreateWindow("PointLinePlygon");   glutReshapeFunc(myReshape);   glutDisplayFunc(display);   glEnable(GL_DEPTH_TEST);   glutMainLoop();}void display(){   glClear(GL_COLOR_BUFFER_BIT);   glClear(GL_DEPTH_BUFFER_BIT);   glClearColor(0,0,0,0);   glBegin(GL_POLYGON); glColor3f(1,0,0); glVertex2f(-5,5); glVertex2f(0,5); glVertex2f(0,0); glVertex2f(-5,0);   glEnd();   glBegin(GL_POLYGON); glColor3f(0,1,0); glVertex2f(0,5); glVertex2f(5,5); glVertex2f(5,0); glVertex2f(0,0);   glEnd();   glBegin(GL_POLYGON); glColor3f(0,0,1); glVertex2f(0,0); glVertex2f(5,0); glVertex2f(5,-5); glVertex2f(0,-5);   glEnd();   glFlush();}void myReshape(int w,int h){   glViewport(0,0,w,h);   glMatrixMode(GL_PROJECTION);   glLoadIdentity();   if(w<=h) glOrtho(-10,10,-10*(GLfloat)h/(GLfloat)w,10*(GLfloat)h/(GLfloat)w,-20,20);   else glOrtho(-10*(GLfloat)w/(GLfloat)h,10*(GLfloat)w/(GLfloat)h,-10,10,-20,20);   glMatrixMode(GL_MODELVIEW);   glutPostRedisplay();}Please Help.   
  OpenGL itself does not provide any functionality to load images. U have to either write your own bitmap loader, or u use a library like devil or freeImage. The image itself then can be displayed using either a textured quad or u copy the image directly to the framebuffer (that has to have the right dimensions).The third option beside the 3rd party image libs would be to use glaux. This would probably be the simplest option, altough it is the least flexible one. There is a tutorial on that here:http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=06;  Yes, that is what I meant. It is complicated. However, I am trying to understand the program in lesson 6.There is no glutDisplayFunc in Lesson 6. So how do I make the image appear in the program in my first post?How do I map it into the three boxes created by the program in my first post?Please help.   ;  Well, all glutDisplayFunc does, is to call your "display" function that u defined above. So all the texture rendering code goes there. I'm afraid there is no simpler solution than the ones provided. Without u understanding what your OpenGL code actually does, it will be difficult for u to solve your problem. Maybe u start with the nehe tutorial lesson 1 and work yourself through to lesson 6. Its not the best tutorials on the market, but its a start and should help a great deal.   ;  If you keep with the "immediate mode" setup you're currently using, once you've figured out how to load the images into memory so that OpenGL can use them (which you'll still need to figure out ;) ), you'll want to set the active texture to the correct .bmp file and then use glTexCoord2f() before each vertex call to indicate where that vertex maps to your texture (keeping in mind that texture coordinates range from 0-1).You can also reduce the frequency of "switching active textures" if all three images are instead compiled into one texture that's left active (and the three boxes' vertices are mapped accordingly).   ;  For loading images, you will need to either write your own loader, or use a pre-written one.  I am a fan of SOIL (http://www.lonesock.net/soil.html) for loading images.   