So I have made this program for a game and need help with making it a bit more automatic.
The program takes in an image and then displays it. I’m doing this over textures in OpenGL. When I take the screenshot of the game it is usually something about 700×400. I input the height and width into my program, resize the image to 1024×1024 (making it a POT texture for better compatibility) by adding blank space (the original image stays at the top left corner and goes all the way to (700,400) and the rest is just blank; does anyone know the term for this?) and then load it into my program and adjust the corners so only the part from (0,0) to (700,400) is shown.
That’s how I handle the display of the image. Now, I would like to make this automatic. So I’d take a 700×400 picture, pass it to the program which would get the image’s width and height (700×400), resize it to 1024×1024 by adding blank space and then load it.
So does anyone know a C++ library capable of doing this? I would still be taking the screenshot manually though.
I am using the Simple OpenGL Image Library (SOIL) for loading the picture (.bmp) and converting it into a texture.
Thanks!
You don’t really have to resize by adding blank space to display image properly. In fact, it’s really unefficient way to do it, especially because you store images in .bmp format.
SOIL is able to automatically add the blank space when loading textures – maybe just try to load the file as-is, without doing any operations.
From SOIL Documentation:
Anyway, you don’t have to use texture to display pixels on the screen. I presume you aren’t using shaders for rendering – if it all goes through fixed pipeline, there’s
glDrawPixelsfunction, which will be much simpler. Just remember to change your SOIL call toSOIL_load_image.