añadida funcionalid para poner texto

main
fanta 2 weeks ago
parent b8994ee780
commit db7e5f2a9a

@ -7,7 +7,7 @@ fanta <fanta@56k.es> 2026
Dependencias: Dependencias:
<pre> <pre>
apt-get install git gcc make libxmp-dev libsdl2-dev libsdl2-image-dev apt-get install git gcc make libxmp-dev libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev
</pre> </pre>
Clonar: Clonar:

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -1,6 +1,6 @@
CC := gcc CC := gcc
CFLAGS := -Wall CFLAGS := -Wall
LINKER_FLAGS = `sdl2-config --cflags --libs` -lxmp -lSDL2_image LINKER_FLAGS = `sdl2-config --cflags --libs` -lxmp -lSDL2_image -lSDL2_ttf
test: test:
make clean make clean

@ -2,9 +2,8 @@
#include <xmp.h> #include <xmp.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <SDL_image.h> #include <SDL_image.h>
#include <SDL_ttf.h>
// Fanta <fanta@56k.es> 2026 // Fanta <fanta@56k.es> 2026
// Presentator 0.2 // Presentator 0.2
@ -35,6 +34,7 @@ int transition_active = 0;
// Functions // Functions
int createWindow(void){ int createWindow(void){
SDL_Init(SDL_INIT_VIDEO); SDL_Init(SDL_INIT_VIDEO);
TTF_Init();
window = SDL_CreateWindow(windowTitle,SDL_WINDOWPOS_UNDEFINED,SDL_WINDOWPOS_UNDEFINED,windowWidth,windowHeight,SDL_WINDOW_FULLSCREEN); window = SDL_CreateWindow(windowTitle,SDL_WINDOWPOS_UNDEFINED,SDL_WINDOWPOS_UNDEFINED,windowWidth,windowHeight,SDL_WINDOW_FULLSCREEN);
render = SDL_CreateRenderer(window, -1, 0); render = SDL_CreateRenderer(window, -1, 0);
return 0; return 0;
@ -90,50 +90,82 @@ int loadSlide(int nslide){
size_t len = 0; size_t len = 0;
int nline = 1; int nline = 1;
ssize_t read; ssize_t read;
int slideType; char * slideText;
char * slideName; char * slideName;
int slideTextSize;
int slideTextRed;
int slideTextGreen;
int slideTextBlue;
int slideTextX;
int slideTextY;
char * slideFont;
fp = fopen(slidesIndex, "r"); fp = fopen(slidesIndex, "r");
while ((read = getline(&line, &len, fp)) != -1) { while ((read = getline(&line, &len, fp)) != -1) {
if (nslide == nline){ if (nslide == nline){
actualSlide = line; actualSlide = line;
char *token = strtok(actualSlide, ";"); char *token = strtok(actualSlide, ";");
int e; int e;
for (e = 0; e < 2; e++) { for (e = 0; e < 9; e++) {
if (e == 0){ slideType = atoi(token); } if (e == 0){ slideName = token; }
if (e == 1){ slideName = token; slideName[ strlen(slideName) - 1 ] = '\0';} if (e == 1){ slideTextSize = atoi(token); }
if (e == 2){ slideTextRed = atoi(token); }
if (e == 3){ slideTextGreen = atoi(token); }
if (e == 4){ slideTextBlue = atoi(token); }
if (e == 5){ slideTextX = atoi(token); }
if (e == 6){ slideTextY = atoi(token); }
if (e == 7){ slideFont = token; }
if (e == 8){ slideText = token; slideText[ strlen(slideText) - 1 ] = '\0'; }
token = strtok(NULL, ";"); token = strtok(NULL, ";");
} }
printf("%i %s\n", slideType, slideName);
actualSlide[ strlen(actualSlide) - 1 ] = '\0';
SDL_Rect textureSlideRect = { 0, 0, windowWidth, windowHeight }; SDL_Rect textureSlideRect = { 0, 0, windowWidth, windowHeight };
IMG_Init(IMG_INIT_PNG); IMG_Init(IMG_INIT_PNG);
if (slideType == 0){ textureSlide = IMG_LoadTexture(render, slideName); } // png printf("%s %s\n", slideName, slideText);
if (slideType == 1){ textureSlide = IMG_LoadTexture(render, slideName); } // gif incompleto ahora mismo pero ya detectado textureSlide = IMG_LoadTexture(render, slideName);
SDL_RenderCopy(render, textureSlide, NULL, &textureSlideRect); SDL_RenderCopy(render, textureSlide, NULL, &textureSlideRect);
TTF_Font* font = TTF_OpenFont(slideFont, slideTextSize);
SDL_Color textColor = {slideTextRed, slideTextGreen, slideTextBlue, 255};
SDL_Surface *textSurface = TTF_RenderText_Solid(font, slideText, textColor);
SDL_Texture *textTexture = SDL_CreateTextureFromSurface(render, textSurface);
SDL_Rect textRect = {slideTextX, slideTextY, textSurface->w, textSurface->h};
SDL_RenderCopy(render, textTexture, NULL, &textRect);
} }
nline = nline +1; nline = nline +1;
} }
fclose(fp); fclose(fp);
nline = nline - 1; nline = nline - 1;
if (line){ free(line); }; if (line){ free(line); };
return 0; return 0;
} }
int transition_BackToBlack(void){ int transition_BackToBlack(void){
SDL_SetRenderDrawBlendMode(render, SDL_BLENDMODE_BLEND); SDL_SetRenderDrawBlendMode(render, SDL_BLENDMODE_BLEND);
SDL_Rect barra = { 0, 0, windowWidth, windowHeight }; SDL_Rect barra = { 0, 0, windowWidth, windowHeight };
int z; int z;
for (z = 250; z > 0; z = z -10) { for (z = 250; z > 0; z = z -10) {
loadSlide(actualNSlide); loadSlide(actualNSlide);
refreshVolumeArea(iv); refreshVolumeArea(iv);
SDL_SetRenderDrawColor(render, 0, 0, 0, z); SDL_SetRenderDrawColor(render, 0, 0, 0, z);
SDL_RenderFillRect(render, &barra); SDL_RenderFillRect(render, &barra);
SDL_RenderPresent(render); SDL_RenderPresent(render);
} }
return 0;
}
int effect_enableTransition(void){ // red blink on the volume area box
SDL_SetRenderDrawBlendMode(render, SDL_BLENDMODE_BLEND);
int z;
for (z = 250; z > 0; z = z -10) {
loadSlide(actualNSlide);
refreshVolumeArea(iv);
SDL_Rect barra = { 913, 24, 94, 12 };
SDL_SetRenderDrawColor(render, 255, 0, 0, z);
SDL_RenderFillRect(render, &barra);
SDL_RenderPresent(render);
}
return 0; return 0;
} }
@ -158,7 +190,6 @@ int main(int argc, char ** argv) {
while (!quit) { while (!quit) {
SDL_WaitEvent(&evento); SDL_WaitEvent(&evento);
@ -234,9 +265,11 @@ int main(int argc, char ** argv) {
case SDLK_F1: case SDLK_F1:
if (transition_active == 0){ if (transition_active == 0){
transition_active = 1; transition_active = 1;
effect_enableTransition();
}else{ }else{
transition_active = 0; transition_active = 0;
} effect_enableTransition();
};
break; break;
} }
break; break;

@ -1,5 +1,5 @@
0;slides/slide-001.png slides/slide-000.png;24;97;101;106;250;725;fonts/Daydream DEMO.otf;Tunubesecamirio.com
0;slides/slide-002.png slides/slide-001.png;24;84;254;84;10;720;fonts/Daydream DEMO.otf;Hackeja La Terra En defensa dels territoris
0;slides/slide-003.png slides/slide-002.png;20;0;0;168;10;16;fonts/Daydream DEMO.otf;Hackeja La Terra En defensa dels territoris
0;slides/slide-004.png slides/slide-003.png;26;255;255;255;10;720;fonts/Daydream DEMO.otf;Hack The Earth In defense of territories
1;slides/slide-005.gif slides/slide-004.png;64;255;0;0;100;100;fonts/Lato-Black.ttf;

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 249 KiB

After

Width:  |  Height:  |  Size: 146 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 369 KiB

After

Width:  |  Height:  |  Size: 172 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 372 KiB

After

Width:  |  Height:  |  Size: 159 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 352 KiB

After

Width:  |  Height:  |  Size: 249 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 369 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 372 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 352 KiB

Loading…
Cancel
Save