//Standard lib #include #include #include #include //Third party #include "raylib.h" //Our own files #include "constants.h" #include "programstate.h" #include "drawhelper.h" #include "draw.h" //Drawing Routines #include "draw_xpitches_yports.h" #include "draw_xports_ypitches.h" #include "draw_port_grids.h" #include "draw_meterbridge.h" #include "draw_activity.h" //Effect Routines #include "effect_starfield.h" #define GLSL_VERSION 330 extern ProgramState programState; Effect effects[NR_OF_EFFECTS] = { { false, "Starfield", false, 1.0f, 1, 2, effect_starfield}, { false, "Snow Fall", false, 1.0f, 1, 3, effect_starfield}, { false, "Falling Leafs", false, 1.0f, 1, 4, effect_starfield}, { false, "Rain", false, 1.0f, 1, 5, effect_starfield}, { false, "Embers", false, 1.0f, 1, 5, effect_starfield}, }; //This needs to be manually synced to gui.c combox //This order is permanent. No re-ordering after the first release! //The save file and the GUI depend on it. void (*drawFunctions[5])() = { draw_xpitches_yports, draw_xports_ypitches, draw_port_grids, draw_meterbridge, draw_activity, }; static Texture2D backgroundTexture; static RenderTexture2D renderTarget; static Shader shader; void loadBackgroundImage(char * path, bool newImage) { if (programState.nsm) { char * temporaryAbsolutePath = malloc (sizeof(char) * 4096); //4096 is the max path length in linux snprintf(temporaryAbsolutePath, (sizeof(char) * 4096), "%s/%s", programState.nsmDirectory, "background.png"); if (newImage) { //User clicked on the GUI button and chose a file unlink(temporaryAbsolutePath); symlink(path, temporaryAbsolutePath); //source-file, link } programState.pathBackgroundImage = "background.png"; backgroundTexture = LoadTexture(temporaryAbsolutePath); free(temporaryAbsolutePath); } else { programState.pathBackgroundImage = path; backgroundTexture = LoadTexture(programState.pathBackgroundImage); } } void init_draw() { renderTarget = LoadRenderTexture(GetScreenWidth(), GetScreenHeight()); shader = LoadShader(0, FormatText("glsl%i/bloom.fs", GLSL_VERSION)); //vs file, fs file } void mainLoop_draw(Note *allGUINotes) { if (IsWindowResized()) { //printf("Window resized to: %i x %i\n", GetScreenWidth(), GetScreenHeight()); programState.guiRedrawNeeded = true; } //Drawing Layers from bottom to top: //Background Image (or plain color) //Background Sprites (internal Z-Order = Y) //Background Effects (e.g. Starfield) //Main Visualization (Notes) //Foreground Sprites (internal Z-Order = Y) //Foreground Effects (e.g. Rain) if (programState.showBackgroundImageLayer) { //void DrawTexture(Texture2D texture, int posX, int posY, Color tint); //Draw centered but not scaled. DrawTexture(backgroundTexture, GetScreenWidth()/2-backgroundTexture.width/2, GetScreenHeight()/2-backgroundTexture.height/2, WHITE); } //BeginTextureMode(renderTarget); // Enable drawing to texture //ClearBackground(BLACK); //Texture background //Background Effects Pass if (programState.showEffectLayer) { for (int i=0; i