开发者

SDL writing text

开发者 https://www.devze.com 2023-03-12 04:27 出处:网络
I\'m having a problem for a SDL project, I\'d like to show text on the window and allow the user to input text. As much as I know, there is no simple way to achieve that. Do you hava any suggestion?

I'm having a problem for a SDL project, I'd like to show text on the window and allow the user to input text. As much as I know, there is no simple way to achieve that. Do you hava any suggestion? Note:开发者_开发问答 I use C programming langage. I know there is a library called SDL_ttf which doesn't seems to make the job I want.


I have to be honest, as I was reading your question, SDL_ttf immediately sprang to mind. It's not too hard to use and there are plenty of docs available.

What it sounds like you are looking for, is a library that provides a simple console interface, where your main programming interaction is to write(...) and read(...) text and it handles display, scrolling and so on.

This project has a lot of code showing how to implement a simple 'console' in SDL, and it does use SDL_ttf to do so.

I'm not convinced you are going to avoid it, unless you grab someone's library that hides it away from you like this one but you are going to have less control over the display and interactivity this provides.


I must go with benosteen, SDL_ttf is a really good option. For my part, I used this tutorial to make it work in my project. It's really simple and straightforward.

EDIT: I had some troubles with the Blending functionality of SDL_ttf, but I managed to make it work after QuasarDonkey found the problem in this question.

Have a look for a straight forward example on how to use it and create text surface.

0

精彩评论

暂无评论...
验证码 换一张
取 消