How to render text in SDL2?

Yep, it is possible, given that you have a renderer and a window plus you don’t really have any thoughts on dabbling with surfaces then you might want to mind on creating texture, here is a sample code //this opens a font style and sets a size TTF_Font* Sans = TTF_OpenFont(“Sans.ttf”, 24); // this is … Read more

Difference between surface and texture (SDL / general)

Basically your assumption “has to do something with GPU?” is right. SDL_Surface is used in software rendering. With software rendering, as saloomi2012 correctly noticed, you are using regular RAM to store image data. Thus, in most cases you can access data buffer associated with surface directly, modifying its content, i.e. it is using CPU, hence … Read more

Static-linking of SDL2 libraries

It’s not necessary to recompile the library, SDL2 is given with static-link library named “libSDL2.a” on the folder “SDL2-2.0.0\i686-w64-mingw32\lib\”. Just be sure to add these options to the linker : “-lmingw32 -lSDL2main -lSDL2 -mwindows -lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lversion -luuid -static-libgcc” on Code:Blocks at “Project / Build Options… … Read more

Kivy error (python 2.7) : sdl2 import error

Problem It is looking for the Kivy dependencies (e.g. sdl2) in your virtualenv. Solution I have encountered the same problem. I did the following and it solved the problem. Environment Windows 10 PyCharm Community Python 3.5 Kivy dependencies installed (docutils, pygments, pypiwin32, kivy.deps.sdl2, kivy.deps.glew, kivy.deps.gstreamer) and for Python 3.5+ (kivy.deps.angle) PyCharm IDE Open the project … Read more

SDL2: Fast Pixel Manipulation

SDL_CreateTexture() w/SDL_TEXTUREACCESS_STREAMING + SDL_UpdateTexture() seems to work well enough with the right pixel format. On my system using the default renderer: Renderer name: direct3d Texture formats: SDL_PIXELFORMAT_ARGB8888 SDL_PIXELFORMAT_YV12 SDL_PIXELFORMAT_IYUV (though the opengl info is the same:) Renderer name: opengl Texture formats: SDL_PIXELFORMAT_ARGB8888 SDL_PIXELFORMAT_YV12 SDL_PIXELFORMAT_IYUV SDL_PIXELFORMAT_ARGB8888 gives me ~1ms/frame: // g++ main.cpp `pkg-config –cflags –libs sdl2` … Read more

sdl2 – ImportError: DLL load failed: The specified module could not be found and [CRITICAL] [App] Unable to get a Window, abort

I had the same problem. I solved this by removing Kivy and its dependencies first. python -m pip uninstall kivy python -m pip uninstall kivy.deps.sdl2 python -m pip uninstall kivy.deps.glew python -m pip uninstall kivy.deps.gstreamer python -m pip uninstall image Now reinstalling everything except gstreamer. python -m pip install –upgrade pip wheel setuptools python -m … Read more

How to use SDL2 and SDL_image with cmake

I think that the following will work, as it finds the libraries on my ubuntu system and the example function you provided can link: project(shooter-cmake2) cmake_minimum_required(VERSION 2.8) set(CMAKE_CXX_FLAGS “${CMAKE_CXX_FLAGS} -std=c++0x”) add_executable(${PROJECT_NAME} src/test.cpp) INCLUDE(FindPkgConfig) PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2) PKG_SEARCH_MODULE(SDL2IMAGE REQUIRED SDL2_image>=2.0.0) INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIRS} ${SDL2IMAGE_INCLUDE_DIRS}) TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${SDL2_LIBRARIES} ${SDL2IMAGE_LIBRARIES}) If cmake is executed with –debug-output it outputs: — Found PkgConfig: … Read more

Using SDL2 with CMake

This blog post shows how you can do it: Using SDL2 with CMake On Linux you can use a recent CMake (e.g. version 3.7) and using SDL2 works out of the box. cmake_minimum_required(VERSION 3.7) project(SDL2Test) find_package(SDL2 REQUIRED) include_directories(SDL2Test ${SDL2_INCLUDE_DIRS}) add_executable(SDL2Test Main.cpp) target_link_libraries(SDL2Test ${SDL2_LIBRARIES}) Under Windows you can download the SDL2 development package, extract it somewhere … Read more

unresolved external symbol __imp__fprintf and __imp____iob_func, SDL2

I have finally figured out why this is happening ! In visual studio 2015, stdin, stderr, stdout are defined as follow : #define stdin (__acrt_iob_func(0)) #define stdout (__acrt_iob_func(1)) #define stderr (__acrt_iob_func(2)) But previously, they were defined as: #define stdin (&__iob_func()[0]) #define stdout (&__iob_func()[1]) #define stderr (&__iob_func()[2]) So now __iob_func is not defined anymore which leads … Read more

How do I use SDL2 in my programs correctly?

This answer is about MinGW / GCC, and not Visual Studio. This answer only applies to Windows. Common errors The common errors are: SDL.h: No such file or directory (when compiling) Various SDL_main problems: “undefined reference to SDL_main”, “conflicting types for SDL_main” or “number of arguments doesn’t match prototype”, etc. (when compiling or linking) undefined … Read more