Questions tagged [sdl-2]

For questions and issues regarding Simple DirectMedia Layer 2 (SDL2). If you're using SDL 1.2, use tag [sdl-1.2]. If you're questioning the library in general, use tag [sdl].

Simple DirectMedia Layer 2.0 (SDL2) is the second generation of a popular open source cross-platform library that provides a simple interface to graphics, sound, and input devices. The new version comes with lots of new features such as full 3D hardware acceleration and the less restrictive zlib license.

Resources:

2910 questions
129
votes
2 answers

What is an SDL renderer?

I'm starting with SDL2 and having some trouble trying to understand what an SDL_Renderer is. What is it? What does it do? What's the difference between SDL_Renderer, SDL_Window, SDL_Surface and SDL_Texture and how they are related? I had issues with…
prcastro
  • 2,178
  • 3
  • 19
  • 21
125
votes
20 answers

unresolved external symbol __imp__fprintf and __imp____iob_func, SDL2

Could someone explain what the __imp__fprintf and __imp____iob_func unresolved external means? Because I get these errors when I'm trying to compile: 1>SDL2main.lib(SDL_windows_main.obj) : error LNK2019: unresolved external symbol…
RockFrenzy
  • 1,585
  • 3
  • 11
  • 13
106
votes
4 answers

Difference between surface and texture (SDL / general)

Can anyone explain to me in simple words what is the difference between texture and surface? I saw it used in SDL2 as SDL_Surface and SDL_Texture. SDL_Textureis created from SDL_Surface which in turn is created from image/bitmap. Both are collection…
ps-aux
  • 11,627
  • 25
  • 81
  • 128
57
votes
7 answers

How to render text in SDL2?

I'm using an SDL_Window and SDL_Renderer. Is it possible to use SDL_TTF with SDL_Render/SDL_Window? If so, how?
Ethan Webster
  • 719
  • 2
  • 6
  • 11
51
votes
12 answers

Using SDL2 with CMake

I'm trying to use CLion to create a SDL2 project. The problem is that the SDL headers can't be found when using #include's. My CMakeLists.txt file: cmake_minimum_required(VERSION 2.8.4) project(ChickenShooter) set(SDL2_INCLUDE_DIR…
Ovenkoek
  • 621
  • 1
  • 6
  • 7
49
votes
3 answers

"winapifamily.h: No such file or directory" when compiling SDL in Code::Blocks

I am following along with the SDL2.0 tutorials by LazyFoo, using Code::Blocks 13.12. I have had no trouble getting SDL2 linked and running in VS2010 but have changed IDE and come across this error: winapifamily.h: No such file or directory I think…
user3427293
  • 491
  • 1
  • 4
  • 3
38
votes
6 answers

How to use SDL2 and SDL_image with cmake

I'm looking for the simplest way to compile a c++ program using SDL2 and SDL_image with cmake. Here is my best attempt, after hours of searching: CMakeLists.txt project(shooter-cmake2) cmake_minimum_required(VERSION…
Carl Lemaire
  • 383
  • 1
  • 3
  • 7
32
votes
2 answers

Xcode 5 crashes when running an app with SDL 2

I tried to follow these two tutorials (or the applicable parts of them, due to version differences) to install SDL 2.0.2 to work with Xcode 5.1: Tutorial 1 Tutorial 2 Running any program with the SDL 2 framework linked causes Xcode to crash with…
Olli Niskanen
  • 1,535
  • 2
  • 12
  • 18
32
votes
3 answers

What is the point of an SDL2 Texture?

I'm kind of stuck on the logic behind an SDL2 texture. To me, they are pointless since you cannot draw to them. In my program, I have several surfaces (or what were surfaces before I switched to SDL2) that I just blitted together to form layers.…
Qix - MONICA WAS MISTREATED
  • 14,451
  • 16
  • 82
  • 145
29
votes
2 answers

How to render fonts and text with SDL2 efficiently?

Saw this post here about using SDL_ttf to render text in a game. However that approach requires calling SDL_CreateTextureFromSurface(), along with the SDL_FreeSurface() and SDL_DestroyTexture() every single frame. Is creating textures (and probably…
introiboad
  • 997
  • 1
  • 11
  • 18
29
votes
3 answers

How to draw pixels in SDL 2.0?

How does one draw with pixels in SDL2.0? I'm trying to get familiar with C++, but this is very difficult to do without pretty pictures, so I'm trying to get a very basic graphics display thing running. All I really want it to do is give me a…
Jordan
  • 695
  • 2
  • 8
  • 18
28
votes
2 answers

What is the difference between an SDL physical key code and an SDL virtual key code?

The struct SDL_Keysym has SDL_Scancode and SDL_Keycode members. What is the difference between them? The documentation does not really clear it up for me. I tried both and they seem to do the same thing.
Mampoempan
  • 347
  • 1
  • 3
  • 8
26
votes
1 answer

Installing SDL2 on Linux

I try to run simple test.cpp from Twinklebar SDL tutorial, I get this error: test.cpp:2:10: fatal error: 'SDL2/SDL.h' file not found So I look up the sdl development package in Ubuntu/Mint: aptitude search sdl | grep 2 All I can find is…
exebook
  • 32,014
  • 33
  • 141
  • 226
26
votes
6 answers

SDL_PollEvent vs SDL_WaitEvent

So I was reading this article which contains 'Tips and Advice for Multithreaded Programming in SDL' - https://vilimpoc.org/research/portmonitorg/sdl-tips-and-tricks.html It talks about SDL_PollEvent being inefficient as it can cause excessive CPU…
TPS
  • 2,067
  • 3
  • 23
  • 32
25
votes
3 answers

How do I use SDL2 in my programs correctly?

I want to make a game using SDL2, but I'm unable to compile and/or run my code, please help! SDL2 is notoriously hard to set up, and it's often the first library aspiring game developers try to use. This post is intended as a canonical duplicate…
HolyBlackCat
  • 78,603
  • 9
  • 131
  • 207
1
2 3
99 100