SDL_ttf | font files with Simple Directmedia Layer | User Interface library
kandi X-RAY | SDL_ttf Summary
kandi X-RAY | SDL_ttf Summary
This library is a wrapper around the excellent FreeType 2.0 library, available at: This library allows you to use TrueType fonts to render text in SDL applications. To make the library, first install the FreeType library, then type './configure' then 'make' to build the SDL truetype library and the showfont and glfont example applications. Be careful when including fonts with your application, as many of them are copyrighted. The Microsoft fonts, for example, are not freely redistributable and even the free "web" fonts they provide are only redistributable in their special executable installer form (May 1998). There are plenty of freeware and shareware fonts available on the Internet though, and may suit your purposes. This library is under the zlib license, see the file "COPYING.txt" for details. Portions of this software are copyright 2013 The FreeType Project (www.freetype.org). All rights reserved. Enjoy! -Sam Lantinga slouken@libsdl.org (6/20/2001).
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of SDL_ttf
SDL_ttf Key Features
SDL_ttf Examples and Code Snippets
Community Discussions
Trending Discussions on SDL_ttf
QUESTION
I have trouble including and linking SDL_ttf
and SDL_image
to my project. I have a cmake file that works only for SDL
and SDL_gfx
on Clion. I guess the problem is from the cmake file.
I got several errors when I build the project:
undefined reference to `FUNCTION'
The libraries which I used for my project: https://github.com/satayyeb/sdl2-libraries
sdl2 folder (where library files are located) tree:
...ANSWER
Answered 2022-Feb-06 at 20:54I found the problem:
In
sdl2-image-lib
andsdl2-ttf-lib
directory there arelibSDL2_image.dll.a
andlibSDL2_ttf.dll.a
binary files that must be linked instead oflibSDL2_image.a
andlibSDL2_ttf.a
files.dll files must be copied to the directory where the EXE file is located. the dll files are in bin folders of the library.
The libraries which I used for my project: https://github.com/satayyeb/sdl2-libraries
and the modified CMakeLists.txt:
QUESTION
I've been chasing this visual bug for a while, and I've concluded that the process of renderCopying from one texture to another results in a slightly darkened image.
...ANSWER
Answered 2022-Feb-06 at 06:06You recursively apply blend operation multiple times on the same data.
Your render texture have the same size as your window. You didn't clear it, so let's presume it is zeroed by default, including alpha (it may be implementation-dependant, i don't see documentation states that anywyere; explicit clear with required colour may be a good idea).
SDL_ttf gives you surface with alpha channel. Then you render your first text fragment to that texture with blendmode=blend, blending it atop of zeroes. If you look at the formulas for blend operations - alpha values of your render target gets overwritten by your text texture (dstA = srcA + (dstA * (1-srcA))
, and dstA
is 0, so it is just srcA
), but colour values are multiplied by your source alpha, so srcRGB = srcRGB * srcA
.
Then you blend this target texture on top of your screen, which is cleared to (0, 0, 0, 255), applying the same blend operation again, resulting in another blending by the same srcA, so your colours are now srcRGB = srcRGB * srcA * srcA
. This is obviously incorrect.
It gets worse with your second text fragment, because you do all that again, but never clear your render target. So when you use your render target again, you do another rendering of entire texture, including what was rendered at first text fragment, applying another blend on top of that.
You need to do blending only once. There are multiple ways to do so, and you'll have to decide what's best for your case. I don't know how you want to use your render texture, so presuming you want to keep alpha values, you need to do blending at last stage. That can be achieved by drawing into render target with blendmode=none, and then blitting your render texture onto screen, but only once. For example:
QUESTION
I am trying to figure out how to use SDL2 on VSCODE. I've got basic code and windows working but when I add additional functions and files, it doesn't seem to want to compile. I'm new to this but I thought I included the necessary things in my headers and in my build.
For the main
...ANSWER
Answered 2022-Jan-02 at 22:08You can use g++
to build your program in two ways:
In two stages, first by compiling the individual
.cpp
files as translation units to object files.o
and then in another invocation ofg++
to link them together into an executableOr you can use a single invocation of
g++
to compile and link the executable.
You are currently trying to mix the two modes somehow. For the single-invocation build you should call g++
only once and add all .cpp
files to it:
QUESTION
I've been having trouble compiling an executable with SDL 1.2 and C that will work on another machine. I'vee been compiling it from Ubuntu using a makefile. I'd like to be able to send a "bin.zip" to a classmate, with "SDL.dll" and "SDL_ttf.dll" inside as well as "prog" the executable that I compiled for them.
I would expect them to be able to run that "prog" from their own Ubuntu desktop (Virtual Machine, if that's relevant) and not need to install libsdl1.2debian
and libsdl-ttf2.0-0
themselves first, since I included the DLLs.
Note that they can run it fine once they've installed those libraries.
My project structure, at compilation, is such:
- 2048-c
- /bin (dlls and executable)
- /include (".h" header files)
- /lib ("SDL.lib", "SDL_ttf.lib", "SDLmain.lib")
- /src (".c" source files)
- "makefile"
My makefile looks like this:
...ANSWER
Answered 2021-Dec-14 at 18:23Yes, I was missing something obvious : DLLs are specifically for Windows
Now, as for getting an executable to work without installing the required libraries, I still haven't managed that (linking statically didn't pan out, in my case), but at least I learnt something.
If I give cross-compilation to Windows a try, I'll try to update this.
QUESTION
i use SDL Lib and SDL_TTF Lib
I have a code that allows you to enter text And then display the text on my window so here the code
...ANSWER
Answered 2021-Jul-08 at 14:12It's because once you've outputed something to the screen, it stays there unless you clear it or put something above it.
Think of it as a painter plotting things on his canvas. If you want to overwrite something, you have to overwrite the previous shape.
The simplest way to deal with this would be to call SDL_RenderClear at the beginning of every draw, it clears the whole screen clean, and then every time you render something it'll never overlap the previous stuff.
QUESTION
Here is a minimal example of how I render my SDL text:
...ANSWER
Answered 2021-Jul-06 at 03:03You are setting your destination
rectangle to be different than the text that was rendered to the surface so it will stretch.
You should also free up the surface before your main loop.
So the code I think you are looking for:
QUESTION
I'm writing this simple program to learn how to work with audio with SDL. The program opens a window with a button that says go and when you hit the button it should play a WAV of a drum sample. There are no errors and the program doesn't crash it's just that instead of playing the drum sound it makes a weird buzzing noise that doesn't stop until you exit the program. I think it's something to do with the audio callback function but I am very new to this so I'm not sure exactly how it works.
...ANSWER
Answered 2021-Jun-30 at 16:15The issue may be that you're using SDL_MixAudio
.
Your code mixes in the data from the .wav
file, but mixes it into what?
What is in stream
before calling SDL_MixAudio
?
I get the same buzz, but when I use memset
to zero out the stream
buffer before calling SDL_MixAudio
, I get the correct sound from the .wav
file.
I don't know for sure but I believe that on the second and subsequent calls to your mixing
function, the data from the prior callback is still in the stream
buffer.
Side note: When the .wav
data has finished playing, we can reset sound.dpos
to replay the file again.
Here's the refactored code:
QUESTION
I got another Problem with including libs into my cmake Project. The Project specs are:
IDE: Visual Studio Code
Kit: GCC 10.3.0 Mingw64 (via msys2)
The two packages, Freetype and Luajit, are installed via msys (in mingw64 mode), too.
So, this is my CMakeLists.txt:
...ANSWER
Answered 2021-Jun-29 at 12:39I found an Answer for myself. It seems like the Errors appear randomly. After relaunching Vscode 2-3 times, the errors appear or do not appear randomly. Seems like a problem with the IDE 😐
QUESTION
I'm using clang++
on Windows to do some very basic SDL2 stuff, but I just found out that Clang++ doesn't come with the , nor "fmt" out of the box.
What I need is a more pretty way to concatenate a bunch of formatted strings, that would have been trivial elsewhere, and although I managed to get it to work I'm unhappy with the long repeated structures. This is what I got:
...ANSWER
Answered 2021-May-17 at 10:46Would something like this be acceptable?
QUESTION
I am trying to make a portable framework library that works between Linux and Windows, however whenever I compile my code on Linux I keep running into an error:
...ANSWER
Answered 2021-Mar-27 at 02:36CMAKE_POSITION_INDEPENDENT_CODE
only influences targets defined after it has been set. However, you're setting CMAKE_POSITION_INDEPENDENT_CODE
to ON
after including the extern
subdirectory, which is why the external libraries are not built with position-independent code.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install SDL_ttf
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page