diff options
author | Fox Caminiti <fox@foxcam.net> | 2022-12-16 20:16:43 -0500 |
---|---|---|
committer | Fox Caminiti <fox@foxcam.net> | 2022-12-16 20:16:43 -0500 |
commit | bedd6906eabdd513042d6a178d4dc56a3a41d1d3 (patch) | |
tree | 2bcbd3e46ae61e583707a2ccc5b3f5cfeacb61a8 /src/effects_constructors.cpp | |
parent | cdb9e1f7240cb0716b7d99df5e1fd7c3fc3407a8 (diff) |
v3, file/build organization
Diffstat (limited to 'src/effects_constructors.cpp')
-rw-r--r-- | src/effects_constructors.cpp | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/src/effects_constructors.cpp b/src/effects_constructors.cpp new file mode 100644 index 0000000..406cb08 --- /dev/null +++ b/src/effects_constructors.cpp @@ -0,0 +1,117 @@ +static void +Effect_AddEntry(project_state *State, char *Name, char *ID, void (*func)(real32 *, int, int, int, void *, uint16), const char *GL_Shader, effect_display_type DisplayType = effect_display_type_standard) +{ + header_effect *Effect = &State->Effect[State->Playhead_Effect]; + Effect->Name = Name; + Effect->ID = ID; + Effect->func = func; + Effect->DisplayType = DisplayType; + Effect->PropertyStartIndex = State->Playhead_Property; + if (GL_Shader) { + Effect->GLShaderIndex = Effect_GL_InitShader(GL_Shader); + Effect->UseGL = true; + } +} + +static void +Effect_EndEntry(project_state *State) +{ + State->Playhead_Effect++; +} + +static void +Effect_AddProperty_Real(project_state *State, char *Name, real32 DefaultValue, real32 MinVal = -999999, real32 MaxVal = 999999, property_display_type DisplayType = property_display_type_standard) +{ + header_effect *Effect = &State->Effect[State->Playhead_Effect]; + Effect->Property_Count++; + header_property *Property = &State->Property[State->Playhead_Property++]; + Property->Name = Name; + Property->DefaultValue = DefaultValue; + Property->DisplayType = DisplayType; + Property->MinVal = MinVal; + Property->MaxVal = MaxVal; +} + +static void +Effect_AddProperty_Col(project_state *State, char *Name, v4 DefaultValue) +{ + Effect_AddProperty_Real(State, "r", DefaultValue.r, 0, 1, property_display_type_color); + Effect_AddProperty_Real(State, "g", DefaultValue.g, 0, 1, property_display_type_color); + Effect_AddProperty_Real(State, "b", DefaultValue.b, 0, 1, property_display_type_color); + Effect_AddProperty_Real(State, "a", DefaultValue.a, 0, 1, property_display_type_color); +} + +static void +Effect_AddProperty_Blendmode(project_state *State, char *Name, blend_mode DefaultValue) +{ + header_effect *Effect = &State->Effect[State->Playhead_Effect]; + Effect->Property_Count++; + header_property *Property = &State->Property[State->Playhead_Property++]; + Property->Name = Name; + Property->DefaultValue = DefaultValue; + Property->DisplayType = property_display_type_blendmode; +} + +static header_effect* +Effect_EntryFromID(project_state *State, char *ID) +{ + for (int i = 0; i < State->Playhead_Effect; i++) { + if (String_Compare(ID, State->Effect[i].ID, 8)) + return &State->Effect[i]; + } + Assert(0); + return &State->Effect[0]; +} + +static void +Effect_InitEntries(project_state *State) +{ + /* + */ + // Curves + /* + Effect_AddEntry(State, "Curves", "REALCRVS", &NULL, NULL, effect_display_type_curves); + Effect_AddProperty_Real(State, "Selected channel", 0.0f); + Effect_AddProperty_Real(State, "Number of points (main)", 2.0f); + Effect_AddProperty_Col(State, "Number of points (individual)", V4(2.0f)); + for (int i = 0; i < MAX_CURVESPOINTS*5/2; i++) { + v4 PointData = ((i % (MAX_CURVESPOINTS/2)) == 0) ? V4(0, 0, 1, 1) : V4(0); + Effect_AddProperty_Col(State, "PointData", PointData); + } + Effect_EndEntry(State); + */ + + // Solid color + Effect_AddEntry(State, "Solid color", "REALSCOL", &Effect_DrawColor, GLShader_SolidColor); + Effect_AddProperty_Col(State, "Color", V4(0.3f, 0.2f, 0.6f, 1.0f)); + Effect_EndEntry(State); + + // Gaussian blur + Effect_AddEntry(State, "Gaussian blur", "REALGBLR", &Effect_GaussianBlur, GLShader_GaussianBlur); + Effect_AddProperty_Real(State, "Radius", 1.0f, 0.0f, 200.0f); + Effect_EndEntry(State); + + // Curves + Effect_AddEntry(State, "Curves", "REALCRVS", &Effect_Curves, NULL, effect_display_type_curves); + for (int i = 0; i < MAX_PROPERTIES_PER_EFFECT; i++) { + Effect_AddProperty_Real(State, "point", 0.0f); + } + Effect_EndEntry(State); + + // Levels + Effect_AddEntry(State, "Levels", "REALLVLS", &Effect_Levels, GLShader_Levels, effect_display_type_levels); + // min/max is handled by the UI + Effect_AddProperty_Real(State, "All start point", 0.0f); + Effect_AddProperty_Real(State, "All mid point", 1.0f); + Effect_AddProperty_Real(State, "All end point", 1.0f); + Effect_AddProperty_Col(State, "Channel start point", V4(0.0f)); + Effect_AddProperty_Col(State, "Channel mid point", V4(1.0f)); + Effect_AddProperty_Col(State, "Channel end point", V4(1.0f)); + Effect_EndEntry(State); + /* + // Test gradient + Effect_AddEntry(State, "Test gradient", "REALTGRD", &Effect_TestGradient, NULL); + Effect_AddProperty_Col(State, "Color", V4(0.3f, 0.2f, 0.6f, 1.0f)); + Effect_EndEntry(State); + */ +} |