MCPcopy Create free account
hub / github.com/PABannier/sam3.cpp / upload_texture

Function upload_texture

examples/main_image.cpp:160–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

158};
159
160static GLuint upload_texture(const uint8_t* data, int w, int h, int ch, GLuint existing = 0) {
161 GLuint tex = existing;
162 if (!tex) glGenTextures(1, &tex);
163 glBindTexture(GL_TEXTURE_2D, tex);
164 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
165 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
166 GLenum fmt = (ch == 4) ? GL_RGBA : GL_RGB;
167 glTexImage2D(GL_TEXTURE_2D, 0, fmt, w, h, 0, fmt, GL_UNSIGNED_BYTE, data);
168 return tex;
169}
170
171static void build_overlay(app_state& app) {
172 if (app.image.data.empty()) return;

Callers 2

build_overlayFunction · 0.70
load_imageFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected