How do you render textures in GLSL? I know a bit about shaders, but i only use them in game engines, which usually make it easier to input textures and then render them in the shader.
I have never used any game engines or textures or shaders before for anything…but here’s two sources I found that might help!
(I think this is right)
That’s for C/C++, and I’m not using a game engine right now, I’m using a Repl with the GLSL template
ah ok, sorry! Let me try something else
Sorry, I’m not very educated on this subject, I don’t want to give you any misleading information, you’ll have to ask someone else other than me, my apologies
It depends really.
What kind of API are you using?
Which graphics library?
If you are using
stb_image.h library there is a good example here by how to use it:
Lighthouse3d have a good tutorial about it and a good library too. https://www.lighthouse3d.com/tutorials/glsl-tutorial/
A simple way to load texture data into a texture object would be:
GLuint textureID; glGenTextures(1, &textureID); glBindTexture(GL_TEXTURE_2D, textureID); // Set your texture parameters glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // Load image data here int width, height, numChannels; unsigned char* data = stbi_load("path_to_your_image.png", &width, &height, &numChannels, 0); // Use loaded image data here glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data); glGenerateMipmap(GL_TEXTURE_2D); stbi_image_free(data);