<commit_before>//
// Copyright (c) 2011-2014 <NAME> <<EMAIL>>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

use ooc-math

import OpenGLES3/Quad
import OpenGLES3/NativeWindow
import OpenGLES3/Context
import OpenGLES3/X11Window

import Surface, GpuImage, GpuCanvas, GpuMonochrome, GpuBgra, GpuBgr, GpuMap

Window: class extends Surface {
  native: NativeWindow
  context: Context
  ratio: Float

  monochromeToBgra: GpuMapMonochromeToBgra
  bgrToBgra: GpuMapBgrToBgra
  bgraToBgra: GpuMapBgra

  init: func (size: IntSize2D) {
    this size = size
    this ratio = (size width) as Float / (size height) as Float
  }

  _generate: func (size: IntSize2D, title: String) -> Bool {
    this native = X11Window create(size width, size height, title)
    this context = Context create(native)
    result: UInt = this context makeCurrent()
    this quad = Quad create(this ratio)
    monochromeToBgra = GpuMapMonochromeToBgra new()
    bgrToBgra = GpuMapBgrToBgra new()
    bgraToBgra = GpuMapBgra new()
    result == 1 && (this native != null) && (this context != null) && (this quad != null)
  }

  draw: func ~Monochrome (image: GpuMonochrome, transform: FloatTransform2D) {
    monochromeToBgra transform = transform
    monochromeToBgra ratio = this ratio
    this draw(image, monochromeToBgra)
  }

  draw: func ~Bgr (image: GpuBgr, transform: FloatTransform2D) {
    bgrToBgra transform = transform
    bgrToBgra ratio = this ratio
    this draw(image, bgrToBgra)
  }

  draw: func ~Bgra (image: GpuBgra, transform: FloatTransform2D) {
    bgraToBgra transform = transform
    bgraToBgra ratio = this ratio
    this draw(image, bgraToBgra)
  }

  draw: func ~canvas (canvas: GpuCanvas) {

  }

  clear: func {
    this native clear()
  }

  update: func {
    this context update()
  }

  create: static func (size: IntSize2D, title: String) -> This {
    result := Window new(size)
    (result _generate(size, title)) ? result : null
  }

}<commit_msg>Adapted Window to changed base class<commit_after>//
// Copyright (c) 2011-2014 <NAME> <<EMAIL>>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

use ooc-math

import OpenGLES3/Quad
import OpenGLES3/NativeWindow
import OpenGLES3/Context
import OpenGLES3/X11Window

import Surface, GpuImage, GpuCanvas, GpuMonochrome, GpuBgra, GpuBgr, GpuMap

Window: class extends Surface {
  native: NativeWindow
  context: Context

  monochromeToBgra: GpuMapMonochromeToBgra
  bgrToBgra: GpuMapBgrToBgra
  bgraToBgra: GpuMapBgra

  init: func (size: IntSize2D) {
    this size = size
    this ratio = (size width) as Float / (size height) as Float
  }
  _generate: func (size: IntSize2D, title: String) -> Bool {
    this native = X11Window create(size width, size height, title)
    this context = Context create(native)
    result: UInt = this context makeCurrent()
    this quad = Quad create(this ratio)
    this monochromeToBgra = GpuMapMonochromeToBgra new()
    this bgrToBgra = GpuMapBgrToBgra new()
    this bgraToBgra = GpuMapBgra new()
    result == 1 && (this native != null) && (this context != null) && (this quad != null)
  }
  draw: func ~Monochrome (image: GpuMonochrome, transform: FloatTransform2D) {
    monochromeToBgra transform = transform
    monochromeToBgra ratio = this ratio
    this draw(image, monochromeToBgra)
  }
  draw: func ~Bgr (image: GpuBgr, transform: FloatTransform2D) {
    bgrToBgra transform = transform
    bgrToBgra ratio = this ratio
    this draw(image, bgrToBgra)
  }
  draw: func ~Bgra (image: GpuBgra, transform: FloatTransform2D) {
    bgraToBgra transform = transform
    bgraToBgra ratio = this ratio
    this draw(image, bgraToBgra)
  }
  bind: func {
    this native bind()
  }
  clear: func {
    this native clear()
  }
  update: func {
    this context swapBuffers()
  }
  create: static func (size: IntSize2D, title: String) -> This {
    result := Window new(size)
    (result _generate(size, title)) ? result : null
  }
}
{'fraction_non_alphanumeric': 0.0893237744623135, 'fraction_numerical': 0.009300523154427436, 'mean_word_length': 3.629596412556054, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1650500', 'n_tokens_mistral': 1661, 'n_tokens_neox': 1614, 'n_words': 586}