Skip to content

Texture

Jesusemora edited this page Mar 10, 2023 · 2 revisions

Texture

Loads a texture in memory. it also has functions for binding textures to opengl and swaping textures. work in progress

Variables

int width width of the image
int height height of the image
unsigned char* imageO stores loaded image
bool isAlpha used to selected between GL_RGB and GL_RGBA

public methods

void createTex(char* filePath) loads a texture from file as RGB
void createTex(char* filePath, bool alpha) when alpha is used, loads a texture from file as RGBA
void SetFlags(int ws, int wt, int filtmin, int filtmax, bool mipmap = true) sets the horizontal and vertical wrapping ws and wt, filtering min and max filtmin and filtmax and wheter or not to generate mipmaps.
filtmin opengl
0 nearest GL_NEAREST
1 linear GL_LINEAR
2 nearest mipmap nearest
3 nearest mipmap linear
4 linear mipmap nearest
5 linear mipmap linear
filtmax
0 nearest
1 linear
ws - wt opengl
0 repeat GL_REPEAT
1 clamp GL_CLAMP_TO_EDGE
2 mirrored GL_MIRRORED_REPEAT
void BindTexture(int id, GLuint *textureID) binds the current texture to the location id using a GLuint textureID previously generated with glGenTextures(size, textureID)
void SwapTexture(int id, GLuint *textureID) used during render loop. assigns the current texture to the location id (GL_TEXTURE0 + id)

Clone this wiki locally