-2
\$\begingroup\$

I have an issue with the SDL_BlitSurface... When I blit (SDL_BlitSurface) in a transparent (background) surface, it does not blits, actually I tried all the existants functions (SDL_DisplayFormat(Alpha), SDL_SetAlpha, SDL_FilLRect/SDL_ColorKey, per-pixel method) anything! The r/g/b/a mask are good. Here is the code:

SDL_Surface * surfed_texture =
SDL_CreateRGBSurface(SDL_SWSURFACE,surface_width,surface_height,32,
0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000);
Uint32 tormv = SDL_MapRGB(surfed_texture->format,255,0,255);
int possiblecolors[] = { 255,0,255,255,255,255 };
int in_pc = 0;
if(color.r == possiblecolors[0] && color.g == possiblecolors[1] && color.b == possiblecolors[2]){
in_pc=3;
}
SDL_FillRect(surfed_texture,NULL,SDL_MapRGB(surfed_texture
>format,possiblecolors[in_pc],possiblecolors[in_pc+1],possiblecolors[in_pc+2]));
SDL_SetColorKey(surfed_texture, SDL_SRCCOLORKEY, SDL_MapRGB(surfed_texture
>format,possiblecolors[in_pc],possiblecolors[in_pc+1],possiblecolors[in_pc+2]));
SDL_Surface * temporal = NULL;
for(int i=0;i<(int)buff_split.size();i++){
const char* c_text = buff_split.at(i).c_str();

temporal = TTF_RenderText_Blended(font,c_text,color);

int w_fo;
int h_fo;
TTF_SizeText(font,c_text,&w_fo,&h_fo);

SDL_Rect rct;
rct.y=i*lineSkip;

if(txt_align==ALIGN_LEFT){
    rct.x=0;
}else if(txt_align==ALIGN_CENTER){
    rct.x = surface_width/2 - w_fo/2;
}else if(txt_align==ALIGN_RIGHT){
    rct.x = surface_width - w_fo;
}

rct.w=0;
rct.h=0;

// Blit surface

SDL_BlitSurface(temporal,NULL,surfed_texture,&rct);

SDL_FreeSurface(temporal);
}
\$\endgroup\$
1
\$\begingroup\$

Have you tried rendering on a software surface. In my experience SDL2.0 only works with SDL_RENDERER_SOFTWARE not with SDL_RENDERER_ACCELERATED ( flags supplied to SDL_CreateRenderer).

Gijs

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.