00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00027
#ifndef SHSYNTAX_HPP
00028
#define SHSYNTAX_HPP
00029
00030
#include "ShDllExport.hpp"
00031
#include "ShProgram.hpp"
00032
#include "ShUtility.hpp"
00033
00038
00039
00040
#define SH_PUSH_ARG_QUEUE ::SH::ShContext::current()->parsing()->tokenizer.pushArgQueue()
00041
#define SH_PUSH_ARG ::SH::ShContext::current()->parsing()->tokenizer.pushArg()
00042
#define SH_PROCESS_ARG(arg) ::SH::ShContext::current()->parsing()->tokenizer.processArg(arg)
00043
00044
00046
00047
00053 #define SH_BEGIN_PROGRAM(target) ::SH::shBeginShader(target);
00054
00062 #define SH_END_PROGRAM ::SH::shEndShader();
00063
00064
00065
#define SH_END SH_END_PROGRAM
00066
00067
#define SH_BEGIN_VERTEX_PROGRAM ::SH::shBeginShader("gpu:vertex");
00068
#define SH_BEGIN_FRAGMENT_PROGRAM ::SH::shBeginShader("gpu:fragment");
00069
00071
00072
00077 #define SH_IF(cond) ::SH::shIf(SH_PUSH_ARG_QUEUE && SH_PUSH_ARG && SH_PROCESS_ARG(cond)); {{
00078
00083 #define SH_ELSE }} ::SH::shElse(); {{
00084
00089 #define SH_ENDIF ::SH::shEndIf();}}
00090
00091
00093
00094
00098 #define SH_WHILE(cond) ::SH::shWhile(SH_PUSH_ARG_QUEUE && SH_PUSH_ARG && SH_PROCESS_ARG(cond)); {{{
00099
00103 #define SH_ENDWHILE ::SH::shEndWhile();}}}
00104
00105
00107
00108
00112 #define SH_DO ::SH::shDo(); {{{{
00113
00117 #define SH_UNTIL(cond) ::SH::shUntil(SH_PUSH_ARG_QUEUE && SH_PUSH_ARG && SH_PROCESS_ARG(cond));}}}}
00118
00119
00121
00122
00128
00129 #define SH_FOR(init,cond,update) ::SH::shFor(SH_PUSH_ARG_QUEUE \
00130
&& SH_PUSH_ARG && SH_PROCESS_ARG(init) \
00131
&& SH_PUSH_ARG && SH_PROCESS_ARG(cond) \
00132
&& SH_PUSH_ARG && SH_PROCESS_ARG(update)); {{{{{
00133
00137 #define SH_ENDFOR ::SH::shEndFor();}}}}}
00138
00139
00141
00142
00149 #define SH_BREAK ::SH::shBreak();
00150
00157 #define SH_CONTINUE ::SH::shBreak();
00158
00159
00161
00162
00168 #define SH_NAME(var) do { var.name( # var); } while (0)
00169
00179 #define SH_DECL(var) var; var.name( # var ); ::SH::ShIgnore() & var
00180
00189 #define SH_NAMEDECL(var, varName) var; var.name( varName ); ::SH::ShIgnore() & var
00190
00191
00192
namespace SH {
00193
00195 SH_DLLEXPORT
00196 ShProgram shBeginShader(
const std::string& kind =
"");
00198 SH_DLLEXPORT
00199
void shEndShader();
00200
00202 SH_DLLEXPORT
00203
void shCompile(ShProgram& prg);
00205 SH_DLLEXPORT
00206
void shCompile(ShProgram& prg,
const std::string& target);
00207
00209 SH_DLLEXPORT
00210
void shCompileShader(ShProgram& prg);
00212 SH_DLLEXPORT
00213
void shCompileShader(ShProgram& prg,
const std::string& target);
00214
00216 SH_DLLEXPORT
00217
void shBind(ShProgram& prg);
00219 SH_DLLEXPORT
00220
void shBind(
const std::string& target, ShProgram& shader);
00221
00223 SH_DLLEXPORT
00224
void shBindShader(ShProgram& shader);
00226 SH_DLLEXPORT
00227
void shBindShader(
const std::string& target, ShProgram& shader);
00228
00230 SH_DLLEXPORT
00231
bool shSetBackend(
const std::string& name);
00232
00233
00239 SH_DLLEXPORT
00240
void shInit();
00241
00243 SH_DLLEXPORT
00244
void shIf(
bool);
00246 SH_DLLEXPORT
00247
void shElse();
00249 SH_DLLEXPORT
00250
void shEndIf();
00251
00253 SH_DLLEXPORT
00254
void shWhile(
bool);
00256 SH_DLLEXPORT
00257
void shEndWhile();
00258
00260 SH_DLLEXPORT
00261
void shDo();
00263 SH_DLLEXPORT
00264
void shUntil(
bool);
00265
00267 SH_DLLEXPORT
00268
void shFor(
bool);
00270 SH_DLLEXPORT
00271
void shEndFor();
00272
00274 SH_DLLEXPORT
00275
void shBreak();
00277 SH_DLLEXPORT
00278
void shContinue();
00279
00280 }
00281
00282
#endif