예제 #1
0
    void Texture::draw() {
        bind();
        quad.draw();
        unbind();

        checkGLError("Texture::draw quad draw");
    }
예제 #2
0
 unsigned char *Texture::mapData() {
     if(!texture) {
         glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pboTexture);
         texture = (unsigned char*)(glMapBuffer(GL_PIXEL_UNPACK_BUFFER,
                                                GL_READ_WRITE));
     }
     checkGLError("Texture::mapData");
     return texture;
 }
예제 #3
0
    void Texture::createTexture() {
        glGenTextures(1, &idTexture);
        glBindTexture(GL_TEXTURE_2D, idTexture);

        glTexParameteri(GL_TEXTURE_2D,
                        GL_TEXTURE_WRAP_S, GLint(GL_REPEAT));
        glTexParameteri(GL_TEXTURE_2D,
                        GL_TEXTURE_WRAP_T, GLint(GL_REPEAT));

        glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, width, height);
        checkGLError("Texture::createTexture glTexStorage2D");

        glGenBuffers(1, &pboTexture);
        glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pboTexture);
        glBufferData(GL_PIXEL_UNPACK_BUFFER,
                     getWidth() * getHeight() * getChannelCount(),
                     nullptr, GL_DYNAMIC_DRAW);
        checkGLError("Texture::createTexture glBufferData");
        glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
    }
예제 #4
0
    void Texture::uploadData() {
        glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pboTexture);

        bind();
        glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height,
                        GL_BGRA, GL_UNSIGNED_BYTE, 0);
        unbind();

        glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
        checkGLError("Texture::uploadData");
    }
예제 #5
0
 void Texture::unmapData() {
     glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
     checkGLError("Texture::unmapData");
     texture = nullptr;
 }