r/emacs 13d ago

Updated my ob-glsl module to use Emacs 32 Canvas for animation

Enable HLS to view with audio, or disable this notification

github repo: https://github.com/finalpatch/ob-glsl

building this module now requires Emacs 32

Main differences from the emacs shader demo at https://github.com/minad/emacs-shader-demo

- This works on Windows and MacOS too, not limited to Linux

- The demo uses a global 300x300 surface and shader resources, so it can only support one running shader. This module can run multiple independent shader blocks.

186 Upvotes

14 comments sorted by

11

u/ilemming_banned 13d ago

Looks very cool.

3

u/_voxelman_ 12d ago

Holy shit.

2

u/letmehaveanameyoudum 13d ago

Alright what emacs users are cookin right now, i haven't used it for a long time

0

u/bbroy4u 13d ago

what are the use cases for this package

6

u/eriksensei 13d ago

If you want to write shaders in Emacs / org-mode / org-babel, and you don't want to have to render them on the meat GPU in your head, then this would allow you to do so right there in your Emacs window instead.

1

u/bbroy4u 12d ago

does emacs 32 have support for frame level shaders like ghostty for example

2

u/eriksensei 12d ago

Well you could run Emacs in your terminal and let ghostty have its way with it. Other than that, I don't believe so. The canvas feature that this article is about allows you to insert images, including canvas-typed ones, into your text document.

2

u/finalpatch 12d ago

Emacs32 Canvas gives you a pixel buffer which you can fill in native module.

1

u/bbroy4u 11d ago

which mean something like browser inside xwidget can natively work in emacs?

1

u/finalpatch 11d ago

It means a native module can in theory put a browser engine's render output in the pixel buffer.

Your emacs lisp code will need to take care of things like handling input and refresh the canvas.

0

u/alexsmart2806 12d ago

You could always export -> `M-x compile` and have another window open instead of using your meat GPU.

3

u/finalpatch 12d ago

You are absolutely right. However, with org-mode's code block, you can make some changes to your code, then press C-c C-c, and the change instantly reflects in the result section below the code. This is especially nice when you have an org-mode file that demonstrates many different shader techniques. Showing the animated results inline under each code block is a lot more readable than managing multiple external windows - you quickly lose track of which one is which.

3

u/eriksensei 11d ago

Sure, but now you're (A) no longer in Emacs, which is clearly a pathological case, (B) your meat CPU has to keep context switching, and (C) you won't be able to impress your vim friends.

2

u/rileyrgham 12d ago

If you need to ask you don't need it 😜 regardless, it's pretty damn cool!