<commit_before># -*- coding: utf-8 -*-
from __future__ import absolute_import

import OpenGL.GL as gl

import imgui
import ctypes


class BaseOpenGLRenderer(object):
    def __init__(self):
        imgui.create_context()
        self.io = imgui.get_io()

        self._font_texture = None

        self.io.delta_time = 1.0 / 60.0

        self._create_device_objects()
        self.refresh_font_texture()

        # todo: add option to set new_frame callback/implementation
        #self.io.render_callback = self.render

    def render(self, draw_data):
        raise NotImplementedError

    def refresh_font_texture(self):
        raise NotImplementedError

    def _create_device_objects(self):
        raise NotImplementedError

    def _invalidate_device_objects(self):
        raise NotImplementedError

    def shutdown(self):
        imgui.destroy_context()
        self._invalidate_device_objects()
        #imgui.shutdown()


class ProgrammablePipelineRenderer(BaseOpenGLRenderer):<commit_msg>Bugfix: Memory leak / modify after free. Ensure we invalidate_device_objects() *before* calling destroy_context()<commit_after># -*- coding: utf-8 -*-
from __future__ import absolute_import

import OpenGL.GL as gl

import imgui
import ctypes


class BaseOpenGLRenderer(object):
    def __init__(self):
        imgui.create_context()
        self.io = imgui.get_io()

        self._font_texture = None

        self.io.delta_time = 1.0 / 60.0

        self._create_device_objects()
        self.refresh_font_texture()

        # todo: add option to set new_frame callback/implementation
        #self.io.render_callback = self.render

    def render(self, draw_data):
        raise NotImplementedError

    def refresh_font_texture(self):
        raise NotImplementedError

    def _create_device_objects(self):
        raise NotImplementedError

    def _invalidate_device_objects(self):
        raise NotImplementedError

    def shutdown(self):
        self._invalidate_device_objects()
        imgui.destroy_context()


class ProgrammablePipelineRenderer(BaseOpenGLRenderer):
{'fraction_non_alphanumeric': 0.07732949087415947, 'fraction_numerical': 0.005763688760806916, 'mean_word_length': 3.092337917485265, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '5910239', 'n_tokens_mistral': 617, 'n_tokens_neox': 582, 'n_words': 133}