Hi All,
I’ve been working on this for a few days now and not getting any closer to a result.
i’m trying to use sdl to make a overlay type display on top of the raspberry pi camera.
however no matter what i try i can’t seem to get it to work i always end up with a black background that is over writing the display under it.
i know it can be done as I’ve got a proto type mocked up using the dispman hello font example.
the code i’m trying is
Code:
#include <stdio.h>
#include “SDL.h”
#include “SDL_image.h”
int main(int argc, char **argv)
{
if (SDL_Init(SDL_INIT_VIDEO) !=0) {
printf(“Error SDL_Init %s \n”,SDL_GetError());
}
SDL_Window *window;
window = SDL_CreateWindow(
“Test”,
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
640,
480,
SDL_WINDOW_OPENGL
);
if (window == NULL) {
printf(“Error with Window %s \n”,SDL_GetError());
}
SDL_Renderer *ren;
ren = SDL_CreateRenderer(window,-1,SDL_RENDERER_ACCELERATED |
SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE);
SDL_Texture *tex;
tex = SDL_CreateTexture(ren,SDL_PIXELFORMAT_ARGB8888,
SDL_TEXTUREACCESS_TARGET,500,500);
if (tex == NULL) {
printf(“textur error %s \n”,SDL_GetError());
}
SDL_SetTextureBlendMode(tex,SDL_BLENDMODE_BLEND);
SDL_SetRenderTarget(ren,tex);
SDL_SetRenderDrawColor(ren,0,0,0,0);
SDL_RenderClear(ren);
SDL_SetRenderTarget(ren,NULL);
SDL_Rect rect;
rect.x=0;
rect.y=0;
rect.h=300;
rect.w=300;
SDL_SetRenderDrawColor(ren,255,255,255,255);
SDL_RenderFillRect(ren,&rect);
SDL_RenderPresent(ren);
SDL_Delay(3000);
return 0;
}
the only way i’ve been able to get close is to modify the following in the source code.
Code:
/* Disable alpha, otherwise the app looks composed with whatever dispman is showing (X11, console,etc) */
dispman_alpha.flags = DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS;
dispman_alpha.opacity = 100;
dispman_alpha.mask = 0;
this works but makes the entire window transparent including anything i draw onto it.
i’m using arch Linux with a PKGBUILD version of sdl that disables opengl and makes SDL2 use the dispmanx backend.
can anyone point me in the right direction with this???
Thanks
Matthew