qml-glsl-coder icon indicating copy to clipboard operation
qml-glsl-coder copied to clipboard

live editor of GLSL fragment shaders based on Qt / QML

QML GLSL Coder v1.2.0

project URL: https://github.com/neolit123/qml-glsl-coder


INFORMATION

"QML GLSL Coder" is a live editor of GLSL fragment shaders based on Qt / QML.

the project is inspired by the following tools:

  • ShaderToy (by IQ)
  • Quint (by Andrew Baldwin)
  • GLSL-Sandbox (by various contributors)

a couple of years ago i saw that easy, on-the-spot GLSL shader compilation was possible with Qt / QML in the Quint project, but it had some issues and was not very usable. in the meantime, i was playing with writing some effects in the other listed tools which are WebGL based.

this project is not a port of Quint but rather a written from scratch, fully functional editor that i started writing a while back.

public domain license - see the file LICENSE!


SCREENSHOTS

https://tinyurl.com/ycl39h8p https://tinyurl.com/y8d7rf6j https://tinyurl.com/y9j9hlc8 https://tinyurl.com/y6vfpc42


WHAT WORKS

only tested on Win32 desktop! press F1 for the help screen and a list of keyboard shortcuts.

*) has a pretty usable text editor

  • the editor is defined in qml/Editor.qml
  • the editor can be toggled with F4
  • everything that QML's TextEdit has, this editor has as well
  • mouse wheel and page up/down support
  • shows the current line and compilation errors
  • has a syntax highlighter defined in cpp/highlighter.cpp/.h

*) loading/saving .glsl files

  • F7/F8 open the file load/save dialogs

*) loading of a single image that can be used as a texture

  • controlled with F6
  • see shaders/greyscaleTexture.glsl for an example

*) dynamic quality and interpolation

  • controlled with F9, F10, F11

*) toggleable FPS counter and mouse cursor

  • controlled with F2, F3

*) fullscreen support

  • controlled with F12

WHAT DOESN'T WORK (THAT WELL)

here are some issues which are caused by Qt / QML bugs or missing features:

*) Qt 5.5 has some sort of a bug in QQuickShaderEffect that prevents on-the-spot changes of the .fragmentShader property. this forced me to write a custom QQuickItem named ShaderItem which is a stripped down QQuickShaderEffect replacement.

*) auto-compile-on-edit actually works quite well on the ShaderItem side, but the onTextChanged() signal from TextEdit is a bit sporadic. therefore, i have disabled auto-compile-on-edit and you have to press F5 to recompile. at some point this could become an option.

*) on Win32 the file open/save dialogs don't show in fullscreen unless the UI is clicked. to solve the issue the file dialogs are opened in window-mode and when closed, the original mode (e.g. fullscreen) is restored.

*) for some reason, when the application window is open it makes certain tools on Win32 sluggish, while the CPU remains almost IDLE.

*) lines with bold text have more height than lines without bold text, which breaks the estimation to fit exactly N lines of text in the editor visible area and the last line may be cut. QML's TextEdit has no easy means to set a fixed line height which is not very convenient.


QMAKE VS CMAKE

cmake is more potent, while qmake is easier for a fast project setup. period. this project is qmake based.

hopefully qmake will not be deprecated soon.


DEPLOYMENT SIZE

40MB on Win32 is a bit too much but that's how Qt works. if i wrote the same in SDL and some sort of a simplified widgets toolkit it could have been in the lines of 10MB but it might have taken more time.


BUILDING

install the latest Qt version cd qmake make


PRE-BUILD BINARIES

qml-glsl-coder-1.0.0-win32-qt5.5.0.zip: https://tinyurl.com/y8h5c22h qml-glsl-coder-1.2.0-win32-qt5.5.1.zip: https://tinyurl.com/y9om8f6b


EOF