big refactor: i see i need header files

This commit is contained in:
huaqo-games
2025-11-02 11:23:26 +01:00
parent 297a835780
commit c1a2448126
38 changed files with 582 additions and 560 deletions
+36
View File
@@ -0,0 +1,36 @@
#include "engine.h"
PostProcessing CreatePostFX(const char* shaderPath){
PostProcessing postFX = {0};
postFX.shader = LoadShader(NULL, shaderPath);
if (postFX.shader.id == 0) {
TraceLog(LOG_ERROR, "Failed to load shader: %s", shaderPath);
return postFX;
}
postFX.strength = 0.0f;
postFX.resolutionLoc = GetShaderLocation(postFX.shader, "resolution");
postFX.strengthLoc = GetShaderLocation(postFX.shader, "strength");
Vector2 resolution = { (float)GetScreenWidth(), (float)GetScreenHeight() };
SetShaderValue(postFX.shader, postFX.resolutionLoc, &resolution, SHADER_UNIFORM_VEC2);
return postFX;
}
void UpdatePostFX(PostProcessing *postFX){
if (postFX->shader.id == 0) return;
SetShaderValue(postFX->shader, postFX->strengthLoc, &postFX->strength, SHADER_UNIFORM_FLOAT);
Vector2 resolution = { (float)GetScreenWidth(), (float)GetScreenHeight() };
SetShaderValue(postFX->shader, postFX->resolutionLoc, &resolution, SHADER_UNIFORM_VEC2);
}
void RenderPostFX(PostProcessing *postFX, RenderTexture2D *target){
BeginShaderMode(postFX->shader);
DrawTextureRec(target->texture, (Rectangle){ 0, 0, target->texture.width, -target->texture.height }, (Vector2){ 0, 0 }, WHITE);
EndShaderMode();
}
void UnloadPostFX(PostProcessing *postFX){
if (postFX->shader.id == 0) return;
UnloadShader(postFX->shader);
}