The Problem
I am attempting to load and display an image in OpenGL using the SOIL library. I originally started with lodePNG but I had difficulties getting the image to display so I assumed it was just a library issue and decided to switch to SOIL, however, as I am having the same issue now I believe it must be something that I am doing wrong somewhere in my own code.
So, the exact issue is that I seem to be able to load a texture correctly: the width and height attributes get set to the appropriate value, and if I just dump the data it loads to console it seems to have actually grabbed the appropriate data (Screenshots later on). The problem comes when I try to render it, I believe my shader and loading code to be correct, however I only get a black square upon rendering. I have been working on this for a couple of days now, trying lots of iterations and have even seperated out all of my framework code and have a completely barren example now that just loads up OpenGL and needed libraries and tries to render.
I am seriously at a loss as to what I am doing wrong, I am using GL_TEXTURE1 as my active texture but I originally started with GL_TEXTURE0 so I don't think that would be the problem.
Beyond that I can't think of anything that I am glaringly doing wrong; console output from Bitmap.cpp DOES output correct data (the image to display is 64x64) and when I dump the char* it outputs a large amount of data that was loaded into it.
EDIT
I managed to fix it, I honestly can't believe I missed this but when I switched from lodePNG to SOIL I never added the 4 lines that set the attributes of the images. Adding these lines fixed everything right up and made it render
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
Bitmap.cpp
GLuint BitmapLoader::Load(std::string path) {
glEnable(GL_TEXTURE_2D);
GLuint texture_id;
glGenTextures(1, &texture_id);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture_id);
image = SOIL_load_image(path.c_str(), &width, &height, 0, SOIL_LOAD_RGBA);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image);
std::cout << "Width: " << width << ", Height: " << height << std::endl;
std::cout << "Image ID: " << texture_id << std::endl;
std::cout << "Image Data: " << image << std::endl;
SOIL_free_image_data(image);
if (texture_id == -1) {
return -1;
}
return texture_id;
}