7 ms·
SDL 2.0.0 is out after many years in development
- bloodorange 13y agoI remember using SDL more than a decade ago and in general it was a pleasant experience. My only gripe was that it needs to hijacked the main loop. Nevertheless, I will give it a shot again. Good work Sam!
- lifthrasiir 13y agoSDL_main is no longer mandatory (though it is still there); #define-ing SDL_MAIN_HANDLED and calling SDL_SetMainReady once before SDL_Init is sufficient now. Edit: Ah, if the main loop you refer is SDL_Event loop, as exDM69 said, SDL always supported passive event functions that can be called at your original idle function. SDL 2.0 adds an active event watcher (SDL_AddEventWatch etc.) as an alternative though.
- pgz 13y agoThat's great news, I always felt the whole SDL_main thing to be quite evil.
- exDM69 13y ago> That's great news, I always felt the whole SDL_main thing to be quite evil. Evil or not, it solves a practical problem that you would have to work around if SDL did not. And AFAIK, you have always had the option of not using SDL_main if you wish to solve the problem on your own. On desktop platforms the program entry point is pretty easy to solve (main vs. WinMain) with an SDL_main-style macro or command line args on win32 compilers. But when you start working with iOS and Android, it gets more hairy.
- pgz 13y agoOn OS X main was wrapped in a function that made it work with the Finder (manipulating an argv containing --psn). It was annoying to me because I worked on a application that did the same thing internally and where SDL was not a hard dependency. But well, it's not that bad as I make it sound.
- lclarkmichalek 13y agoIt did make writing bindings for other languages rather interesting
- exDM69 13y ago> My only gripe was that it needs to hijacked the main loop. SDL has never hijacked the main loop, unlike e.g. GLUT. SDL has SDL_WaitEvent and SDL_PollEvent and leaves the main loop to you.
- reidrac 13y agoI wrote a silly (unfinished) game about 10 years ago, and SDL portability never ceases to amaze me. The game has been ported to devices I didn't even know they existed. It's amazing because I did it for fun and I used some data structures I would have never expect to be so portable (ie. using a double linked list of objects in static memory instead of alloc/free). I wonder if that's why it works even in very limited hardware. My favourite, the game running on a TI-Nspire calculator: http://www.youtube.com/watch?&v=acdAqxiwG7I&t=15 http://www.youtube.com/watch?&v=acdAqxiwG7I&t=15
- chrisballinger 13y agoLooks like they changed their license from LGPL to zlib as well. I wonder if this will increase adoption, or if it just was so Valve could use it in Steam for Linux.
- scoopr 13y agoAlso pretty much required to get applications sdl to ios/android store.
- tadfisher 13y agoThe Play Store is pretty much license-agnostic. At least there is no policy preventing GPL works that I know of.
- rsynnott 13y agoWhile the FSF discourages use of the Android marketplace, they do say there's no specific GPL conflict. Compliance is potentially a bit more of a pain for the developer, of course; strictly speaking they have to make sure the LGPL-covered code is available for download for three years after distribution ends. They also strictly speaking have to provide a mechanism to re-assemble the app; example here: http://sparrowmailapp.com/lgpl.php http://sparrowmailapp.com/lgpl.php (though note that a lot of people just don't bother).
- belorn 13y agoGiven that Starcraft 2 have LGPL code in it, I sincerely doubt that games stores had any part in the decision.
- rsynnott 13y agoI doubt it would be a huge issue for Valve; they already use LGPL code. However, it's often a big deal for small developers; simpler licenses mean simpler due diligence on investment and such, and a lot of companies are cautious of LGPL in anything that they'll be distributing.
- munchor 13y ago
- munchor 13y agoLately I started using SFML instead of SDL for C++ Game Development. However, I'll still use SDL on future projects I hope. It's a brilliant library, so compact and portable that the games you write will be able to be compiled to a lot of platforms, even high school graphing calculators[1]. The SDL development still impresses me and 2.0.0 is a major milestone and multiple windows, new OpenGL, touch support, Android and iOS support are here to keep SDL alive with all the new frameworks and "engines". I hope it does well! [1]: http://www.omnimaga.org/index.php?topic=12378.0 http://www.omnimaga.org/index.php?topic=12378.0
- angersock 13y agoThe network and scenegraph stuff that SFML comes with is quite nice--the choice of C++, though, makes other language bindings a bit more clunky.
- davexunit 13y agoYeah, imo SFML's biggest weakness is that it is written in C++ instead of C.
- winter_blue 13y agoI really like SFML, I've been using for a small game project of mine as well. The API is just nice and beautiful. I was wondering how SDL 2.0 stacks up against SFML? Does anyone know much about it? I'm only doing 2D game development, so SDL's "simple 2D rendering API that can use Direct3D, OpenGL, OpenGL ES, or software rendering behind the scenes" is perfect for my needs. However it needs to support two basic things: * Rotation (additional matrix transformation like scaling & shearing would be nice as as well) * Transparency (being able to apply a color filter not necessarily limited to the alpha channel, like an RGBA filter would be nicer) Does it support the above? (I'm guessing it does -- just want to be sure.) Also, I know Android/iOS support for SFML is in the pipeline, but the fact that it's not ready yet is another reason it might be good to switch to SDL 2.
- lifthrasiir 13y ago
- telephonetemp 13y agoIf I start a new multimedia project today and aim to support the widest range of devices should I use this version of SDL or 1.x?
- aktau 13y agoUse SDL2, much better and official support for mobile platforms. The only platforms that were killed in SDL2 are old ones like MacOS9 etc.
- frozenport 13y agoI never understood SDL vs OpenGL. As somebody who does OpenGL why should I use SDL?
- lifthrasiir 13y agoOpenGL is a platform-independent API for graphics. SDL is a platform-independent API for everything else relevant to the game development, and also provides an initialization procedure for OpenGL (which OpenGL itself does not provide, so you needed to use platform-specific APIs like WGL and AGL or later standards like EGL).
- mahmud 13y agoIsn't SDL the simplest, most portable way to use OpenGL? OpenGL by itself is useless, it just does 3D graphics, and its GLUT library is too bare-bones to be of much use. SDL is a good, portable chassis for OpenGL application that don't need native GUI integration. An SDL OpenGL app will compile and run almost anywhere, with minimal fuss. Compare that to using OpenGL contexts inside platform-specific toolkits.
- angersock 13y agoGLFW is an excellent library: http://www.glfw.org/ http://www.glfw.org/ It's very, very barebones (just enough to GL up to do a thing), but it's quite good in that role.
- mahmud 13y agoSDL exists, is tiny, modular and efficient. Not to mention has loads of extensions.
- angersock 13y ago#include <GLFW/glfw3.h> int main(void) { GLFWwindow* window; if (!glfwInit()) return -1; window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL); if (!window) { glfwTerminate(); return -1; } glfwMakeContextCurrent(window); while (!glfwWindowShouldClose(window)) { /* Render here */ glfwSwapBuffers(window); glfwPollEvents(); } glfwTerminate(); return 0; } VS #include <GL3/gl3.h> #include <SDL.h> /* Our program's entry point */ int main(int argc, char *argv[]) { SDL_Window *mainwindow; SDL_GLContext maincontext; SDL_Event event; int running = 1; if (SDL_Init(SDL_INIT_VIDEO) < 0) exit(1); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); mainwindow = SDL_CreateWindow(PROGRAM_NAME, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 512, 512, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN); if (!mainwindow) exit(1); maincontext = SDL_GL_CreateContext(mainwindow); SDL_GL_SetSwapInterval(1); while (running) { while (SDL_PollEvent(&event) { if ( event == SDL_WINDOWEVENT_CLOSE ) { running = 0; break; } /* render */ } SDL_GL_SwapWindow(mainwindow); } SDL_GL_DeleteContext(maincontext); SDL_DestroyWindow(mainwindow); SDL_Quit(); return 0; } It's got SDL beat a bit in simplicity for OpenGL, sorry dude.
- zokier 13y agoI wonder how SDL 2D rendering capabilities compare to SFML, now that they both are OpenGL accelerated.
- EzGraphs 13y agoFrom the About: "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." http://www.libsdl.org/index.php http://www.libsdl.org/index.php
- reidrac 13y agoOh, yes. New website!
- Aardwolf 13y agoAwesome work, I'm looking forward to use it! I always liked the combination of SDL+OpenGL. Clipboard support is also very exciting because using X for that in Linux is a nightmare :)
- ambrop7 13y agoLet me guess: it's still impossible to minimize a full screen game on Linux or alt-tab etc., and the joystick will still not be recognized if you plug it in after the game starts.
- exDM69 13y ago> Let me guess: it's still impossible to minimize a full screen game on Linux or alt-tab etc. You can hardly blame SDL for this, games are not really what X11 was designed for. Setting up full screen and asking for exclusive access to the keyboard will prevent the window manager from doing anything to it. My solution for this problem: use a window manager that can full screen any window and switch back. > and the joystick will still not be recognized if you plug it in after the game starts. To be fair, 99% of AAA games don't support joystick hotplugging either. It's really annoying. Since you have not checked whether this is actually the situation and do not properly understand the other components in the equation, I find your attitude offensive.
- ambrop7 13y ago> You can hardly blame SDL for this, games are not really what X11 was designed for. It's funny how the Windows version of the game usually works just fine in Wine, minimization and window switching included. > Setting up full screen and asking for exclusive access to the keyboard will prevent the window manager from doing anything to it. Then why are they asking for exclusive access to the keyboard in the first place? X has rich input protocols (XInput2 was recently designed). > Since you have not checked whether this is actually the situation True, but I have read the changelog, and it doesn't mention any of these two annoying problems to be fixed. Part of the reason I made this comment is to see if someone else knows whether they were fixed.
- anonymous 13y agoIIRC, there was a presentation by Valve where they complained that even if you don't do a keyboard grab, some window managers do it for you when you request a fullscreen window. For an SDL2-using game, I tried BrütalLegend and alt-tab works as you'd expect when using OpenBox. I usually just run games in a separate X server with just OpenBox to isolate them from messing with my main desktop. Plus, they can't block ctrl+alt+F7.
- batiste 13y agoGreat library. Simple to use and efficient. I have been using it for some time. I have created a little TMX file reader aiming at game development. C is hard but fun: https://github.com/batiste/sdl2-game-loop https://github.com/batiste/sdl2-game-loop
- SteveDeFacto 13y agoI have been using SDL2 for awhile now and it is a great library. It was definitely not ready until now though. I still need to rewrite my game engine to work with the current version. I am happy to hear this will be the last rewrite though!
- shmerl 13y agoWhat about OpenGL 4.x support? OpenGL 3.x is not enough already.
- dkersten 13y agoI used SDL 2 after Sam's "please use SDL 2 and report problems" email about 2 or 3 years ago and it was a pleasant experience and a much needed upgrade over SDL 1 (though most of the docs were still incomplete). So this announcement makes me happy.
- 0xdeadbeefbabe 13y agoHow does android and ios support work? What is the process for compiling and using it from an objective C (ios) or java (android)?
- thecodemonkey 13y agoWoo! I have been using SDL for years to build all sorts of projects (games, touch screen interfaces, etc.). But as others here have noted I migrated over to use SFML, mainly because of its nice object-oriented implementation as well as the additional convenience features such as rotation and better alpha support.
- jamesmiller5 13y agoThought I'd share this comprehensive 36 chapter SDL game programming tutorial series, though it is for SDL 1. http://lazyfoo.net/SDL_tutorials/ http://lazyfoo.net/SDL_tutorials/