I've been trying to draw a bitmap int array using glTexImage2D, but it only outputs white nothingness. It outputs jumbled messy pixels from out of bounds memory if I initialize the int aray as a char array instead, but it only renders whiteness if I try casting an int array to a char array.
What I have tried:
I've even tried using memcpy to copy the ints to a 4x larger array called PixelsTemp, but it's still white for some reason. If I manually change some values in PixelsTemp[211], it will show a single blue pixel, but nothing from the memcpy shows somehow. It makes no sense, because PixelsTemp actually works with glDrawPixels just fine, but it's just nothing but white with glTexImage2D. Please help.
void beginRefresh() {
unsigned char* PixelsTemp = new unsigned char[width * height * 4];
memcpy(PixelsTemp, Pixels, width * height * 4);
glEnable(GL_TEXTURE_2D);
glGenTextures(1, &glBuffer);
glBindTexture(GL_TEXTURE_2D, glBuffer);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, PixelsTemp);
UpdateViewport();
glClear(GL_COLOR_BUFFER_BIT); glViewport(nViewX, nViewY, nViewW, nViewH);
glBegin(GL_QUADS);
glTexCoord2f(0.0, 1.0); glVertex3f(-1.0f + (fSubPixelOffsetX), -1.0f + (fSubPixelOffsetY), 0.0f);
glTexCoord2f(0.0, 0.0); glVertex3f(-1.0f + (fSubPixelOffsetX), 1.0f + (fSubPixelOffsetY), 0.0f);
glTexCoord2f(1.0, 0.0); glVertex3f(1.0f + (fSubPixelOffsetX), 1.0f + (fSubPixelOffsetY), 0.0f);
glTexCoord2f(1.0, 1.0); glVertex3f(1.0f + (fSubPixelOffsetX), -1.0f + (fSubPixelOffsetY), 0.0f);
glEnd();
delete[] PixelsTemp;
SwapBuffers(glDeviceContext);
}