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
18
votes
6 answers

SDL2: LNK1561: entry point must be defined

I want to compile this code: #include int main(int argc, char* argv[]) { return 0; } But it can't be linked: Error 1 error LNK1561: entry point must be defined There is some strange code in this library:…
Dmitry
  • 7,457
  • 12
  • 57
  • 83
17
votes
3 answers

Using homebrew installed SDL2 with Xcode

I have installed SDL2 using Homebrew but now I don't know how to make sure Xcode can use it! I imported the created library and added it to the build phases tab of my project. But when I try to build I get the error 'SDL2/SDL.h' not found
Jaap Wijnen
  • 417
  • 2
  • 6
  • 12
17
votes
1 answer

SDL2 / Surface / Texture / Render

I'm trying to learn SDL2. The main difference (as I can see) between the old SDL and SDL2 is that old SDL had window represented by it's surface, all pictures were surfaces and all image operations and blits were surface to surface. In SDL2 we have…
Viktor
  • 295
  • 1
  • 3
  • 10
16
votes
1 answer

SDL_PollEvent() stuttering while idle?

I've cobbled together a very basic game loop in C++ using SDL2, and I've noticed that every few seconds, SDL_PollEvent seems to be unusually slow, even when nothing is happening. I sent my deltaTime to console every loop, and its about 100ms…
Aaron Schultheis
  • 419
  • 2
  • 10
16
votes
4 answers

SDL2_image not found

I am trying to compile the following code which has the headers: #include #include However after running the following makefile: g++ -std=c++11 src/main.cpp -lSDL2 -lSDL2_image I get the following error: fatal…
mas4
  • 989
  • 1
  • 8
  • 20
16
votes
4 answers

SDL2: How to properly toggle fullscreen?

I have problems deactivating fullscreen mode with my program. Entering fullscreen happens correctly, but trying to go back to windowed mode doesn't work, the only effect is that the cursor gets shown again. Here's the MCVE/SSCCE that reproduces the…
Emil Laine
  • 41,598
  • 9
  • 101
  • 157
16
votes
3 answers

How do I take and save a BMP screenshot in SDL 2?

Using just a given SDL_Window* and SDL_Renderer*, how can I create and save a screenshot in SDL 2.0?
Neil Flodin
  • 578
  • 7
  • 22
15
votes
1 answer

How is it possible to determine the correct drawable size of a window on Windows 10? (SDL2)

I am working on an OpenGL application. I use a high-dpi screen, and the Windows GUI is scaled to 125%, to make the programs look like on a regular screen. If I create a 800*600 window using SDL2, it appears the same size as in a regular screen, but…
Iter Ator
  • 8,226
  • 20
  • 73
  • 164
15
votes
4 answers

SDL2.0 Alternative for SDL_Overlay

So I've been trying to go through the following tutorial on ffmpeg: http://dranger.com/ffmpeg/tutorial02.html However, when I try to compile using gcc, I get the following output: root:/Users/mbrodeur/Downloads/HACKATHON CONTENT/Tutorials-> gcc -o…
Disco Globeulon
  • 459
  • 1
  • 6
  • 16
14
votes
3 answers

Fastest way to draw filled quad/triangle with the SDL2 renderer?

I have a game written using SDL2, and the SDL2 renderer (hardware accelerated) for drawing. Is there a trick to draw filled quads or triangles? At the moment I'm filling them by just drawing lots of lines (SDL_Drawlines), but the performance…
Tom Davies
  • 2,386
  • 3
  • 27
  • 44
14
votes
2 answers

What happened to FindSDL2 in CMake?

I use SDL2 in my game. I always was using custom FindSDL2.cmake, because there is no one in standard CMake set. However, some time ago posts about FindSDL2 did appeared. Example: Reddit post. If your cmake is new enough and it has FindSDL2.cmake…
val - disappointed in SE
  • 1,475
  • 3
  • 16
  • 40
14
votes
1 answer

How do I link SDL2 using CMake?

I used the .cmake files from https://github.com/brendan-w/collector/tree/master/cmake, and I put them in the same directory as my CMakeLists.txt, then I used the code: set(CMAKE_MODULE_PATH FindSDL2.cmake FindSDL2_image.cmake) find_package(SDL2…
user3063750
  • 833
  • 1
  • 9
  • 13
14
votes
2 answers

undefined reference to WinMain@16 C++, SDL-2

I've been getting the error undefined reference to WinMain@16. To save space, here's a link to all the files currently in the project. At present, it shouldn't do much other than create a window, fill it in green and then draw a box in the corner,…
The Orca
  • 220
  • 2
  • 10
14
votes
1 answer

Smart pointers with SDL

For my game should I use a raw pointer to create SDL_Window, SDL_Renderer, SDL_Texture etc. as they have specific delete functions SDL_DestroyTexture(texture); or should I add a custom deleter when I create a unique_ptr or shared_ptr and if so…
Dennis Harrop
  • 167
  • 1
  • 7
13
votes
1 answer

SDL2 Can't create window since it couldn't find matching GLX visual

I have a problem as i am currently running Ubuntu Terminal on Windows 10. I also have XMing installed as my X-server(I use XMing for qemu,etc...). And i am trying to run this SDL2 Program. So i have this for main.cpp: #include #include…
amanuel2
  • 4,508
  • 4
  • 36
  • 67