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
32
votes
5 answers

Why does valgrind say basic SDL program is leaking memory?

Here is the SDL program: #include int main(int argc, char** argv){ SDL_Init(SDL_INIT_VIDEO); SDL_Surface* screen = SDL_SetVideoMode(640, 480, 16, SDL_HWSURFACE); SDL_Quit(); return 0; } Compiled with the command: g++ -o test…
Christian
  • 1,111
  • 2
  • 13
  • 15
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
32
votes
6 answers

'"SDL.h" no such file or directory found' when compiling

Here's a piece of my current Makefile: CFLAGS = -O2 -Wall -pedantic -std=gnu++11 `sdl-config --cflags --libs` -lSDL_mixer I have libsdl installed properly, SDL.h is in /usr/include/sdl where it belongs, but it just won't compile. I also have the…
argoneus
  • 1,097
  • 2
  • 13
  • 24
31
votes
2 answers

In What Order Should I Send My Vertices To OpenGL for Culling

I'm learning a spot of 3d opengl, and it's going rather well, I've got a nice camera moving about and some simple cube objects, at the moment. Currently using vertex arrays, but I'm swapping to VBOs pretty quick here. I'm just trying to enable…
ultifinitus
  • 1,813
  • 2
  • 19
  • 32
31
votes
4 answers

Current state and solutions for OpenGL over Windows Remote

OpenGL and Windows Remote don't play along nicely. Solutions for this are dependent on the use case and answers are fragmented across the vast depths of the net. This is a write-up I wish existed when I started researching this, both for coders and…
FrostKiwi
  • 741
  • 1
  • 6
  • 16
30
votes
1 answer

Learning SDL in C

I know the basics of C and I'm looking into SDL. What I need at this point are some tutorials, documentation or perhaps a book about using the SDL libraries in C, especially about graphics. The problem is that every online resource that I have…
Bottle Rocket
  • 357
  • 1
  • 4
  • 6
30
votes
5 answers

SDL window does not show

This is my code: #include #include int main(int argc, const char * argv[]) { SDL_Init(SDL_INIT_VIDEO); SDL_Window *_window; _window = SDL_CreateWindow("Game Engine", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 700,…
Michael
  • 791
  • 3
  • 10
  • 23
30
votes
3 answers

How do I use Qt and SDL together?

I am building a physics simulation engine and editor in Windows. I want to build the editor part using Qt and I want to run the engine using SDL with OpenGL. My first idea was to build the editor using only Qt and share as much code with the engine…
bineteri
  • 721
  • 1
  • 5
  • 12
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
27
votes
6 answers

OpenGL Rendering in a secondary thread

I'm writing a 3D model viewer application as a hobby project, and also as a test platform to try out different rendering techniques. I'm using SDL to handle window management and events, and OpenGL for the 3D rendering. The first iteration of my…
rjacks
  • 1,023
  • 2
  • 10
  • 16
26
votes
0 answers

How Do I Set Up Visual Studio 2015 with SDL2 For Android, iOS, and Windows Development?

Visual Studio 2015 has integrated Android Emulator support. They even have a pre-made template to set up Windows Phone, Android, and iOS targets. It seems like there should be some way of setting up SDL 2.0 in the same solution to easily toggle…
M2tM
  • 4,415
  • 1
  • 34
  • 43
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
25
votes
9 answers

enum class as array index

I made an enum as: enum class KeyPressSurfaces { KEY_PRESS_SURFACE_DEFAULT, KEY_PRESS_SURFACE_UP, KEY_PRESS_SURFACE_DOWN, KEY_PRESS_SURFACE_LEFT, KEY_PRESS_SURFACE_RIGHT, KEY_PRESS_SURFACE_TOTAL }; and later on I attempt to…
Hayden Piper
  • 353
  • 1
  • 3
  • 9