Skip to content

Commit

Permalink
fix up viewer_texture
Browse files Browse the repository at this point in the history
  • Loading branch information
zeffii committed Aug 15, 2023
1 parent f7de2e4 commit 61ca1e3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
12 changes: 5 additions & 7 deletions nodes/viz/viewer_texture.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import bpy
import gpu
import bgl

from bpy.props import (
FloatProperty, EnumProperty, StringProperty, BoolProperty, IntProperty
Expand All @@ -25,6 +24,7 @@
from sverchok.node_tree import SverchCustomTreeNode
from sverchok.ui import bgl_callback_nodeview as nvBGL2
from sverchok.ui import sv_image as svIMG
from sverchok.utils.modules.drawing_abstractions import drawing

# shared stuff between implementations
from sverchok.utils.sv_texture_utils import generate_batch_shader
Expand Down Expand Up @@ -264,8 +264,8 @@ def sv_init(self, context):
def delete_texture(self):
n_id = node_id(self)
if n_id in self.texture:
names = bgl.Buffer(bgl.GL_INT, 1, [self.texture[n_id]])
bgl.glDeleteTextures(1, names)
names = drawing.get_buffer(self.texture[n_id])
drawing.delete_texture(names)

def process(self):
if not self.inputs['Float'].is_linked:
Expand Down Expand Up @@ -295,12 +295,10 @@ def process(self):
if self.activate:
texture = self.get_buffer()
width, height = self.texture_width_height
# x, y = self.xy_offset
gl_color_constant = gl_color_dict.get(self.color_mode)


name = bgl.Buffer(bgl.GL_INT, 1)
bgl.glGenTextures(1, name)
name = drawing.new_buffer_texture()
drawing.generate_textures(name)
self.texture[n_id] = name[0]
init_texture(width, height, name[0], texture, gl_color_constant)

Expand Down
5 changes: 4 additions & 1 deletion utils/modules/drawing_abstractions.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@
drawing.enable_blendmode = pass
drawing.disable_blendmode = pass
drawing.new_buffer_texture = pass
drawing.get_buffer = pass
drawing.bind_texture_2d = pass
drawing.init_complex_texture = pass
drawing.generate_textures = pass

drawing.delete_texture = pass
else:
# from sverchok.utils.modules.drawing_abstractions import drawing

Expand All @@ -46,8 +47,10 @@
drawing.enable_blendmode = lambda: bgl.glEnable(bgl.GL_BLEND)
drawing.disable_blendmode = lambda: bgl.glDisable(bgl.GL_BLEND)
drawing.new_buffer_texture = lambda: bgl.Buffer(bgl.GL_INT, 1)
drawing.get_buffer = lambda indexed_buffer: bgl.Buffer(bgl.GL_INT, 1, indexed_buffer)
drawing.new_buffer_texture_sized = lambda size, data: bgl.Buffer(bgl.GL_FLOAT, size, data)
drawing.bind_texture_2d = lambda texture: bgl.glBindTexture(bgl.GL_TEXTURE_2D, texture)
drawing.delete_texture = lambda texture: bgl.glDeleteTextures(1, texture)

def initialize_complex_texture(width, height, texname, texture, data, format):
if format == 'RGBA':
Expand Down

0 comments on commit 61ca1e3

Please sign in to comment.