Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angled text? #15

Open
urosg80 opened this issue Feb 9, 2017 · 5 comments
Open

Angled text? #15

urosg80 opened this issue Feb 9, 2017 · 5 comments

Comments

@urosg80
Copy link

urosg80 commented Feb 9, 2017

I found this lib and it is superb, really nice working but is there any simple way to support text draw with angle?

@grimfang4
Copy link
Owner

Do you mean rotating the entire string to be drawn? Currently there's not a built-in way to do that and you'd need to draw to a temp target and then draw that rotated.

@urosg80
Copy link
Author

urosg80 commented Feb 9, 2017

Yes exactly, rotated ;) I guessed so much that it would have to be put into a temporary target and go from there.

Any ideas on how to accomplish that?

@grimfang4
Copy link
Owner

Using SDL_Renderer or SDL_gpu?

@urosg80
Copy link
Author

urosg80 commented Feb 9, 2017 via email

@grimfang4
Copy link
Owner

// Create the intermediate texture target
SDL_Texture* temp = SDL_CreateTexture(renderer, format, SDL_TEXTUREACCESS_TARGET, width, height);  // You should reuse this instead of creating a new one every time.

// Draw the text onto it
SDL_SetRenderTarget(renderer, temp);
FC_Draw(font, temp, 0, 0, "My Text");
SDL_SetRenderTarget(renderer, NULL);

// Now draw it rotated somewhere
SDL_Rect dest = {x, y, w, h};
SDL_RenderCopyEx(renderer, temp, NULL, &dest, angle, NULL, SDL_FLIP_NONE);

SDL_DestroyTexture(temp);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants