Questions tagged [sdl]

Simple DirectMedia Layer (SDL) is a cross-platform, free and open source multimedia library. Should not be confused with Security Development Lifecycle.

Simple DirectMedia Layer (SDL) is a cross-platform, free and open source multimedia library written in C that presents a simple interface to various platforms' graphics, sound, and input devices.

From SDL's home page:

Simple DirectMedia Layer is a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D. It is used by video playback software, emulators, and popular games including Valve's award winning catalog and many Humble Bundle games.

SDL officially supports Windows, Mac OS X, Linux, iOS, and Android. Support for other platforms may be found in the source code.

SDL is written in C, works natively with C++, and there are bindings available for several other languages, including C# and Python.

SDL 2.0 is distributed under the zlib license. This license allows you to use SDL freely in any software.

4893 questions
10
votes
2 answers

Cross-compiling SDL 2.0 application between supported platforms

I'm looking for a "Hello World" SDL 2.0 project that cross-compiles between all supported platforms: Windows, Linux, Mac, Android and iOS. Is there anything like that? I could not find on the official forums or docs. What tools are recommended?…
vinnylinux
  • 7,050
  • 13
  • 61
  • 127
10
votes
2 answers

SDL 2.0 retina mac

I have been playing around with SDL 2.0 but after searching I haven't found anything online about how to support retina macs. When creating a window using the following code. gWindow = SDL_CreateWindow("SDL Tutorial", SDL_WINDOWPOS_UNDEFINED, …
Eamonn
  • 187
  • 2
  • 13
10
votes
4 answers

Is there a faster and object orientated alternative to SDL for C++?

The current version of libsdl (1.2.x branch) is very, very slow with blending and per pixel alpha (as it uses software blending). Is there any other good alternative to it?
aviraldg
  • 9,531
  • 6
  • 41
  • 56
10
votes
2 answers

Can I replace SDL_GetTicks with std::chrono::high_resolution_clock?

Checking new stuff from C++, I have found the std::chrono library. I am wondering if std::chrono::high_resolution_clock could be a good replacement for SDL_GetTicks?
bcsanches
  • 2,362
  • 21
  • 32
10
votes
4 answers

How to keep the CPU usage down while running an SDL program?

I've done a very basic window with SDL and want to keep it running until I press the X on window. #include "SDL.h" const int SCREEN_WIDTH = 640; const int SCREEN_HEIGHT = 480; int main(int argc, char **argv) { SDL_Init( SDL_INIT_VIDEO ); …
BudwiseЯ
  • 1,846
  • 2
  • 16
  • 28
10
votes
1 answer

How to scale to resolution in SDL?

I'm writing a 2D platformer game using SDL with C++. However I have encountered a huge issue involving scaling to resolution. I want the the game to look nice in full HD so all the images for the game have been created so that the natural resolution…
David Saxon
  • 1,406
  • 1
  • 12
  • 23
9
votes
5 answers

How can I modify pixels using SDL?

I have a slight problem: I can't modify the pixels of an SDL screen. Specifically, the following code doesn't work. Uint32 * pixels = (Uint32 *) screen -> pixels; screen -> pixels = pixels; This compiles, but it doesn't show anything. What am I…
nory
  • 91
  • 1
  • 1
  • 2
9
votes
2 answers

How to use emscripten ports (SDL2 and Freetype) with cmake

I'm trying to compile a C++ project using CMake to webassembly. I'm using emscripten and I want to use the emscripten ports for SDL2 and Freetype. Normally, when compiling with emcc, you would use the flags: -USE_SDL=2 and -USE_FREETYPE=1, in order…
Astrejoe
  • 335
  • 2
  • 9
9
votes
2 answers

How can configuration tools like sdl-config be used with a cabalized project?

I have a working SDL/Haskell application that I would like to build using Cabal instead of the current Makefile (because that is the "Haskell way"). The Makefile is itself very simple, and I was hoping that the default cabal build process could…
fatuhoku
  • 4,815
  • 3
  • 30
  • 70
9
votes
1 answer

Why is SDL so much slower on Mac than Linux?

I am working on a single-threaded graphical program that renders using SDL2. See the end for a smaller example. It runs on both an old Linux machine and a somewhat less old Mac. The Linux computer has 1.60GHz processors while the Mac's processors…
JudeMH
  • 485
  • 2
  • 10
9
votes
8 answers

GameDevelopment: (Java & OpenGL) or (C++ & OpenGL & SDL)?

Since Java supports OpenGL, what is the best option for developing a game? Java + OpenGL C++ + SDL + OpenGL I always avoided Java (in game development, of course) because of it's speed. But, I discovered that Java supports OpenGL. So, I think…
Martijn Courteaux
  • 67,591
  • 47
  • 198
  • 287
9
votes
7 answers

Is an un-delayed infinite while loop bad practice?

In short: Does an un-delayed while loop consume significant processing power, compared to a similar loop which is slowed down by a delay? In not-so-short: I have run into this question more often. I am writing the core part of a program (either…
Roberto
  • 958
  • 13
  • 33
9
votes
2 answers

pip install pygame - SDL.h file not found

MacOS Sierra ➜ fun_python $ pip --version pip 9.0.1 from /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (python 3.5) pip install pygame is giving me the following error: src/scrap.c:27:10: fatal error: 'SDL.h' file…
AKS
  • 16,482
  • 43
  • 166
  • 258
9
votes
2 answers

What is the best way to handle event with SDL/C++

I am using SDL for the view parts of my game project. And I want to handle key press events without interrupting the main thread. So I decided to run an infinite loop in another view thread to catch any events and inform the main thread. However, I…
Ertan
  • 141
  • 1
  • 5
9
votes
2 answers

Error when Linking SDL2 using Clang on Windows "LNK1561: entry point must be defined"

I am trying to use clang on Windows to compile and link an SDL2 application. The reason for this is to try and keep my development environment consistent with other team members who are using OSX with XCode (compiling with clang). Since the Visual…
radcore
  • 329
  • 2
  • 10