瀏覽代碼

Merge pull request #10127 from Chaosus/shader_pp_error

Add `#error` shader preprocessor directive description
Max Hilbrunner 9 月之前
父節點
當前提交
126943908c
共有 1 個文件被更改,包括 18 次插入0 次删除
  1. 18 0
      tutorials/shaders/shader_reference/shader_preprocessor.rst

+ 18 - 0
tutorials/shaders/shader_reference/shader_preprocessor.rst

@@ -355,6 +355,24 @@ Defines the optional block which is included when the previously defined ``#if``
 
 
 Used as terminator for the ``#if``, ``#ifdef``, ``#ifndef`` or subsequent ``#else`` directives.
 Used as terminator for the ``#if``, ``#ifdef``, ``#ifndef`` or subsequent ``#else`` directives.
 
 
+#error
+^^^^^^
+
+**Syntax:** ``#error <message>``
+
+The ``#error`` directive forces the preprocessor to emit an error with optional message.
+For example, it's useful when used within ``#if`` block to provide a strict limitation of the
+defined value.
+
+.. code-block:: glsl
+
+    #define MAX_LOD 3
+    #define LOD 4
+
+    #if LOD > MAX_LOD
+    #error LOD exceeds MAX_LOD
+    #endif
+
 #include
 #include
 ^^^^^^^^
 ^^^^^^^^