, 내가 만들고 방법 텍스쳐 렌더링 :SDL 2.0 확대 텍스처
typedef struct{
SDL_Rect pos;
SDL_Texture* texture;
int hovered;
} button;
button getButton(int x, int y, char * label, TTF_Font* font, SDL_Color color){
button btn;
btn.hovered = false;
btn.pos.x = x;
btn.pos.y = y;
SDL_Surface* surface = TTF_RenderText_Solid(font, label, color);
btn.pos.w = surface->w;
btn.pos.h = surface->h;
btn.texture = SDL_CreateTextureFromSurface(renderer, surface);
SDL_FreeSurface(surface);
return btn;
}
void drawButton(button btn){
SDL_RenderCopyEx(renderer, btn.texture, NULL, &btn.pos, 0, NULL, SDL_FLIP_NONE);
if(btn.hovered){
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 0x00);
SDL_RenderDrawRect(renderer, &btn.pos);
}
문제는 내가 크기 레이블 중 하나에 해당 질감을 얻을입니다. 텍스처 픽셀 크기를 늘리지 않고 늘릴 수 있습니다. 즉, 텍스처 픽셀의 측면에 빈 공간을 추가하려면 어떻게해야합니까? 사각형의 변화의 크기,
지금까지 시도한 것은 무엇입니까? 어떤 버전의 SDL? 그리고 단추를 렌더링하는 코드는 어디에 있습니까? –
@ E_net4 편집 된 질문은 렌더링과 ver 모두를 나타냅니다. SDL의 어떤 아이디어로도 나올 수 없어서 아무 것도 시도하지 않았습니다. – osamurai