Пример #1
0
  private void initGLObjects() {
    if (clTexture != NULL) {
      checkCLError(clReleaseMemObject(clTexture));
      glDeleteTextures(glTexture);
    }

    glTexture = glGenTextures();

    // Init textures
    glBindTexture(GL_TEXTURE_2D, glTexture);
    glTexImage2D(
        GL_TEXTURE_2D,
        0,
        GL_RGBA8UI,
        ww,
        wh,
        0,
        GL_RGBA_INTEGER,
        GL_UNSIGNED_BYTE,
        (ByteBuffer) null);

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

    clTexture =
        clCreateFromGLTexture2D(
            clContext, CL_MEM_WRITE_ONLY, GL_TEXTURE_2D, 0, glTexture, errcode_ret);
    checkCLError(errcode_ret);
    glBindTexture(GL_TEXTURE_2D, 0);

    glViewport(0, 0, fbw, fbh);

    glUniform2f(sizeUniform, ww, wh);

    FloatBuffer projectionMatrix = BufferUtils.createFloatBuffer(4 * 4);
    glOrtho(0.0f, ww, 0.0f, wh, 0.0f, 1.0f, projectionMatrix);
    glUniformMatrix4fv(projectionUniform, false, projectionMatrix);

    shouldInitBuffers = false;
  }