void create_texture GLuint texture size_t width size_t height bool cle

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
void create_texture (GLuint & texture, size_t width, size_t height, bool clear = false)
{
float *data = NULL;
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
if (clear) {
data = new float [(width * height) * 4 * sizeof (float)];
ZeroMemory (data, (width * height) * 4 * sizeof(float));
}
glTexImage2D(GL_TEXTURE_2D, 0, 4, width, height, 0, GL_RGBA, GL_FLOAT, data);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
if (clear) {
delete [] data;
}
}