1
Graphics / glGetTexImage returns nothing
« on: April 27, 2020, 06:40:42 pm »
Hi! I'm making my second project using SFML and it's a hill climbing algorithm, which approximates images using an sf::VertexArray of triangles. My problem is when I write my sf::VertexArray to a texture, and then use glGetTexImage() so I can fill three arrays with the RGB values of every pixel, these arrays stay empty. I checked for errors using glGetError() and it returns 0.
Here's the code I use:
Here's the code I use:
glEnable(GL_TEXTURE_2D);
sf::Texture::bind(&texture->getTexture());
glGetTexImage(GL_TEXTURE_2D, 0, GL_RED, GL_UNSIGNED_BYTE, red);
glGetTexImage(GL_TEXTURE_2D, 0, GL_GREEN, GL_UNSIGNED_BYTE, green);
glGetTexImage(GL_TEXTURE_2D, 0, GL_BLUE, GL_UNSIGNED_BYTE, blue);
If I create an sf::Texture and use loadFromImage() It fills the three arrays no problem. I also draw the sf::VertexArray to a window if that matters in any way.
sf::Texture::bind(&texture->getTexture());
glGetTexImage(GL_TEXTURE_2D, 0, GL_RED, GL_UNSIGNED_BYTE, red);
glGetTexImage(GL_TEXTURE_2D, 0, GL_GREEN, GL_UNSIGNED_BYTE, green);
glGetTexImage(GL_TEXTURE_2D, 0, GL_BLUE, GL_UNSIGNED_BYTE, blue);