- class Texture {
- private uint textureName;
- private int width;
- private int height;
- public this(int width, int height) {
- this.width = width;
- this.height = height;
- ubyte texture[];
- texture.length = width * height * 3;
- glGenTextures(1, &textureName);
- bind();
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, texture.ptr);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- delete texture;
- }
- public void fromColorBuffer() {
- bind();
- glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, width, height, 0);
- }
- public void bind() {
- glBindTexture(GL_TEXTURE_2D, textureName);
- }
- }