-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GUI, background fixes, further octane work, image tools
- Loading branch information
Showing
10 changed files
with
309 additions
and
46 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import bpy, blf, bgl, os, gpu | ||
from gpu_extras.batch import batch_for_shader | ||
|
||
class ViewportDraw: | ||
|
||
def __init__(self, context, text): | ||
|
||
bakefile = "TLM_Overlay.png" | ||
scriptDir = os.path.dirname(os.path.realpath(__file__)) | ||
bakefile_path = os.path.abspath(os.path.join(scriptDir, '..', '..', 'assets/' + bakefile)) | ||
|
||
bpy.ops.image.open(filepath=bakefile_path) | ||
|
||
#print("Self path: " + bakefile_path) | ||
|
||
image_name = "TLM_Overlay.png" | ||
|
||
image = bpy.data.images[image_name] | ||
|
||
x = 15 | ||
y = 15 | ||
w = 400 | ||
h = 200 | ||
|
||
self.shader = gpu.shader.from_builtin('2D_IMAGE') | ||
self.batch = batch_for_shader( | ||
self.shader, 'TRI_FAN', | ||
{ | ||
"pos": ((x, y), (x+w, y), (x+w, y+h), (x, y+h)), | ||
"texCoord": ((0, 0), (1, 0), (1, 1), (0, 1)), | ||
}, | ||
) | ||
|
||
if image.gl_load(): | ||
raise Exception() | ||
|
||
self.text = text | ||
self.image = image | ||
#self.handle = bpy.types.SpaceView3D.draw_handler_add(self.draw_text_callback, (context,), 'WINDOW', 'POST_PIXEL') | ||
self.handle2 = bpy.types.SpaceView3D.draw_handler_add(self.draw_image_callback, (context,), 'WINDOW', 'POST_PIXEL') | ||
|
||
def draw_text_callback(self, context): | ||
|
||
font_id = 0 | ||
blf.position(font_id, 15, 15, 0) | ||
blf.size(font_id, 20, 72) | ||
blf.draw(font_id, "%s" % (self.text)) | ||
|
||
def draw_image_callback(self, context): | ||
|
||
bgl.glEnable(bgl.GL_BLEND) | ||
bgl.glActiveTexture(bgl.GL_TEXTURE0) | ||
bgl.glBindTexture(bgl.GL_TEXTURE_2D, self.image.bindcode) | ||
|
||
self.shader.bind() | ||
self.shader.uniform_int("image", 0) | ||
self.batch.draw(self.shader) | ||
bgl.glDisable(bgl.GL_BLEND) | ||
|
||
def update_text(self, text): | ||
|
||
self.text = text | ||
|
||
def remove_handle(self): | ||
#bpy.types.SpaceView3D.draw_handler_remove(self.handle, 'WINDOW') | ||
bpy.types.SpaceView3D.draw_handler_remove(self.handle2, 'WINDOW') |
Oops, something went wrong.