Make sure you have an image with packed 8 bit data per component per pixel like rgbrgbrgbrgb etc. etc for each pixel, and make calls like the following ONLY ONCE AT THE START but make sure it’s AFTER you have your OpenGL context active:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, your_image_pointer);
Then when you need to use the texture call:
To draw a quad with the texture on it use the following code, just alter the glVertex calls to suit your needs, you obviously know what these do now.
Then when you’re done call
If you want to use other images simply use glBindTexture(GL_TEXTURE_2D, 2); with a different integer NOTE I’VE CHANGED THE ONE TO A TWO, that tells OpenGL this is a different texture, the second argument is a unique handle identifying the texture, you can use any numbers you like unless you want to play nicely with other software libraries you might link to. You can initialize lots of textures once at the start and use them later with the bind calls, this will ensure your code is nice & fast when you move the slider.
If you only have one texture you don’t need the bind calls, however you will need to use them later if you add images and want to stay as fast as possible.
This is very basic and so the code looks surprisingly simple, once you get this working you can improve it with features like texture filtering etc.
This is all untested so excuse any typos. One thing you may want to do depending on your image is change the formats and use ABGR to speed up load time marginally depending on your image source, but just try to get something working first, then you can get fancy later.